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>
This commit is contained in:
parent
df9c7456d1
commit
7c23281db3
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user