Commit 584e0c3dd3eb5ac0631b0840c3852ea274960862
Committed by
GitHub
1 parent
05ca8e1c
Fixed installation on other than Ubuntu GNU/Linux distributions. (#226)
Fixes the installation paths by using cmake variables.
Showing
1 changed file
with
4 additions
and
3 deletions
CMakeLists.txt
| @@ -73,8 +73,9 @@ target_include_directories(cxxopts INTERFACE | @@ -73,8 +73,9 @@ target_include_directories(cxxopts INTERFACE | ||
| 73 | ) | 73 | ) |
| 74 | 74 | ||
| 75 | if(CXXOPTS_ENABLE_INSTALL) | 75 | if(CXXOPTS_ENABLE_INSTALL) |
| 76 | + include(GNUInstallDirs) | ||
| 76 | include(CMakePackageConfigHelpers) | 77 | include(CMakePackageConfigHelpers) |
| 77 | - set(CXXOPTS_CMAKE_DIR "lib/cmake/cxxopts" CACHE STRING | 78 | + set(CXXOPTS_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/cxxopts" CACHE STRING |
| 78 | "Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.") | 79 | "Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.") |
| 79 | set(version_config "${PROJECT_BINARY_DIR}/cxxopts-config-version.cmake") | 80 | set(version_config "${PROJECT_BINARY_DIR}/cxxopts-config-version.cmake") |
| 80 | set(project_config "${PROJECT_BINARY_DIR}/cxxopts-config.cmake") | 81 | set(project_config "${PROJECT_BINARY_DIR}/cxxopts-config.cmake") |
| @@ -100,8 +101,8 @@ if(CXXOPTS_ENABLE_INSTALL) | @@ -100,8 +101,8 @@ if(CXXOPTS_ENABLE_INSTALL) | ||
| 100 | NAMESPACE cxxopts::) | 101 | NAMESPACE cxxopts::) |
| 101 | 102 | ||
| 102 | # Install the header file and export the target | 103 | # Install the header file and export the target |
| 103 | - install(TARGETS cxxopts EXPORT ${targets_export_name} DESTINATION lib) | ||
| 104 | - install(FILES ${PROJECT_SOURCE_DIR}/include/cxxopts.hpp DESTINATION include) | 104 | + install(TARGETS cxxopts EXPORT ${targets_export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 105 | + install(FILES ${PROJECT_SOURCE_DIR}/include/cxxopts.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
| 105 | endif() | 106 | endif() |
| 106 | 107 | ||
| 107 | add_subdirectory(src) | 108 | add_subdirectory(src) |