diff options
author | Brad King <brad.king@kitware.com> | 2023-05-04 13:00:51 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-05-04 13:01:08 (GMT) |
commit | 28dd02c3ba9dafb3df614565ec83223f61f30280 (patch) | |
tree | dac83df715fdfc46c6cf25e66ee2b59085aa89b8 /Tests | |
parent | 7a4ec8d6cc3226185f4a04db7421d9414b1cada7 (diff) | |
parent | 7bf4e3009000b0ab576f364abc779e9a1599af08 (diff) | |
download | CMake-28dd02c3ba9dafb3df614565ec83223f61f30280.zip CMake-28dd02c3ba9dafb3df614565ec83223f61f30280.tar.gz CMake-28dd02c3ba9dafb3df614565ec83223f61f30280.tar.bz2 |
Merge topic 'autogen-system-include'
7bf4e30090 Autogen: Default AUTOGEN_USE_SYSTEM_INCLUDE to ON if it is not set
033dc7ee2f Autogen: Add AUTOGEN_USE_SYSTEM_INCLUDE target property
8ba16db163 Tests/RunCMake: Add option for dynamic expected output
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8400
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/QtAutogen/GlobalAutogenSystemUseInclude/CMakeLists.txt | 28 | ||||
-rw-r--r-- | Tests/QtAutogen/GlobalAutogenSystemUseInclude/main.cpp | 4 | ||||
-rw-r--r-- | Tests/QtAutogen/Tests.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Autogen/AutogenUseSystemIncludeCommon.cmake | 10 | ||||
-rw-r--r-- | Tests/RunCMake/Autogen/AutogenUseSystemIncludeOff.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/Autogen/AutogenUseSystemIncludeOn.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/Autogen/CMP0151-common.cmake | 10 | ||||
-rw-r--r-- | Tests/RunCMake/Autogen/CMP0151-new.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Autogen/CMP0151-old.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Autogen/Inspect.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/Autogen/RunCMakeTest.cmake | 66 | ||||
-rw-r--r-- | Tests/RunCMake/RunCMake.cmake | 2 |
12 files changed, 142 insertions, 0 deletions
diff --git a/Tests/QtAutogen/GlobalAutogenSystemUseInclude/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenSystemUseInclude/CMakeLists.txt new file mode 100644 index 0000000..1095fb1 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenSystemUseInclude/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.26) +project(GlobalAutogenSystemUseInclude) + +include("../AutogenCoreTest.cmake") + +block() + set(test_autogen_use_system_include ON) + set(CMAKE_AUTOGEN_USE_SYSTEM_INCLUDE ${test_autogen_use_system_include}) + + add_executable(autogen_test_on main.cpp) + get_target_property(target_autogen_use_system_include autogen_test_on AUTOGEN_USE_SYSTEM_INCLUDE) + + if(NOT ${CMAKE_AUTOGEN_USE_SYSTEM_INCLUDE} STREQUAL ${target_autogen_use_system_include}) + message(FATAL_ERROR "CMAKE_AUTOGEN_USE_SYSTEM_INCLUDE not set") + endif() +endblock() + +block() + set(test_autogen_use_system_include OFF) + set(CMAKE_AUTOGEN_USE_SYSTEM_INCLUDE ${test_autogen_use_system_include}) + + add_executable(autogen_test_off main.cpp) + get_target_property(target_autogen_use_system_include autogen_test_off AUTOGEN_USE_SYSTEM_INCLUDE) + + if(NOT ${CMAKE_AUTOGEN_USE_SYSTEM_INCLUDE} STREQUAL ${target_autogen_use_system_include}) + message(FATAL_ERROR "CMAKE_AUTOGEN_USE_SYSTEM_INCLUDE not set") + endif() +endblock() diff --git a/Tests/QtAutogen/GlobalAutogenSystemUseInclude/main.cpp b/Tests/QtAutogen/GlobalAutogenSystemUseInclude/main.cpp new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenSystemUseInclude/main.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index cdce2b1..3e4f04d 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -3,6 +3,7 @@ ADD_AUTOGEN_TEST(AutogenOriginDependsOff autogenOriginDependsOff) ADD_AUTOGEN_TEST(AutogenOriginDependsOn) ADD_AUTOGEN_TEST(AutogenTargetDepends) ADD_AUTOGEN_TEST(Complex QtAutogen) +ADD_AUTOGEN_TEST(GlobalAutogenSystemUseInclude) ADD_AUTOGEN_TEST(GlobalAutogenTarget) ADD_AUTOGEN_TEST(GlobalAutogenExecutable) ADD_AUTOGEN_TEST(LowMinimumVersion lowMinimumVersion) diff --git a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeCommon.cmake b/Tests/RunCMake/Autogen/AutogenUseSystemIncludeCommon.cmake new file mode 100644 index 0000000..bbefd5f --- /dev/null +++ b/Tests/RunCMake/Autogen/AutogenUseSystemIncludeCommon.cmake @@ -0,0 +1,10 @@ +enable_language(CXX) + +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) + +set(CMAKE_AUTOMOC ON) + +add_library(dummy SHARED empty.cpp) +target_link_libraries(dummy Qt${with_qt_version}::Core + Qt${with_qt_version}::Widgets + Qt${with_qt_version}::Gui) diff --git a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOff.cmake b/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOff.cmake new file mode 100644 index 0000000..dfdbb98 --- /dev/null +++ b/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOff.cmake @@ -0,0 +1,3 @@ +include("${CMAKE_CURRENT_LIST_DIR}/AutogenUseSystemIncludeCommon.cmake") + +set_target_properties(dummy PROPERTIES AUTOGEN_USE_SYSTEM_INCLUDE OFF) diff --git a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOn.cmake b/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOn.cmake new file mode 100644 index 0000000..f556ed4 --- /dev/null +++ b/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOn.cmake @@ -0,0 +1,3 @@ +include("${CMAKE_CURRENT_LIST_DIR}/AutogenUseSystemIncludeCommon.cmake") + +set_target_properties(dummy PROPERTIES AUTOGEN_USE_SYSTEM_INCLUDE ON) diff --git a/Tests/RunCMake/Autogen/CMP0151-common.cmake b/Tests/RunCMake/Autogen/CMP0151-common.cmake new file mode 100644 index 0000000..bbefd5f --- /dev/null +++ b/Tests/RunCMake/Autogen/CMP0151-common.cmake @@ -0,0 +1,10 @@ +enable_language(CXX) + +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) + +set(CMAKE_AUTOMOC ON) + +add_library(dummy SHARED empty.cpp) +target_link_libraries(dummy Qt${with_qt_version}::Core + Qt${with_qt_version}::Widgets + Qt${with_qt_version}::Gui) diff --git a/Tests/RunCMake/Autogen/CMP0151-new.cmake b/Tests/RunCMake/Autogen/CMP0151-new.cmake new file mode 100644 index 0000000..9c77e58 --- /dev/null +++ b/Tests/RunCMake/Autogen/CMP0151-new.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/CMP0151-common.cmake") diff --git a/Tests/RunCMake/Autogen/CMP0151-old.cmake b/Tests/RunCMake/Autogen/CMP0151-old.cmake new file mode 100644 index 0000000..9c77e58 --- /dev/null +++ b/Tests/RunCMake/Autogen/CMP0151-old.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/CMP0151-common.cmake") diff --git a/Tests/RunCMake/Autogen/Inspect.cmake b/Tests/RunCMake/Autogen/Inspect.cmake new file mode 100644 index 0000000..d5dc4b4 --- /dev/null +++ b/Tests/RunCMake/Autogen/Inspect.cmake @@ -0,0 +1,13 @@ +enable_language(CXX) + +set(info "") +foreach(var + CMAKE_INCLUDE_FLAG_CXX + CMAKE_INCLUDE_SYSTEM_FLAG_CXX + ) + if(DEFINED ${var}) + string(APPEND info "set(${var} \"${${var}}\")\n") + endif() +endforeach() + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}") diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake index 6a3c49b..4505132 100644 --- a/Tests/RunCMake/Autogen/RunCMakeTest.cmake +++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake @@ -22,4 +22,70 @@ if (DEFINED with_qt_version) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(MocPredefs-build ${CMAKE_COMMAND} --build . --config Debug) endblock() + + # Detect information from the toolchain: + # - CMAKE_INCLUDE_FLAG_CXX + # - CMAKE_INCLUDE_SYSTEM_FLAG_CXX + run_cmake(Inspect) + include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") + + if(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + if(RunCMake_GENERATOR MATCHES "Visual Studio") + string(REGEX REPLACE "^-" "/" test_expect_stdout "${CMAKE_INCLUDE_SYSTEM_FLAG_CXX}") + else() + set(test_expect_stdout "-*${CMAKE_INCLUDE_SYSTEM_FLAG_CXX}") + endif() + string(APPEND test_expect_stdout " *(\"[^\"]*|([^ ]|\\ )*)[\\/]dummy_autogen[\\/]include") + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + string(APPEND test_expect_stdout "_Debug") + endif() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0151-new-build) + run_cmake_with_options(CMP0151-new ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") + message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") + run_cmake_command(CMP0151-new-build ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenUseSystemIncludeOn-build) + run_cmake_with_options(AutogenUseSystemIncludeOn ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") + message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") + run_cmake_command(AutogenUseSystemIncludeOn ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + endif() + + if(CMAKE_INCLUDE_FLAG_CXX) + if(RunCMake_GENERATOR MATCHES "Visual Studio") + string(REGEX REPLACE "^-" "/" test_expect_stdout "${CMAKE_INCLUDE_FLAG_CXX}") + else() + set(test_expect_stdout "-*${CMAKE_INCLUDE_FLAG_CXX}") + endif() + string(APPEND test_expect_stdout " *(\"[^\"]*|([^ ]|\\ )*)[\\/]dummy_autogen[\\/]include") + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + string(APPEND test_expect_stdout "_Debug") + endif() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0151-old-build) + run_cmake_with_options(CMP0151-old ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=OLD) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") + message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") + run_cmake_command(CMP0151-old-build ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenUseSystemIncludeOff-build) + run_cmake_with_options(AutogenUseSystemIncludeOff ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") + message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") + run_cmake_command(AutogenUseSystemIncludeOff ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + endif() endif () diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index b8efe35..18dde94 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -47,6 +47,8 @@ function(run_cmake test) elseif(EXISTS ${top_src}/${test}-${o}.txt) file(READ ${top_src}/${test}-${o}.txt expect_${o}) string(REGEX REPLACE "\n+$" "" expect_${o} "${expect_${o}}") + elseif(DEFINED RunCMake_TEST_EXPECT_${o}) + string(REGEX REPLACE "\n+$" "" expect_${o} "${RunCMake_TEST_EXPECT_${o}}") else() unset(expect_${o}) endif() |