The branch, master has been updated via 9db9f48 cmake: Print a message that uid_wrapper was found with find_package() via bcda60d cmake: Improve version detection to support ranges from 0e55550 Bump version to 1.3.0
https://git.samba.org/?p=uid_wrapper.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 9db9f48cfff026f11c6882811d205c2a16589517 Author: Andreas Schneider <a...@samba.org> Date: Tue Jan 24 11:03:43 2023 +0100 cmake: Print a message that uid_wrapper was found with find_package() Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit bcda60d404ab0c9fc7a5bf8f5e5fd81cef8d6862 Author: Andreas Schneider <a...@samba.org> Date: Tue Jan 24 11:03:18 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 | 2 ++ uid_wrapper-config-version.cmake.in | 41 +++++++++++++++++++++++++++++++------ uid_wrapper-config.cmake.in | 15 +++++++++++++- 3 files changed, 51 insertions(+), 7 deletions(-) Changeset truncated at 500 lines: diff --git a/CMakeLists.txt b/CMakeLists.txt index c11220a..1523bd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,8 @@ install( ) # cmake config files +set(PACKAGE_NAME "uid_wrapper") +set(PACKAGE_NAME_UPPER "UID_WRAPPER") configure_file(uid_wrapper-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config-version.cmake @ONLY) configure_file(uid_wrapper-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/uid_wrapper-config.cmake @ONLY) install( diff --git a/uid_wrapper-config-version.cmake.in b/uid_wrapper-config-version.cmake.in index 4bff45e..c59f6c8 100644 --- a/uid_wrapper-config-version.cmake.in +++ b/uid_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/uid_wrapper-config.cmake.in b/uid_wrapper-config.cmake.in index 43ab1fa..4e77dd6 100644 --- a/uid_wrapper-config.cmake.in +++ b/uid_wrapper-config.cmake.in @@ -1 +1,14 @@ -set(UID_WRAPPER_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@UID_WRAPPER_LIB@) +set(@PACKAGE_NAME_UPPER@_LIBRARY @CMAKE_INSTALL_FULL_LIBDIR@/@UID_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}]") -- UID Wrapper Repository