The branch, master has been updated via 4b1e6b8 cmake: Print a message that nss_wrapper was found with find_package() via adce22a cmake: Improve version detection to support ranges from b33232f tests: Add test_initgroups
https://git.samba.org/?p=nss_wrapper.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 4b1e6b840cc8c8fbbf3e5e50ca8449941deb4e13 Author: Andreas Schneider <a...@samba.org> Date: Wed Jan 25 11:20:51 2023 +0100 cmake: Print a message that nss_wrapper was found with find_package() Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit adce22a356e47c81a7e583ea48040dbba2c534a0 Author: Andreas Schneider <a...@samba.org> Date: Wed Jan 25 11:20:45 2023 +0100 cmake: Improve version detection to support ranges Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> ----------------------------------------------------------------------- Summary of changes: CMakeLists.txt | 3 +++ nss_wrapper-config-version.cmake.in | 41 +++++++++++++++++++++++++++++++------ nss_wrapper-config.cmake.in | 15 +++++++++++++- 3 files changed, 52 insertions(+), 7 deletions(-) Changeset truncated at 500 lines: diff --git a/CMakeLists.txt b/CMakeLists.txt index 163fa10..3ba3822 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,9 @@ install( ) # cmake config files +set(PACKAGE_NAME nss_wrapper) +set(PACKAGE_NAME_UPPER NSS_WRAPPER) + configure_file(nss_wrapper-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config-version.cmake @ONLY) configure_file(nss_wrapper-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config.cmake @ONLY) install( diff --git a/nss_wrapper-config-version.cmake.in b/nss_wrapper-config-version.cmake.in index 4bff45e..c59f6c8 100644 --- a/nss_wrapper-config-version.cmake.in +++ b/nss_wrapper-config-version.cmake.in @@ -1,11 +1,40 @@ set(PACKAGE_VERSION @PROJECT_VERSION@) -# Check whether the requested PACKAGE_FIND_VERSION is compatible -if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_COMPATIBLE FALSE) +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) + if(${PACKAGE_VERSION} MATCHES "^([0-9]+)\\.") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}") endif() + else() + set(CVF_VERSION_MAJOR ${PACKAGE_VERSION}) + endif() + + if(PACKAGE_FIND_VERSION_RANGE) + # both endpoints of the range must have the expected major version + math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1") + if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + else() + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() endif() diff --git a/nss_wrapper-config.cmake.in b/nss_wrapper-config.cmake.in index 9375f5c..ba5711b 100644 --- a/nss_wrapper-config.cmake.in +++ b/nss_wrapper-config.cmake.in @@ -1 +1,14 @@ -set(NSS_WRAPPER_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@NSS_WRAPPER_LIB@) +set(@PACKAGE_NAME_UPPER@_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@NSS_WRAPPER_LIB@) + +# Load information for each installed configuration. +file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_NAME@-config-*.cmake") +foreach(_cmake_config_file IN LISTS _cmake_config_files) + include("${_cmake_config_file}") +endforeach() +unset(_cmake_config_files) +unset(_cmake_config_file) + +include(FindPackageMessage) +find_package_message(@PACKAGE_NAME@ + "Found @PACKAGE_NAME@: ${@PACKAGE_NAME_UPPER@_LIBRARY} (version \"${PACKAGE_VERSION}\")" + "[${@PACKAGE_NAME_UPPER@_LIBRARY}][${PACKAGE_VERSION}]") -- NSS Wrapper Repository