Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export BLT targets #215

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ cmake_minimum_required(VERSION 3.14)
include(cmake/SetupChaiOptions.cmake)

set(BLT_CXX_STD c++14 CACHE STRING "")
set(BLT_EXPORT_THIRDPARTY On CACHE BOOL "")

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
message(STATUS "Setting CMAKE_CXX_EXTENSIONS to ON for PGI Compiler")
Expand Down
10 changes: 10 additions & 0 deletions cmake/thirdparty/SetupChaiThirdparty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,13 @@ if (CHAI_ENABLE_RAJA_PLUGIN)
message(STATUS "CHAI: using existing RAJA target")
endif()
endif ()

set(CHAI_NEEDS_BLT_TPLS False)
if (CHAI_ENABLE_MPI OR CHAI_ENABLE_HIP OR CHAI_ENABLE_OPENMP OR CHAI_ENABLE_CUDA)
set(CHAI_NEEDS_BLT_TPLS True)
endif ()

if (CHAI_NEEDS_BLT_TPLS)
blt_export_tpl_targets(EXPORT chai-blt-targets NAMESPACE chai)
install(EXPORT chai-blt-targets DESTINATION lib/cmake/chai)
endif()
13 changes: 8 additions & 5 deletions src/chai/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ target_include_directories(
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)

configure_file(
${PROJECT_SOURCE_DIR}/src/chai/chai-config.cmake.in
${PROJECT_BINARY_DIR}/share/chai/cmake/chai-config.cmake)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/src/chai/chai-config.cmake.in"
"${PROJECT_BINARY_DIR}/chai-config.cmake"
PATH_VARS CMAKE_INSTALL_PREFIX
INSTALL_DESTINATION lib/cmake/chai)

install(
FILES ${PROJECT_BINARY_DIR}/share/chai/cmake/chai-config.cmake
DESTINATION share/chai/cmake/)
FILES ${PROJECT_BINARY_DIR}/chai-config.cmake
DESTINATION lib/cmake/chai)

install(
FILES ${PROJECT_BINARY_DIR}/include/chai/config.hpp
Expand Down
45 changes: 40 additions & 5 deletions src/chai/chai-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,44 @@
# SPDX-License-Identifier: BSD-3-Clause
##############################################################################

set (CHAI_INSTALL_PREFIX @CMAKE_INSTALL_PREFIX@)
set (CHAI_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include)
set (CHAI_LIB_DIR @CMAKE_INSTALL_PREFIX@/lib)
set (CHAI_CMAKE_DIR @CMAKE_INSTALL_PREFIX@/share/chai/cmake)
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

include(@CMAKE_INSTALL_PREFIX@/share/chai/cmake/chai-targets.cmake)
if (@CHAI_NEEDS_BLT_TPLS@)
include("${CMAKE_CURRENT_LIST_DIR}/chai-blt-targets.cmake")

if (@CHAI_ENABLE_CUDA@)
find_dependency(Threads)
endif ()
endif()

if (NOT TARGET umpire)
set(CHAI_UMPIRE_DIR "@umpire_DIR@")
if(NOT umpire_DIR)
set(umpire_DIR ${CHAI_UMPIRE_DIR})
endif()

find_dependency(umpire CONFIG NO_DEFAULT_PATH PATHS
${umpire_DIR}
${umpire_DIR}/lib/cmake/umpire
@PACKAGE_CMAKE_INSTALL_PREFIX@
@PACKAGE_CMAKE_INSTALL_PREFIX@/lib/cmake/umpire)
endif ()

if (NOT TARGET RAJA)
set(CHAI_RAJA_DIR "@RAJA_DIR@")
if(NOT RAJA_DIR)
set(RAJA_DIR ${CHAI_UMPIRE_DIR})
endif()

find_dependency(RAJA CONFIG NO_DEFAULT_PATH PATHS
${RAJA_DIR}
${RAJA_DIR}/lib/cmake/raja
@PACKAGE_CMAKE_INSTALL_PREFIX@
@PACKAGE_CMAKE_INSTALL_PREFIX@/lib/cmake/raja)
endif ()

include("${CMAKE_CURRENT_LIST_DIR}/chai-targets.cmake")

check_required_components(@PROJECT_NAME@)