summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtAutoDetect.cmake11
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake93
-rw-r--r--cmake/QtPostProcess.cmake27
-rw-r--r--cmake/QtSetup.cmake10
-rw-r--r--cmake/QtStandaloneTestsConfig.cmake.in2
5 files changed, 101 insertions, 42 deletions
diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake
index a1e66ffcbe..7864d40501 100644
--- a/cmake/QtAutoDetect.cmake
+++ b/cmake/QtAutoDetect.cmake
@@ -2,9 +2,12 @@
# Collection of auto dection routines to improve the user eperience when
# building Qt from source.
#
+# Make sure to not run detection when building standalone tests, because the detection was already
+# done when initially configuring qtbase.
function(qt_auto_detect_android)
- if(DEFINED CMAKE_TOOLCHAIN_FILE AND NOT DEFINED QT_AUTODETECT_ANDROID)
+ if(DEFINED CMAKE_TOOLCHAIN_FILE AND NOT DEFINED QT_AUTODETECT_ANDROID
+ AND NOT QT_BUILD_STANDALONE_TESTS)
file(READ ${CMAKE_TOOLCHAIN_FILE} toolchain_file_content OFFSET 0 LIMIT 80)
string(FIND ${toolchain_file_content} "The Android Open Source Project" find_result REVERSE)
@@ -31,7 +34,7 @@ function(qt_auto_detect_android)
endfunction()
function(qt_auto_detect_vpckg)
- if(DEFINED ENV{VCPKG_ROOT})
+ if(DEFINED ENV{VCPKG_ROOT} AND NOT QT_BUILD_STANDALONE_TESTS)
set(vcpkg_toolchain_file "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
get_filename_component(vcpkg_toolchain_file "${vcpkg_toolchain_file}" ABSOLUTE)
@@ -49,6 +52,10 @@ function(qt_auto_detect_vpckg)
message(STATUS "Using vcpkg triplet ${VCPKG_TARGET_TRIPLET}")
endif()
unset(vcpkg_toolchain_file)
+ message(STATUS "CMAKE_TOOLCHAIN_FILE is: ${CMAKE_TOOLCHAIN_FILE}")
+ if(DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
+ message(STATUS "VCPKG_CHAINLOAD_TOOLCHAIN_FILE is: ${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
+ endif()
endif()
endfunction()
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index cb2070f773..1ff33dc706 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -60,37 +60,42 @@ macro(qt_build_repo_begin)
# Find Apple frameworks if needed.
qt_find_apple_system_frameworks()
+
+ # Decide whether tools will be built.
+ qt_check_if_tools_will_be_built()
endmacro()
macro(qt_build_repo_end)
- # Delayed actions on some of the Qt targets:
- include(QtPostProcess)
-
- # Install the repo-specific cmake find modules.
- qt_path_join(__qt_repo_install_dir ${QT_CONFIG_INSTALL_DIR} ${INSTALL_CMAKE_NAMESPACE})
-
- if(NOT PROJECT_NAME STREQUAL "QtBase")
- if (EXISTS cmake)
- qt_copy_or_install(DIRECTORY cmake/
- DESTINATION "${__qt_repo_install_dir}"
- FILES_MATCHING PATTERN "Find*.cmake"
- )
+ if(NOT QT_BUILD_STANDALONE_TESTS)
+ # Delayed actions on some of the Qt targets:
+ include(QtPostProcess)
+
+ # Install the repo-specific cmake find modules.
+ qt_path_join(__qt_repo_install_dir ${QT_CONFIG_INSTALL_DIR} ${INSTALL_CMAKE_NAMESPACE})
+
+ if(NOT PROJECT_NAME STREQUAL "QtBase")
+ if (EXISTS cmake)
+ qt_copy_or_install(DIRECTORY cmake/
+ DESTINATION "${__qt_repo_install_dir}"
+ FILES_MATCHING PATTERN "Find*.cmake"
+ )
+ endif()
endif()
- endif()
- # Print a feature summary:
- feature_summary(WHAT PACKAGES_FOUND
- REQUIRED_PACKAGES_NOT_FOUND
- RECOMMENDED_PACKAGES_NOT_FOUND
- OPTIONAL_PACKAGES_NOT_FOUND
- RUNTIME_PACKAGES_NOT_FOUND
- FATAL_ON_MISSING_REQUIRED_PACKAGES)
+ # Print a feature summary:
+ feature_summary(WHAT PACKAGES_FOUND
+ REQUIRED_PACKAGES_NOT_FOUND
+ RECOMMENDED_PACKAGES_NOT_FOUND
+ OPTIONAL_PACKAGES_NOT_FOUND
+ RUNTIME_PACKAGES_NOT_FOUND
+ FATAL_ON_MISSING_REQUIRED_PACKAGES)
+ endif()
qt_print_build_instructions()
endmacro()
function(qt_print_build_instructions)
- if(NOT PROJECT_NAME STREQUAL "QtBase")
+ if(NOT PROJECT_NAME STREQUAL "QtBase" OR QT_BUILD_STANDALONE_TESTS)
return()
endif()
@@ -118,19 +123,18 @@ macro(qt_build_repo)
# If testing is enabled, try to find the qtbase Test package.
# Do this before adding src, because there might be test related conditions
# in source.
- if (BUILD_TESTING)
+ if (BUILD_TESTING AND NOT QT_BUILD_STANDALONE_TESTS)
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test)
endif()
- ## Decide whether tools will be built.
- qt_check_if_tools_will_be_built()
-
- if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt")
- add_subdirectory(src)
- endif()
+ if(NOT QT_BUILD_STANDALONE_TESTS)
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt")
+ add_subdirectory(src)
+ endif()
- if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tools/CMakeLists.txt")
- add_subdirectory(tools)
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tools/CMakeLists.txt")
+ add_subdirectory(tools)
+ endif()
endif()
if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
@@ -139,23 +143,34 @@ macro(qt_build_repo)
qt_build_repo_end()
- if (BUILD_EXAMPLES AND BUILD_SHARED_LIBS AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt")
+ if (BUILD_EXAMPLES AND BUILD_SHARED_LIBS
+ AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt"
+ AND NOT QT_BUILD_STANDALONE_TESTS)
add_subdirectory(examples)
endif()
endmacro()
macro(qt_set_up_standalone_tests_build)
- qt_set_up_build_internals_paths()
- include(QtSetup)
-
- # Optionally include a repo specific Setup module.
- include(QtRepoSetup OPTIONAL)
-
- qt_find_apple_system_frameworks()
- qt_check_if_tools_will_be_built()
+ # Remove this macro once all usages of it have been removed.
+ # Standalone tests are not handled via the main repo project and qt_build_tests.
endmacro()
macro(qt_build_tests)
+ if(QT_BUILD_STANDALONE_TESTS)
+ # Find location of TestsConfig.cmake. These contain the modules that need to be
+ # find_package'd when testing.
+ set(_qt_build_tests_install_prefix
+ "${QT_CONFIG_INSTALL_DIR}/${INSTALL_CMAKE_NAMESPACE}BuildInternals/StandaloneTests")
+ if(QT_WILL_INSTALL)
+ qt_path_join(_qt_build_tests_install_prefix
+ ${CMAKE_INSTALL_PREFIX} ${_qt_build_tests_install_prefix})
+ endif()
+ include("${_qt_build_tests_install_prefix}/${CMAKE_PROJECT_NAME}TestsConfig.cmake")
+
+ # Of course we always need the test module as well.
+ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test)
+ endif()
+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/auto/CMakeLists.txt")
add_subdirectory(auto)
endif()
diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake
index ffa367cb9e..f77cfe546e 100644
--- a/cmake/QtPostProcess.cmake
+++ b/cmake/QtPostProcess.cmake
@@ -346,10 +346,37 @@ function(qt_create_tools_config_files)
endforeach()
endfunction()
+function(qt_internal_create_config_file_for_standalone_tests)
+ set(standalone_tests_config_dir "StandaloneTests")
+ qt_path_join(config_build_dir
+ ${QT_CONFIG_BUILD_DIR}
+ "${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
+ qt_path_join(config_install_dir
+ ${QT_CONFIG_INSTALL_DIR}
+ "${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
+
+ list(JOIN QT_REPO_KNOWN_MODULES " " QT_REPO_KNOWN_MODULES_STRING)
+ string(STRIP "${QT_REPO_KNOWN_MODULES_STRING}" QT_REPO_KNOWN_MODULES_STRING)
+
+ # Ceate a Config file that calls find_package on the modules that were built as part
+ # of the current repo. This is used for standalone tests.
+ configure_file(
+ "${QT_CMAKE_DIR}/QtStandaloneTestsConfig.cmake.in"
+ "${config_build_dir}/${CMAKE_PROJECT_NAME}TestsConfig.cmake"
+ @ONLY
+ )
+ qt_install(FILES
+ "${config_build_dir}/${CMAKE_PROJECT_NAME}TestsConfig.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+endfunction()
+
qt_create_tools_config_files()
qt_internal_create_depends_files()
qt_generate_build_internals_extra_cmake_code()
qt_internal_create_plugins_files()
+qt_internal_create_config_file_for_standalone_tests()
if (ANDROID)
qt_modules_process_android_dependencies()
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 837b81db4d..04b26d9596 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -39,7 +39,7 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
# or when enabling developer builds and no prefix is specified.
# This detection only happens when building qtbase, and later is propagated via the generated
# QtBuildInternalsExtra.cmake file.
-if (PROJECT_NAME STREQUAL "QtBase")
+if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS)
if((CMAKE_INSTALL_PREFIX STREQUAL CMAKE_BINARY_DIR) OR
(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND FEATURE_developer_build))
@@ -87,6 +87,14 @@ endif()
## Set up testing
option(BUILD_TESTING "Build the testing tree." ${QT_BUILD_TESTING})
+if(QT_BUILD_STANDALONE_TESTS)
+ set(QT_BUILD_TESTING ON)
+
+ # BuildInternals might have set it to OFF on initial configuration. So force it to ON when
+ # building standalone tests.
+ set(BUILD_TESTING ON CACHE BOOL "Build the testing tree." FORCE)
+endif()
+
include(CTest)
enable_testing()
diff --git a/cmake/QtStandaloneTestsConfig.cmake.in b/cmake/QtStandaloneTestsConfig.cmake.in
new file mode 100644
index 0000000000..3d08ae0c12
--- /dev/null
+++ b/cmake/QtStandaloneTestsConfig.cmake.in
@@ -0,0 +1,2 @@
+find_package(@INSTALL_CMAKE_NAMESPACE@ @PROJECT_VERSION@
+ REQUIRED COMPONENTS @QT_REPO_KNOWN_MODULES_STRING@)