mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
c52bad36aa
- Move all install logic inside gsl_install.cmake - This makes reading the logic easier, and avoids the enable language issue with `GNUInstallDirs` by having it included after the project call - Have all functions inside gsl_functions.cmake - Use CMake idiom PROJECT_IS_TOP_LEVEL - Update README.md
27 lines
1.1 KiB
CMake
27 lines
1.1 KiB
CMake
include(GNUInstallDirs)
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
# Install header files
|
|
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/gsl" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
set(export_name "Microsoft.GSLConfig")
|
|
set(namespace "Microsoft.GSL::")
|
|
set(cmake_files_install_dir ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL)
|
|
|
|
# Add find_package() support
|
|
target_include_directories(GSL INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
install(TARGETS GSL EXPORT ${export_name})
|
|
install(EXPORT ${export_name} NAMESPACE ${namespace} DESTINATION ${cmake_files_install_dir})
|
|
export(TARGETS GSL NAMESPACE ${namespace} FILE ${export_name}.cmake)
|
|
|
|
set(gls_config_version "${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake")
|
|
|
|
# Add find_package() versioning support
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
|
|
write_basic_package_version_file(${gls_config_version} COMPATIBILITY SameMajorVersion)
|
|
else()
|
|
write_basic_package_version_file(${gls_config_version} COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT)
|
|
endif()
|
|
|
|
install(FILES ${gls_config_version} DESTINATION ${cmake_files_install_dir})
|