From 0f6f0af4b42480ad5e0e4c033e5c37659842c252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Ospina=20De=20Los=20R=C3=ADos?= Date: Mon, 8 Feb 2021 21:49:36 +0100 Subject: [PATCH] Fix config installation (#93) * Export and install targets and config file * Add alias * Fix install dir * Install config file * Switch to a searchable path --- CMakeLists.txt | 13 +++++++++++-- cmake/config.cmake.in | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52c1e2f..54742e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,15 @@ if(GHC_FILESYSTEM_WITH_INSTALL) include(CMakePackageConfigHelpers) include(GNUInstallDirs) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - install(TARGETS ghc_filesystem EXPORT ghcFilesystemConfig) - install(EXPORT ghcFilesystemConfig NAMESPACE ghcFilesystem:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ghcFilesystem) + install(TARGETS ghc_filesystem EXPORT ghc_filesystem-targets) + install(EXPORT ghc_filesystem-targets NAMESPACE ghcFilesystem:: DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ghc_filesystem") + export(EXPORT ghc_filesystem-targets NAMESPACE ghcFilesystem:: FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/ghc_filesystem-targets.cmake") + configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in" + "${PROJECT_BINARY_DIR}/cmake/ghc_filesystem-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ghc_filesystem" + PATH_VARS CMAKE_INSTALL_INCLUDEDIR) + install(FILES "${PROJECT_BINARY_DIR}/cmake/ghc_filesystem-config.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ghc_filesystem") + add_library(ghcFilesystem::ghc_filesystem ALIAS ghc_filesystem) endif() diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in index 3d25f9f..ace9761 100644 --- a/cmake/config.cmake.in +++ b/cmake/config.cmake.in @@ -1,5 +1,6 @@ @PACKAGE_INIT@ -set_and_check(ghcfilesystem_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@") +# import targets +include("${CMAKE_CURRENT_LIST_DIR}/ghc_filesystem-targets.cmake") -check_required_components(ghcfilesystem) +check_required_components(ghcfilesystem) \ No newline at end of file