Skip to content

Commit f61c47e

Browse files
paulwickingQt Cherry-pick Bot
authored andcommitted
CMake: Drop 'git' in VERSION argument for dev builds
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. QDoc carries a fork of `clang/AST/QualTypeNames` due to upstream changes between LLVM 15 and LLVM 16 that were deemed incompatible with QDoc's needs. As this class sees upstream modifications that break compilation, there's a need to bisect LLVM to track down the offending upstream change, so that QDoc's implementation can be modified to work correctly alongside newer versions of LLVM. These builds contain version strings that contain 'git' as a suffix, and thus break the developer experience in qttools.git. To mitigate this problem, this change strips the suffix by a simple regular expression based string replacement. The new behavior is gated with `QT_FEATURE_developer_build` (the feature flag defined by a `-developer-build` configuration of qtbase.git). The rationale is that, as this is strictly speaking a convenience for me, myself, and I, it should not be the default behavior of the CMake script, and if run in an environment that's a developer build, it's reasonable to expect that the developer responsible for configuring qttools.git is able to find and understand why this happens. This change extends the logic implemented in 914e00b and is, as such, cherry-picked as far back as to the branches that change targeted. Task-number: QTBUG-139407 Pick-to: 6.9 6.8 Change-Id: Id5dea0678037cc5f86343b7aa0421b27c6ad13c0 Reviewed-by: Topi Reiniö <[email protected]> Reviewed-by: David Boddie <[email protected]> (cherry picked from commit 39f0f48) Reviewed-by: Qt Cherry-pick Bot <[email protected]>
1 parent c0cac4b commit f61c47e

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

cmake/FindWrapLibClang.cmake

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ 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)
22+
if(QT_FEATURE_developer_build)
23+
string(REGEX REPLACE "git$" "" _clean "${${IN}}")
24+
if(_clean STREQUAL "")
25+
set(_clean "${${IN}}")
26+
endif()
27+
set(${OUT} "${_clean}" PARENT_SCOPE)
28+
else()
29+
set(${OUT} "${${IN}}" PARENT_SCOPE)
30+
endif()
31+
endfunction()
32+
2033
# Find the zstd package before llvm gets a chance to plant its Findzstd.cmake on us. That find
2134
# module is most likely inconsistent with your system-provided llvmConfig.cmake, leading to
2235
# configuration errors. Disable find_package(zstd) within llvm if FindWrapZSTD.cmake was successful.
@@ -33,7 +46,8 @@ if(QT_NO_FIND_PACKAGE_CLANG_WORKAROUND)
3346
set(Clang_FOUND FALSE)
3447
foreach(VERSION ${QDOC_SUPPORTED_CLANG_VERSIONS})
3548
if(NOT Clang_FOUND)
36-
find_package(Clang ${VERSION} CONFIG QUIET)
49+
strip_git_from_version(VERSION VERSION_CLEAN)
50+
find_package(Clang ${VERSION_CLEAN} CONFIG QUIET)
3751
endif()
3852
endforeach()
3953
else()
@@ -48,7 +62,8 @@ else()
4862
set(LLVM_FOUND FALSE)
4963
foreach(VERSION ${QDOC_SUPPORTED_CLANG_VERSIONS})
5064
if(NOT LLVM_FOUND)
51-
find_package(LLVM ${VERSION} CONFIG QUIET)
65+
strip_git_from_version(VERSION VERSION_CLEAN)
66+
find_package(LLVM ${VERSION_CLEAN} CONFIG QUIET)
5267
endif()
5368
endforeach()
5469
if(NOT LLVM_FOUND)
@@ -81,7 +96,8 @@ else()
8196
unset(__qt_wraplibclang CACHE)
8297

8398
# Now, we're pretty certain that we can find the 'Clang' package without running into errors.
84-
find_package(Clang ${LLVM_VERSION} EXACT CONFIG)
99+
strip_git_from_version(LLVM_VERSION LLVM_VERSION_CLEAN)
100+
find_package(Clang ${LLVM_VERSION_CLEAN} EXACT CONFIG)
85101
endif()
86102

87103
if(QT_FEATURE_zstd)

0 commit comments

Comments
 (0)