-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup CMake config for genten to be packaged and found by external pr…
…ojects
- Loading branch information
Showing
6 changed files
with
151 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
############################################################################### | ||
# export everything for a cmake build to be able to import with find_package | ||
############################################################################### | ||
|
||
if (NOT DEFINED GENTEN_INSTALL_INCLUDE_DIR) | ||
set(GENTEN_INSTALL_INCLUDE_DIR "include") | ||
endif() | ||
|
||
if (NOT DEFINED GENTEN_INSTALL_CONFIG_DIR) | ||
set(GENTEN_INSTALL_CONFIG_DIR "lib64") | ||
endif() | ||
|
||
if (NOT DEFINED GENTEN_INSTALL_LIB_DIR) | ||
set(GENTEN_INSTALL_LIB_DIR "lib64") | ||
endif() | ||
|
||
if (NOT DEFINED GENTEN_INSTALL_BIN_DIR) | ||
set(GENTEN_INSTALL_BIN_DIR "bin") | ||
endif() | ||
|
||
if (NOT DEFINED GENTEN_INSTALL_CMAKE_MODULE_DIR) | ||
if(WIN32) | ||
set(GENTEN_INSTALL_CMAKE_MODULE_DIR "cmake") | ||
else() | ||
set(GENTEN_INSTALL_CMAKE_MODULE_DIR "${GENTEN_INSTALL_CONFIG_DIR}/cmake/Genten") | ||
endif() | ||
endif() | ||
|
||
include(CMakePackageConfigHelpers) | ||
# write version heler | ||
write_basic_package_version_file( | ||
${CMAKE_CURRENT_BINARY_DIR}/GentenConfigVersion.cmake | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
# write cmake package config file | ||
configure_package_config_file( | ||
GentenConfig.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/GentenConfig.cmake | ||
INSTALL_DESTINATION ${GENTEN_INSTALL_CMAKE_MODULE_DIR} | ||
PATH_VARS | ||
GENTEN_INSTALL_INCLUDE_DIR | ||
GENTEN_INSTALL_LIB_DIR | ||
GENTEN_INSTALL_BIN_DIR | ||
GENTEN_INSTALL_CMAKE_MODULE_DIR | ||
) | ||
|
||
# install everything needed | ||
install(FILES | ||
${CMAKE_CURRENT_BINARY_DIR}/GentenConfig.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/GentenConfigVersion.cmake | ||
genten_setup_deps.cmake | ||
genten_setup_targets.cmake | ||
DESTINATION ${GENTEN_INSTALL_CMAKE_MODULE_DIR}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
############################################################################### | ||
# Note: | ||
# This file is named XxxConfig.cmake because once upon a time | ||
# when it was named xxx-config.cmake, we found that CMake's exported | ||
# targets script includes all "xxx*.cmake" files. This logic would | ||
# cause this script to be included more than once, seeding instability | ||
# that caused great harm to the kingdom. | ||
############################################################################### | ||
|
||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR) | ||
|
||
@PACKAGE_INIT@ | ||
|
||
|
||
if(NOT GENTEN_FOUND) | ||
|
||
set(GENTEN_VERSION "@PROJECT_VERSION@") | ||
set(GENTEN_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") | ||
|
||
set(GENTEN_KOKKOS_DIR "@KOKKOS_PATH@") | ||
|
||
# advertise if mfem support is enabled | ||
set(GENTEN_LAPACK_FOUND @LAPACK_FOUND@) | ||
set(GENTEN_LAPACK_LIBS "@LAPACK_LIBS@") | ||
|
||
# pull in vars with details about configured paths | ||
get_filename_component(GENTEN_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) | ||
|
||
# setup dependent pkgs (i.e., kokkos) | ||
include(${GENTEN_CMAKE_CONFIG_DIR}/genten_setup_deps.cmake) | ||
|
||
# include the main exported targets | ||
include("${GENTEN_CMAKE_CONFIG_DIR}/genten.cmake") | ||
|
||
# finish setup | ||
include("${GENTEN_CMAKE_CONFIG_DIR}/genten_setup_targets.cmake") | ||
|
||
set(GENTEN_FOUND TRUE) | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
if(GENTEN_KOKKOS_DIR) | ||
if(NOT EXISTS ${GENTEN_KOKKOS_DIR}/lib64/cmake/Kokkos/KokkosConfig.cmake) | ||
MESSAGE(FATAL_ERROR "Could not find kokkos CMake include file (${GENTEN_KOKKOS_DIR}/lib64/cmake/Kokkos/KokkosConfig.cmake)") | ||
endif() | ||
|
||
############################################################################### | ||
# Import Kokkos CMake targets | ||
############################################################################### | ||
find_package(Kokkos REQUIRED | ||
NO_DEFAULT_PATH | ||
PATHS ${GENTEN_KOKKOS_DIR}/lib64/cmake/Kokkos) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
set(GENTEN_INCLUDE_DIRS "${GENTEN_INSTALL_PREFIX}/include/genten") | ||
|
||
add_library(genten::genten INTERFACE IMPORTED) | ||
|
||
set_property(TARGET genten::genten | ||
APPEND PROPERTY | ||
INTERFACE_INCLUDE_DIRECTORIES "${GENTEN_INSTALL_PREFIX}/include/") | ||
|
||
set_property(TARGET genten::genten | ||
APPEND PROPERTY | ||
INTERFACE_INCLUDE_DIRECTORIES "${GENTEN_INSTALL_PREFIX}/include/genten/") | ||
|
||
set_property(TARGET genten::genten | ||
PROPERTY INTERFACE_LINK_LIBRARIES | ||
genten_mathlibs_c gentenlib gt_higher_moments) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,30 @@ | ||
#--https://stackoverflow.com/questions/49857596/cmake-simple-config-file-example/49858236 | ||
#--https://stackoverflow.com/questions/20746936/what-use-is-find-package-if-you-need-to-specify-cmake-module-path-anyway | ||
set(joint_moment_headers Genten_HigherMoments.hpp) | ||
|
||
ADD_LIBRARY ( | ||
gt_higher_moments SHARED | ||
${Genten_SOURCE_DIR}/joint_moments/Genten_HigherMoments.cpp | ||
) | ||
TARGET_LINK_LIBRARIES(gt_higher_moments PUBLIC ${GENTEN_LINK_LIBS}) | ||
|
||
|
||
INSTALL( | ||
TARGETS genten_mathlibs_c gentenlib gt_higher_moments | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
EXPORT gt_higher_momentsConfig | ||
INSTALL ( | ||
FILES ${joint_moment_headers} | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/genten | ||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ | ||
) | ||
|
||
INSTALL( | ||
EXPORT gt_higher_momentsConfig | ||
DESTINATION cmake | ||
TARGETS gt_higher_moments | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
EXPORT genten | ||
) | ||
|
||
#HK3 | ||
#HK3EXPORT( | ||
#HK3 EXPORT gt_higher_momentsConfig | ||
#HK3 NAMESPACE gt_higher_moments:: | ||
#HK3 FILE gt_higher_momentsConfig.cmake | ||
#HK3 ) | ||
#HK3 | ||
#HK3EXPORT( PACKAGE gt_higher_moments) | ||
|
||
#HKINSTALL ( | ||
#HK TARGETS gt_higher_moments | ||
#HK DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
#HK ) | ||
#HK | ||
#HKinclude(CMakePackageConfigHelpers) | ||
#HKconfigure_package_config_file(gt_higher_momentsConfig.cmake.in | ||
#HK ${CMAKE_CURRENT_BINARY_DIR}/gt_higher_momentsConfig.cmake | ||
#HK INSTALL_DESTINATION cmake) | ||
#HK | ||
#HKINSTALL( | ||
#HK FILES | ||
#HK ${CMAKE_CURRENT_BINARY_DIR}/gt_higher_momentsConfig.cmake | ||
#HK DESTINATION cmake | ||
#HK ) | ||
|
||
|
||
# the configure files will be installed by the config/cmake files | ||
# | ||
#INSTALL( | ||
# EXPORT gt_higher_momentsConfig | ||
# DESTINATION cmake | ||
# ) | ||
# |