diff options
author | Brad King <brad.king@kitware.com> | 2021-05-28 16:21:45 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-05-28 16:22:31 (GMT) |
commit | 8f9fa818dcfa8eadf896e1acf6b16e17e82a60fa (patch) | |
tree | 1cef3da4df0e2c6f8ddc17f13c6fe8e02a8b7a3f /Modules | |
parent | c19fdf69fa466538a49fcefd2dedd3ebdb6055f0 (diff) | |
parent | e609afeb5f4385755a6d0f2fdb45fcdfb0a01b7a (diff) | |
download | CMake-8f9fa818dcfa8eadf896e1acf6b16e17e82a60fa.zip CMake-8f9fa818dcfa8eadf896e1acf6b16e17e82a60fa.tar.gz CMake-8f9fa818dcfa8eadf896e1acf6b16e17e82a60fa.tar.bz2 |
Merge topic 'WriteBasicConfigVersion_support_leading_zeroes'
e609afeb5f WriteBasicConfigVersion supports version strings such as 21.07.04
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6167
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/BasicConfigVersion-ExactVersion.cmake.in | 37 | ||||
-rw-r--r-- | Modules/BasicConfigVersion-SameMajorVersion.cmake.in | 3 | ||||
-rw-r--r-- | Modules/BasicConfigVersion-SameMinorVersion.cmake.in | 14 |
3 files changed, 50 insertions, 4 deletions
diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in index 3507a22..c8d2695 100644 --- a/Modules/BasicConfigVersion-ExactVersion.cmake.in +++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in @@ -18,14 +18,43 @@ endif() set(PACKAGE_VERSION "@CVF_VERSION@") -if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version - set(CVF_VERSION_NO_TWEAK "${CMAKE_MATCH_1}") +if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}") + set(CVF_VERSION_PATCH "${CMAKE_MATCH_3}") + + if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}") + endif() + if(NOT CVF_VERSION_MINOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" CVF_VERSION_MINOR "${CVF_VERSION_MINOR}") + endif() + if(NOT CVF_VERSION_PATCH VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" CVF_VERSION_PATCH "${CVF_VERSION_PATCH}") + endif() + + set(CVF_VERSION_NO_TWEAK "${CVF_VERSION_MAJOR}.${CVF_VERSION_MINOR}.${CVF_VERSION_PATCH}") else() set(CVF_VERSION_NO_TWEAK "@CVF_VERSION@") endif() -if(PACKAGE_FIND_VERSION MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version - set(REQUESTED_VERSION_NO_TWEAK "${CMAKE_MATCH_1}") +if(PACKAGE_FIND_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version + set(REQUESTED_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(REQUESTED_VERSION_MINOR "${CMAKE_MATCH_2}") + set(REQUESTED_VERSION_PATCH "${CMAKE_MATCH_3}") + + if(NOT REQUESTED_VERSION_MAJOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MAJOR "${REQUESTED_VERSION_MAJOR}") + endif() + if(NOT REQUESTED_VERSION_MINOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MINOR "${REQUESTED_VERSION_MINOR}") + endif() + if(NOT REQUESTED_VERSION_PATCH VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_PATCH "${REQUESTED_VERSION_PATCH}") + endif() + + set(REQUESTED_VERSION_NO_TWEAK + "${REQUESTED_VERSION_MAJOR}.${REQUESTED_VERSION_MINOR}.${REQUESTED_VERSION_PATCH}") else() set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}") endif() diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index dc04e54..cf73f60 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -17,6 +17,9 @@ else() if("@CVF_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 "@CVF_VERSION@") endif() diff --git a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in index 9bb2efc..ef21df6 100644 --- a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in @@ -19,6 +19,13 @@ else() if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.([0-9]+)") set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}") + + if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}") + endif() + if(NOT CVF_VERSION_MINOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" CVF_VERSION_MINOR "${CVF_VERSION_MINOR}") + endif() else() set(CVF_VERSION_MAJOR "@CVF_VERSION@") set(CVF_VERSION_MINOR "") @@ -44,6 +51,13 @@ else() set(PACKAGE_VERSION_COMPATIBLE FALSE) endif() else() + if(NOT PACKAGE_FIND_VERSION_MAJOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" PACKAGE_FIND_VERSION_MAJOR "${PACKAGE_FIND_VERSION_MAJOR}") + endif() + if(NOT PACKAGE_FIND_VERSION_MINOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" PACKAGE_FIND_VERSION_MINOR "${PACKAGE_FIND_VERSION_MINOR}") + endif() + if((PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) AND (PACKAGE_FIND_VERSION_MINOR STREQUAL CVF_VERSION_MINOR)) set(PACKAGE_VERSION_COMPATIBLE TRUE) |