From d5896fec1909710ffcbb4fa5752349be13adff9e Mon Sep 17 00:00:00 2001 From: Peter Brady Date: Fri, 13 Oct 2023 11:23:51 -0500 Subject: [PATCH] Use `GNUInstallDirs` to fix installation problems on mac --- CMakeLists.txt | 3 +++ cmake/parthenonConfig.cmake.in | 10 ++++++++++ src/CMakeLists.txt | 8 +++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33c19c34256d7..7f9dc79723aaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,6 +353,9 @@ if (PARTHENON_ENABLE_ASCENT) find_package(Ascent REQUIRED NO_DEFAULT_PATH) endif() +# Installation configuration +include(GNUInstallDirs) + add_subdirectory(src) add_subdirectory(example) add_subdirectory(benchmarks) diff --git a/cmake/parthenonConfig.cmake.in b/cmake/parthenonConfig.cmake.in index aaed3e28971d6..e70d251505bf8 100644 --- a/cmake/parthenonConfig.cmake.in +++ b/cmake/parthenonConfig.cmake.in @@ -11,6 +11,14 @@ # the public, perform publicly and display publicly, and to permit others to do so. #========================================================================================= +if(NOT PARTHENON_CMAKE) + cmake_path(SET PARTHENON_CMAKE_BASE_DIR NORMALIZE "${CMAKE_CURRENT_LIST_DIR}/..") + message(STATUS "Appending parthenon cmake module directory: " ${PARTHENON_CMAKE_BASE_DIR}) + list(APPEND CMAKE_MODULE_PATH ${PARTHENON_CMAKE_BASE_DIR}) + set(PARTHENON_CMAKE TRUE) +endif() + + # Favor using the kokkos package that was built with parthenon, if one has not been specified if (@PARTHENON_IMPORT_KOKKOS@) find_package(Kokkos 3 REQUIRED PATHS @Kokkos_DIR@ NO_DEFAULT_PATH) @@ -37,4 +45,6 @@ if(@OpenMP_FOUND@) find_package(OpenMP REQUIRED COMPONENTS CXX) endif() +find_package(Filesystem REQUIRED COMPONENTS Experimental Final) + include("${CMAKE_CURRENT_LIST_DIR}/parthenonTargets.cmake") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54a226c553831..f7067e9238d17 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -328,11 +328,7 @@ target_include_directories(parthenon PUBLIC $ ) -install(TARGETS parthenon EXPORT parthenonTargets - INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/parthenon" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +install(TARGETS parthenon EXPORT parthenonTargets) # Maintain directory structure in installed include files install(DIRECTORY . DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/parthenon" FILES_MATCHING PATTERN "*.hpp") @@ -343,6 +339,8 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/config.hpp install(FILES ${PROJECT_BINARY_DIR}/cmake/parthenonConfig.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/parthenon") +install(FILES ${PROJECT_SOURCE_DIR}/cmake/FindFilesystem.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake") + install(EXPORT parthenonTargets FILE parthenonTargets.cmake NAMESPACE Parthenon::