de3a806def
Previously repo/tests/CMakeLists.txt was a standalone project on which CMake could be called. This was useful for Coin to be able to build and package only tests, but was a bit troublesome because that means having to specify the usual boilerplate like minimum CMake version, which packages to find in every tests.pro project. Instead of having a separate standalone project, modify the top level project and associated CMake code to allow passing a special QT_BUILD_STANDALONE_TESTS variable, which causes the top level project to build only tests, and find Qt in the previously installed qt location. This also means that when building a repo, we generate a ${repo_name}TestsConfig.cmake file which does find_package on all the modules that have been built as part of that repo. So that when standalone tests bare built for that repo, the modules are automatically found. qt_set_up_standalone_tests_build() is modified to be a no-op because it is not needed anymore. Its usage should be removed from all the other repos, and then removed from qtbase. Non-adjusted tests/CMakeLists.txt projects in other repositories should still be buildable with the current code, until they are updated to the new format. Adjust the Coin build instructions to build the standalone tests in a separate directory. Adjust pro2cmake to generate new structure for the tests/tests.pro projects. Adjust the qtbase tests project. Fixes: QTBUG-79239 Change-Id: Ib4b66bc772d8876cdcbae1e90ce5a5a5234fa675 Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
65 lines
2.8 KiB
CMake
65 lines
2.8 KiB
CMake
#
|
|
# 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
|
|
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)
|
|
if (NOT ${find_result} EQUAL -1)
|
|
set(android_detected TRUE)
|
|
else()
|
|
set(android_detected FALSE)
|
|
endif()
|
|
|
|
if(android_detected)
|
|
message(STATUS "Android toolchain file detected, checking configuration defaults...")
|
|
if(NOT DEFINED ANDROID_NATIVE_API_LEVEL)
|
|
message(STATUS "ANDROID_NATIVE_API_LEVEL was not specified, using API level 21 as default")
|
|
set(ANDROID_NATIVE_API_LEVEL 21 CACHE STRING "")
|
|
endif()
|
|
if(NOT DEFINED ANDROID_STL)
|
|
set(ANDROID_STL "c++_shared" CACHE STRING "")
|
|
endif()
|
|
endif()
|
|
set(QT_AUTODETECT_ANDROID ${android_detected} CACHE STRING "")
|
|
elseif (QT_AUTODETECT_ANDROID)
|
|
message(STATUS "Android toolchain file detected")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(qt_auto_detect_vpckg)
|
|
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)
|
|
|
|
if(DEFINED CMAKE_TOOLCHAIN_FILE)
|
|
get_filename_component(supplied_toolchain_file "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE)
|
|
if(NOT supplied_toolchain_file STREQUAL vcpkg_toolchain_file)
|
|
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" CACHE STRING "")
|
|
endif()
|
|
unset(supplied_toolchain_file)
|
|
endif()
|
|
set(CMAKE_TOOLCHAIN_FILE "${vcpkg_toolchain_file}" CACHE STRING "" FORCE)
|
|
message(STATUS "Using vcpkg from $ENV{VCPKG_ROOT}")
|
|
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
|
|
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
|
|
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()
|
|
|
|
|
|
qt_auto_detect_android()
|
|
qt_auto_detect_vpckg()
|