summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-10-16 17:21:04 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-10-23 01:32:29 +0200
commit7c23281db31aa55b0fe3cce85cb018a1206dccb1 (patch)
treec11d0ab557769d15b6e0b9133596e4f74e32e89b /cmake
parentdf9c7456d11dfcf74c7399ba0981a3ba3d3f5117 (diff)
CMake: Fix headersclean to work on macOS
It appears there's a difference between the chosen macOS compiler path in the CI versus the compiler path on my local machine. In the CI the chosen compiler path ends up 'being /usr/bin/clang++' whereas for me locally it's /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ For some reason the headersclean commands succeed in the CI, but locally they fail for me saying that standard library includes can not be found, unless an explicit sysroot flag is specified. I assume that in the CI the '/usr/bin/clang++' compiler shim chooses some implcit sysroot, whereas the longer Xcode compiler expects an explicit sysroot. It's probably also affected by the fact that in the CI we pass an explicit CMAKE_OSX_SYSROOT to a non-standard Xcode location e.g. /Applications/Xcode11.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk Note the '11' in the Xcode app name. Locally I don't pass a custom CMAKE_OSX_SYSROOT, and my Xcode is installed in a regular location e.g /Applications/Xcode.app. The sysroot flag and path is added to regular CXX compilation rules inside CMake's core (in cmLocalGenerator.cxx). Reuse the same variables that CMake uses and add them to our headersclean command rules. Task-number: QTBUG-82615 Change-Id: Ic03ea27e39471f5fa168eb5970bf3d3f1d1be251 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtHeadersClean.cmake8
1 files changed, 7 insertions, 1 deletions
diff --git a/cmake/QtHeadersClean.cmake b/cmake/QtHeadersClean.cmake
index e420e5814e..0b2debdd79 100644
--- a/cmake/QtHeadersClean.cmake
+++ b/cmake/QtHeadersClean.cmake
@@ -83,6 +83,12 @@ function(qt_internal_add_headers_clean_target
# Use strict mode C++17, with no GNU extensions (see -pedantic-errors above).
list(APPEND hcleanFLAGS -std=c++17)
+ set(cxx_flags ${CMAKE_CXX_FLAGS})
+
+ if(APPLE AND CMAKE_OSX_SYSROOT)
+ list(APPEND cxx_flags "${CMAKE_CXX_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}")
+ endif()
+
foreach(header ${hclean_headers})
get_filename_component(input_path "${header}" ABSOLUTE)
set(artifact_path "header_${header}.o")
@@ -90,7 +96,7 @@ function(qt_internal_add_headers_clean_target
add_custom_command(
OUTPUT "${artifact_path}"
COMMENT "headersclean: Checking header ${header}"
- COMMAND "${CMAKE_CXX_COMPILER}" -c ${CMAKE_CXX_FLAGS} ${hcleanFLAGS}
+ COMMAND "${CMAKE_CXX_COMPILER}" -c ${cxx_flags} ${hcleanFLAGS}
-I "${QT_BUILD_DIR}/include" -I "${CMAKE_INSTALL_PREFIX}/include"
${hcleanDEFS} -xc++ "${input_path}"
-o${artifact_path}