diff --git a/CMakeLists.txt b/CMakeLists.txt index 52e844b1..27ba61ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/cmake/thirdparty/SetupChaiThirdparty.cmake b/cmake/thirdparty/SetupChaiThirdparty.cmake index d0be864a..29a95124 100644 --- a/cmake/thirdparty/SetupChaiThirdparty.cmake +++ b/cmake/thirdparty/SetupChaiThirdparty.cmake @@ -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() \ No newline at end of file diff --git a/src/chai/CMakeLists.txt b/src/chai/CMakeLists.txt index 27520b68..3cf9a093 100644 --- a/src/chai/CMakeLists.txt +++ b/src/chai/CMakeLists.txt @@ -81,13 +81,16 @@ target_include_directories( $ $) -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 diff --git a/src/chai/chai-config.cmake.in b/src/chai/chai-config.cmake.in index 4fc7af6a..862817d3 100644 --- a/src/chai/chai-config.cmake.in +++ b/src/chai/chai-config.cmake.in @@ -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@)