Skip to content

Commit 659d915

Browse files
committed
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.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]> (cherry picked from commit f61c47e) Reviewed-by: Paul Wicking <[email protected]>
1 parent d0f1a2e commit 659d915

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,11 +17,25 @@ 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
if(QT_NO_FIND_PACKAGE_CLANG_WORKAROUND)
2134
set(Clang_FOUND FALSE)
2235
foreach(VERSION ${QDOC_SUPPORTED_CLANG_VERSIONS})
2336
if(NOT Clang_FOUND)
24-
find_package(Clang ${VERSION} CONFIG QUIET)
37+
strip_git_from_version(VERSION VERSION_CLEAN)
38+
find_package(Clang ${VERSION_CLEAN} CONFIG QUIET)
2539
endif()
2640
endforeach()
2741
else()
@@ -36,7 +50,8 @@ else()
3650
set(LLVM_FOUND FALSE)
3751
foreach(VERSION ${QDOC_SUPPORTED_CLANG_VERSIONS})
3852
if(NOT LLVM_FOUND)
39-
find_package(LLVM ${VERSION} CONFIG QUIET)
53+
strip_git_from_version(VERSION VERSION_CLEAN)
54+
find_package(LLVM ${VERSION_CLEAN} CONFIG QUIET)
4055
endif()
4156
endforeach()
4257
if(NOT LLVM_FOUND)
@@ -69,7 +84,8 @@ else()
6984
unset(__qt_wraplibclang CACHE)
7085

7186
# Now, we're pretty certain that we can find the 'Clang' package without running into errors.
72-
find_package(Clang ${LLVM_VERSION} EXACT CONFIG)
87+
strip_git_from_version(LLVM_VERSION LLVM_VERSION_CLEAN)
88+
find_package(Clang ${LLVM_VERSION_CLEAN} EXACT CONFIG)
7389
endif()
7490

7591
# LLVM versions >= 16 come with Findzstd.cmake that creates a target for libzstd.

0 commit comments

Comments
 (0)