From 879335cebfa5a5c79f2d3bb987e565f25b14aee9 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 26 Apr 2020 14:37:54 +0300 Subject: [PATCH 1/2] CMakeLists: add VERSION to project() and package So the library consumers via find_package(Microsoft.GSL 3.0.2) could determine the actual library version. --- CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a12c33..66b09e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1.3...3.16) -project(GSL CXX) +project(GSL VERSION 3.0.2 LANGUAGES CXX) include(ExternalProject) find_package(Git) @@ -92,6 +92,18 @@ install( install(EXPORT Microsoft.GSLConfig NAMESPACE Microsoft.GSL:: DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL) export(TARGETS GSL NAMESPACE Microsoft.GSL:: FILE Microsoft.GSLConfig.cmake) +# Add find_package() versioning support. The version for +# generated Microsoft.GSLConfigVersion.cmake will be used from +# last project() command. The version's compatibility is set between all +# minor versions (as it was in prev. GSL releases). +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake + COMPATIBILITY SameMajorVersion + ARCH_INDEPENDENT +) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL) + # Add Microsoft.GSL::GSL alias for GSL so that dependents can be agnostic about # whether GSL was added via `add_subdirectory` or `find_package` add_library(Microsoft.GSL::GSL ALIAS GSL) From de053645bb8a47cc4cbb8c1b2e47a33d5f5ef18d Mon Sep 17 00:00:00 2001 From: leha-bot Date: Tue, 28 Apr 2020 13:07:41 +0300 Subject: [PATCH 2/2] CMakeLists: Drop ARCH_INDEPENDENT as it does not supported via old CMake --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66b09e0..0cf66f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,6 @@ include(CMakePackageConfigHelpers) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake COMPATIBILITY SameMajorVersion - ARCH_INDEPENDENT ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL)