Skip to content

Commit cc1fa16

Browse files
committed
CMake: Extract major.minor.patch in VERSION argument
LLVM has a strict compatibility check in the CMake packages they provide. Therefore, we cannot pass a non-conformant version string, such as `21.0.0git`, to the `find_package()` call for Clang or LLVM. A recent change modified the FindWrapLibclang.cmake script such that developer builds would strip out the `git` suffix. Of course, release candidates have other suffixes, so dropping `git` is too narrow. A more robust solution is to extract the major.minor.patch version, i.e. turning both of `21.1.0-rc3` and `21.1.0git` into `21.1.0`. The function that does the work is renamed to better reflect its purpose, and all three call-sites are updated. The change is cherry-picked to the branches that were targeted by the parent change. This change amends 39f0f48. Task-number: QTBUG-139407 Pick-to: 6.10 6.9 6.8 Change-Id: I06409a394c5f994f88d516efd5d9e03de06cb468 Reviewed-by: Topi Reiniö <[email protected]>
1 parent 39f0f48 commit cc1fa16

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cmake/FindWrapLibClang.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ endif()
1717
include(FindPackageHandleStandardArgs)
1818
set(WrapLibClang_FOUND FALSE)
1919

20-
# Strip a possible trailing `git` from the version string for developer builds.
21-
function(strip_git_from_version IN OUT)
20+
# Extract major.minor.patch version from version string for developer builds.
21+
function(normalize_version_for_dev_build IN OUT)
2222
if(QT_FEATURE_developer_build)
23-
string(REGEX REPLACE "git$" "" _clean "${${IN}}")
23+
string(REGEX MATCH "^([0-9]+\\.[0-9]+\\.[0-9]+)" _clean "${${IN}}")
2424
if(_clean STREQUAL "")
2525
set(_clean "${${IN}}")
2626
endif()
@@ -46,7 +46,7 @@ if(QT_NO_FIND_PACKAGE_CLANG_WORKAROUND)
4646
set(Clang_FOUND FALSE)
4747
foreach(VERSION ${QDOC_SUPPORTED_CLANG_VERSIONS})
4848
if(NOT Clang_FOUND)
49-
strip_git_from_version(VERSION VERSION_CLEAN)
49+
normalize_version_for_dev_build(VERSION VERSION_CLEAN)
5050
find_package(Clang ${VERSION_CLEAN} CONFIG QUIET)
5151
endif()
5252
endforeach()
@@ -62,7 +62,7 @@ else()
6262
set(LLVM_FOUND FALSE)
6363
foreach(VERSION ${QDOC_SUPPORTED_CLANG_VERSIONS})
6464
if(NOT LLVM_FOUND)
65-
strip_git_from_version(VERSION VERSION_CLEAN)
65+
normalize_version_for_dev_build(VERSION VERSION_CLEAN)
6666
find_package(LLVM ${VERSION_CLEAN} CONFIG QUIET)
6767
endif()
6868
endforeach()
@@ -96,7 +96,7 @@ else()
9696
unset(__qt_wraplibclang CACHE)
9797

9898
# Now, we're pretty certain that we can find the 'Clang' package without running into errors.
99-
strip_git_from_version(LLVM_VERSION LLVM_VERSION_CLEAN)
99+
normalize_version_for_dev_build(LLVM_VERSION LLVM_VERSION_CLEAN)
100100
find_package(Clang ${LLVM_VERSION_CLEAN} EXACT CONFIG)
101101
endif()
102102

0 commit comments

Comments
 (0)