diff options
author | Cristian Adam <cristian.adam@qt.io> | 2022-10-06 20:12:22 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@qt.io> | 2022-10-06 20:12:22 (GMT) |
commit | 681714ce205de10f8c5fb39baabed7b9486afcd9 (patch) | |
tree | 7c7324866c1d6843292b92549efed35b3dad0b08 /Tests/RunCMake | |
parent | 2133cf2c8e575bfff000041505208e28bcdfd4a3 (diff) | |
download | CMake-681714ce205de10f8c5fb39baabed7b9486afcd9.zip CMake-681714ce205de10f8c5fb39baabed7b9486afcd9.tar.gz CMake-681714ce205de10f8c5fb39baabed7b9486afcd9.tar.bz2 |
AUTOMOC: Skip PCH when all sources files skip the PCH file too
Fixes: #23464
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/Ninja/QtAutoMocSkipPch.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/RunCMakeTest.cmake | 16 |
2 files changed, 33 insertions, 0 deletions
diff --git a/Tests/RunCMake/Ninja/QtAutoMocSkipPch.cmake b/Tests/RunCMake/Ninja/QtAutoMocSkipPch.cmake new file mode 100644 index 0000000..059b917 --- /dev/null +++ b/Tests/RunCMake/Ninja/QtAutoMocSkipPch.cmake @@ -0,0 +1,17 @@ +enable_language(CXX) + +set(QtX Qt${with_qt_version}) + +find_package(${QtX} REQUIRED COMPONENTS Core) + +set(CMAKE_AUTOMOC ON) + +add_library(simple_lib SHARED simple_lib.cpp) +add_executable(app_with_qt app.cpp app_qt.cpp) + +target_link_libraries(app_with_qt PRIVATE simple_lib ${QtX}::Core) + +set_source_files_properties(app.cpp app_qt.cpp + PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + +target_precompile_headers(app_with_qt PRIVATE [["QObject"]]) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 2a5b556..9f078e6 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -357,6 +357,22 @@ function(run_QtAutoMocDeps) run_ninja("${RunCMake_TEST_BINARY_DIR}") endif() endfunction() + +function(run_QtAutoMocSkipPch) + set(QtX Qt${CMake_TEST_Qt_version}) + if(CMake_TEST_${QtX}Core_Version VERSION_GREATER_EQUAL 5.15.0) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/QtAutoMocSkipPch-build) + run_cmake_with_options(QtAutoMocSkipPch + "-Dwith_qt_version=${CMake_TEST_Qt_version}" + "-D${QtX}_DIR=${${QtX}_DIR}" + "-D${QtX}Core_DIR=${${QtX}Core_DIR}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" + ) + # Build the project. + run_ninja("${RunCMake_TEST_BINARY_DIR}") + endif() +endfunction() if(CMake_TEST_Qt_version) run_QtAutoMocDeps() + run_QtAutoMocSkipPch() endif() |