summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-09-30 15:05:52 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-05 19:09:34 +0000
commit2bb41394e0b910bb7c1b1b40ff9944f179ba7be2 (patch)
tree634178610c98783328889411db47b686e4b68342 /cmake
parentce369b75071958cac9bcdb38f61f3b8ffee9aa39 (diff)
CMake: Ensure that UNIX is set for INTEGRITY
Certain platform-related variables, in this case UNIX, must be set in a platform module, because they get cleared after the toolchain file is loaded. Such platform modules live in upstream CMake, but there is none yet for INTEGRITY. This manifests in an undefined UNIX variable and "System is unknown to CMake" warnings for the project and every configure test. Add the CMake module "Platform/Integrity" in the cmake/platforms directory. Add this directory to CMAKE_MODULE_PATH to let CMake load Platform/Integrity when the toolchain file set CMAKE_SYSTEM_NAME to "Integrity". CMake's module directory takes precedence, when loading platform modules. This is special for platform modules and different from the documented behavior of CMAKE_MODULE_PATH and include(). In case the user wants to provide their own platform modules via CMAKE_MODULE_PATH, they can instruct Qt to not add its path by setting QT_AVOID_CUSTOM_PLATFORM_MODULES to ON. Make sure that configure tests with project files also load the custom platform module. Fixes: QTBUG-96998 Change-Id: I9855d620d24dc66353cec5e847a2675b464ace26 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 165e01d5d51d16377542c1b3ffbc22f03fb75e97) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtAutoDetect.cmake6
-rw-r--r--cmake/QtBaseGlobalTargets.cmake5
-rw-r--r--cmake/QtFeature.cmake21
-rw-r--r--cmake/platforms/Platform/Integrity.cmake8
-rw-r--r--cmake/qt.toolchain.cmake.in6
5 files changed, 45 insertions, 1 deletions
diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake
index 128a882b8d..ce87560a85 100644
--- a/cmake/QtAutoDetect.cmake
+++ b/cmake/QtAutoDetect.cmake
@@ -433,6 +433,12 @@ function(qt_auto_detect_integrity)
endif()
endfunction()
+# Let CMake load our custom platform modules.
+# CMake-provided platform modules take precedence.
+if(NOT QT_AVOID_CUSTOM_PLATFORM_MODULES)
+ list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/platforms")
+endif()
+
qt_auto_detect_cmake_generator()
qt_auto_detect_cyclic_toolchain()
qt_auto_detect_cmake_config()
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index a660434a86..334e7eb585 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -263,6 +263,11 @@ qt_copy_or_install(FILES
DESTINATION "${__GlobalConfig_install_dir}"
)
+# Install our custom platform modules.
+qt_copy_or_install(DIRECTORY cmake/platforms
+ DESTINATION "${__GlobalConfig_install_dir}"
+)
+
# Install public config.tests files.
qt_copy_or_install(DIRECTORY
"config.tests/static_link_order"
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
index 65cb4f157a..a4832a896b 100644
--- a/cmake/QtFeature.cmake
+++ b/cmake/QtFeature.cmake
@@ -801,7 +801,14 @@ function(qt_config_compile_test name)
# If the repo has its own cmake modules, include those in the module path, so that various
# find_package calls work.
if(EXISTS "${PROJECT_SOURCE_DIR}/cmake")
- list(APPEND flags "-DCMAKE_MODULE_PATH:STRING=${PROJECT_SOURCE_DIR}/cmake")
+ set(flags_copy "${flags}")
+ set(flags)
+ foreach(flag IN LISTS flags_copy)
+ if(flag MATCHES "^-DCMAKE_MODULE_PATH:STRING=")
+ set(flag "${flag};${PROJECT_SOURCE_DIR}/cmake")
+ endif()
+ list(APPEND flags "${flag}")
+ endforeach()
endif()
# Pass which packages need to be found.
@@ -907,6 +914,7 @@ function(qt_config_compile_test name)
set(_save_CMAKE_C_STANDARD "${CMAKE_C_STANDARD}")
set(_save_CMAKE_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
set(_save_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+ set(_save_CMAKE_TRY_COMPILE_PLATFORM_VARIABLES "${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}")
if(arg_C_STANDARD)
set(CMAKE_C_STANDARD "${arg_C_STANDARD}")
@@ -928,6 +936,11 @@ function(qt_config_compile_test name)
list(APPEND CMAKE_REQUIRED_FLAGS "-Zc:__cplusplus")
endif()
+ # Let CMake load our custom platform modules.
+ if(NOT QT_AVOID_CUSTOM_PLATFORM_MODULES)
+ list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_MODULE_PATH)
+ endif()
+
set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_LIBRARIES "${arg_LIBRARIES}")
check_cxx_source_compiles("${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_${name})
@@ -936,6 +949,7 @@ function(qt_config_compile_test name)
set(CMAKE_C_STANDARD "${_save_CMAKE_C_STANDARD}")
set(CMAKE_CXX_STANDARD "${_save_CMAKE_CXX_STANDARD}")
set(CMAKE_REQUIRED_FLAGS "${_save_CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES "${_save_CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}")
endif()
endif()
@@ -972,6 +986,11 @@ function(qt_get_platform_try_compile_vars out_var)
endif()
endforeach()
+ # Let CMake load our custom platform modules.
+ if(NOT QT_AVOID_CUSTOM_PLATFORM_MODULES)
+ list(APPEND flags_cmd_line "-DCMAKE_MODULE_PATH:STRING=${QT_CMAKE_DIR}/platforms")
+ endif()
+
# Pass darwin specific options.
# The architectures need to be passed explicitly to project-based try_compile calls even on
# macOS, so that arm64 compilation works on Apple silicon.
diff --git a/cmake/platforms/Platform/Integrity.cmake b/cmake/platforms/Platform/Integrity.cmake
new file mode 100644
index 0000000000..964a01fc2f
--- /dev/null
+++ b/cmake/platforms/Platform/Integrity.cmake
@@ -0,0 +1,8 @@
+# Custom platform module file for INTEGRITY.
+#
+# UNIX must be set here, because this variable is cleared after the toolchain file is loaded.
+#
+# Once the lowest CMake version we support ships an Integrity platform module,
+# we can remove this file.
+
+set(UNIX 1)
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
index 38a7431620..79a37fd95a 100644
--- a/cmake/qt.toolchain.cmake.in
+++ b/cmake/qt.toolchain.cmake.in
@@ -70,6 +70,12 @@ get_filename_component(QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR "${CMAKE_CURRENT_LIST_
list(PREPEND CMAKE_PREFIX_PATH "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX}")
+# Let CMake load our custom platform modules.
+# CMake-provided platform modules take precedence.
+if(NOT QT_AVOID_CUSTOM_PLATFORM_MODULES)
+ list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/platforms")
+endif()
+
# Handle packages located in QT_ADDITIONAL_PACKAGES_PREFIX_PATH when cross-compiling. Needed for
# Conan.
# We prepend to CMAKE_PREFIX_PATH so that a find_package(Qt6Foo) call works, without having to go