diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2019-02-26 22:28:04 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2019-02-26 22:28:04 (GMT) |
commit | e795be115e9c40d6092958d64f251db435acc4ba (patch) | |
tree | 1474474ff28bcdcfd1fe0c64a2d4431e740266d7 /Tests | |
parent | 4b95e7fe63d254b8e50f09f85a51e232a7470c7b (diff) | |
parent | 78ff8d573777c099aea5bd2eb92d9866c0d85952 (diff) | |
download | CMake-e795be115e9c40d6092958d64f251db435acc4ba.zip CMake-e795be115e9c40d6092958d64f251db435acc4ba.tar.gz CMake-e795be115e9c40d6092958d64f251db435acc4ba.tar.bz2 |
Merge branch 'master' into cmake_role-vs-fix
Diffstat (limited to 'Tests')
41 files changed, 891 insertions, 206 deletions
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index f6a9153..91f7e25 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories( set(CMakeLib_TESTS testGeneratedFileStream.cxx testRST.cxx + testRange.cxx testString.cxx testSystemTools.cxx testUTF8.cxx diff --git a/Tests/CMakeLib/testRange.cxx b/Tests/CMakeLib/testRange.cxx new file mode 100644 index 0000000..5ae805f --- /dev/null +++ b/Tests/CMakeLib/testRange.cxx @@ -0,0 +1,45 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmRange.h" + +#include <iostream> +#include <string> +#include <vector> + +#define ASSERT_TRUE(x) \ + do { \ + if (!(x)) { \ + std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ + return false; \ + } \ + } while (false) + +int testRange(int /*unused*/, char* /*unused*/ []) +{ + std::vector<int> const testData = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + + ASSERT_TRUE(!cmMakeRange(testData).empty()); + ASSERT_TRUE(cmMakeRange(testData).size() == 10); + + ASSERT_TRUE(!cmMakeRange(testData).advance(5).empty()); + ASSERT_TRUE(cmMakeRange(testData).advance(5).size() == 5); + + ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).empty()); + ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).size() == 0); + + ASSERT_TRUE(cmMakeRange(testData).any_of([](int n) { return n % 3 == 0; })); + ASSERT_TRUE(cmMakeRange(testData).all_of([](int n) { return n < 11; })); + ASSERT_TRUE(cmMakeRange(testData).none_of([](int n) { return n > 11; })); + + std::vector<int> const evenData = { 2, 4, 6, 8, 10 }; + ASSERT_TRUE(cmMakeRange(testData).filter([](int n) { return n % 2 == 0; }) == + cmMakeRange(evenData)); + + std::vector<std::string> const stringRange = { "1", "2", "3", "4", "5" }; + ASSERT_TRUE(cmMakeRange(testData) + .transform([](int n) { return std::to_string(n); }) + .retreat(5) == cmMakeRange(stringRange)); + + return 0; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6c888cc..3245f3e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -459,7 +459,7 @@ if(BUILD_TESTING) set(runCxxDialectTest 1) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL Clang - AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4 AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") if(NOT APPLE OR POLICY CMP0025) set(runCxxDialectTest 1) endif() @@ -1413,6 +1413,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindCURL) endif() + if(CMake_TEST_FindCups) + add_subdirectory(FindCups) + endif() + if(CMake_TEST_FindDoxygen) add_subdirectory(FindDoxygen) endif() @@ -3268,12 +3272,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log" ) - configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) - add_test(CTestTest2 ${CMAKE_CTEST_COMMAND} - -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V - --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" - ) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) + add_test(CTestTest2 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" + ) + endif() if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja") configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in" @@ -3305,11 +3311,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif () - get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) - if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( CTestTest2 - PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - endif () + if(NOT CMake_TEST_EXTERNAL_CMAKE) + get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) + if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + set_tests_properties ( CTestTest2 + PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + endif() + endif() endif () if(CMake_TEST_EXTERNAL_CMAKE) @@ -3373,6 +3381,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} -DCMake_TEST_Fortran_SUBMODULES:BOOL=${CMake_TEST_Fortran_SUBMODULES} + ${CMake_TEST_FortranModules_BUILD_OPTIONS} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules") endif() diff --git a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt index 9be69f1..1f9d3ac 100644 --- a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt @@ -57,7 +57,7 @@ else() message("Unhandled Platform") endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") check_cxx_compiler_flag("-x c++" HAVE_X_CXX) if(NOT HAVE_X_CXX) message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed") diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 811fff3..b5df961 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -407,7 +407,7 @@ endforeach() unset(_configs) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR CMAKE_C_COMPILER_ID STREQUAL Clang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")) AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) diff --git a/Tests/FindCups/CMakeLists.txt b/Tests/FindCups/CMakeLists.txt new file mode 100644 index 0000000..5be1ac1 --- /dev/null +++ b/Tests/FindCups/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindCups.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindCups/Test" + "${CMake_BINARY_DIR}/Tests/FindCups/Test" + ${build_generator_args} + --build-project FindCups + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindCups/Test/CMakeLists.txt b/Tests/FindCups/Test/CMakeLists.txt new file mode 100644 index 0000000..9e90553 --- /dev/null +++ b/Tests/FindCups/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) +project(TestFindCups C) +include(CTest) + +find_package(Cups REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_CUPS_VERSION="${CUPS_VERSION_STRING}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt Cups::Cups) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${CUPS_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${CUPS_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindCups/Test/main.c b/Tests/FindCups/Test/main.c new file mode 100644 index 0000000..b69d621 --- /dev/null +++ b/Tests/FindCups/Test/main.c @@ -0,0 +1,12 @@ +#include <cups/cups.h> + +int main() +{ + int num_options = 0; + cups_option_t* options = NULL; + + num_options = cupsAddOption(CUPS_COPIES, "1", num_options, &options); + cupsFreeOptions(num_options, options); + + return 0; +} diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 7023615..929fa4d 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -46,7 +46,7 @@ function(test_fortran_c_interface_module) FortranCInterface_VERIFY() FortranCInterface_VERIFY(CXX) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale|Absoft") + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|PathScale|Absoft") set(module_expected 1) endif() if(FortranCInterface_MODULE_FOUND OR module_expected) diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index b7b8320..761c405 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6) project(IncludeDirectories) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja" OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 45bb229..b584e16 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -61,7 +61,7 @@ if (C_expected_features) string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_C_COMPILER_VERSION}") if (CMAKE_C_COMPILER_ID STREQUAL "GNU" - OR CMAKE_C_COMPILER_ID STREQUAL "Clang" + OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_C_COMPILER_ID STREQUAL "Intel") add_executable(WriteCompilerDetectionHeader_C11 main.c) @@ -118,7 +118,7 @@ string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINO string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_CXX_COMPILER_VERSION}") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "SunPro" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel") @@ -128,7 +128,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" endif() # for msvc the compiler version determines which c++11 features are available. -if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")) if(";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;") list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS) list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES) diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt index f4b726f..9b32e59 100644 --- a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt @@ -5,10 +5,48 @@ include("../AutogenCoreTest.cmake") # Dummy executable to generate a clean target add_executable(dummy dummy.cpp) -set(timeformat "%Y%j%H%M%S") +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") set(mocBasicSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocBasic") set(mocBasicBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocBasic") +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamp When) + file(TIMESTAMP "${mocBasicBin}" time${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change) + if (timeAfter VERSION_GREATER timeBefore) + message(STATUS "As expected the file ${mocBasicBin} changed.") + else() + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} did not change!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + endif() +endmacro() + +macro(require_change_not) + if (timeAfter VERSION_GREATER timeBefore) + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} changed!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + else() + message(STATUS "As expected the file ${mocBasicBin} did not change.") + endif() +endmacro() + + # Initial build configure_file("${mocBasicSrcDir}/test1a.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) try_compile(MOC_RERUN @@ -21,46 +59,44 @@ try_compile(MOC_RERUN OUTPUT_VARIABLE output ) if (NOT MOC_RERUN) - message(SEND_ERROR "Initial build of mocBasic failed. Output: ${output}") + message(FATAL_ERROR "Initial build of mocBasic failed. Output: ${output}") endif() + # Get name of the output binary file(STRINGS "${mocBasicBinDir}/mocBasic.txt" mocBasicList ENCODING UTF-8) list(GET mocBasicList 0 mocBasicBin) -message("Changing the header content for a MOC rerun") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}") +# To avoid a race condition where the binary has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch binary to ensure it has a new timestamp +acquire_timestamp(Before) +sleep() +message(STATUS "Touching binary file to ensure a new timestamps") +file(TOUCH_NOCREATE "${mocBasicBin}") +acquire_timestamp(After) +require_change() + + # - Ensure that the timestamp will change -# - Change header file content and rebuild +# - Change header file content # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamp(Before) +sleep() +message(STATUS "Changing the header content for a MOC re-run") configure_file("${mocBasicSrcDir}/test1b.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result ) -if (result) - message(SEND_ERROR "Second build of mocBasic failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}") -# - Test if timestamps changed -if (NOT timeAfter GREATER timeBefore) - message(SEND_ERROR "File (${mocBasicBin}) should have changed!") -endif() +sleep() +rebuild(2) +acquire_timestamp(After) +require_change() -message("Changing nothing for a MOC rerun") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}") # - Ensure that the timestamp would change # - Change nothing # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result ) -if (result) - message(SEND_ERROR "Third build of mocBasic failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}") -# - Test if timestamps changed -if (timeAfter GREATER timeBefore) - message(SEND_ERROR "File (${mocBasicBin}) should not have changed!") -endif() +acquire_timestamp(Before) +sleep() +message(STATUS "Changing nothing for no MOC re-run") +rebuild(3) +acquire_timestamp(After) +require_change_not() diff --git a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt index b83e994..e1951f1 100644 --- a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt @@ -9,10 +9,53 @@ include("../AutogenCoreTest.cmake") add_executable(dummy dummy.cpp) # Utility variables -set(timeformat "%Y%j%H%M%S") +set(timeformat "%Y.%j.%H.%M%S") set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocPlugin") set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocPlugin") +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change PLG) + if (pl${PLG}After VERSION_GREATER pl${PLG}Before) + message(STATUS "As expected the file ${pl${PLG}File} changed.") + else() + message(SEND_ERROR + "Unexpectedly the file ${pl${PLG}File} did not change!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n") + endif() +endmacro() + +macro(require_change_not PLG) + if (pl${PLG}After VERSION_GREATER pl${PLG}Before) + message(SEND_ERROR + "Unexpectedly the file ${pl${PLG}File} changed!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n") + else() + message(STATUS "As expected the file ${pl${PLG}File} did not change.") + endif() +endmacro() + +macro(acquire_timestamps When) + file(TIMESTAMP "${plAFile}" plA${When} "${timeformat}") + file(TIMESTAMP "${plBFile}" plB${When} "${timeformat}") + file(TIMESTAMP "${plCFile}" plC${When} "${timeformat}") + file(TIMESTAMP "${plDFile}" plD${When} "${timeformat}") + file(TIMESTAMP "${plEFile}" plE${When} "${timeformat}") +endmacro() + + # Initial build try_compile(MOC_PLUGIN "${mocPlugBinDir}" @@ -24,83 +67,68 @@ try_compile(MOC_PLUGIN OUTPUT_VARIABLE output ) if (NOT MOC_PLUGIN) - message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}") + message(FATAL_ERROR "Initial build of mocPlugin failed. Output: ${output}") endif() +# Get names of the output binaries find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plEFile "PlugE" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) +# To avoid a race condition where the library has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - rebuild library to ensure it has a new timestamp +sleep() +message(STATUS "Rebuilding library files to ensure new timestamps") +rebuild(1) + + # - Ensure that the timestamp will change. # - Change the json files referenced by Q_PLUGIN_METADATA # - Rebuild -file(TIMESTAMP "${plAFile}" plABefore "${timeformat}") -file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}") -file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") -file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") -file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}") - -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing json files.") configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/StyleE.json") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - -file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}") -file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}") -file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") -file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") -file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}") - -if (plAAfter GREATER plABefore) - message(SEND_ERROR "file (${plAFile}) should not have changed!") -endif() -if (plBAfter GREATER plBBefore) - message(SEND_ERROR "file (${plBFile}) should not have changed!") -endif() -if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") -endif() -if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") -endif() -if (NOT plEAfter GREATER plEBefore) - # There's a bug in Ninja on Windows - # https://gitlab.kitware.com/cmake/cmake/issues/16776 - if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) - message(SEND_ERROR "file (${plEFile}) should have changed!") - endif() +sleep() +rebuild(2) +acquire_timestamps(After) +# Test changes +require_change_not(A) +require_change_not(B) +require_change(C) +require_change(D) +# There's a bug in Ninja on Windows: +# https://gitlab.kitware.com/cmake/cmake/issues/16776 +if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) + require_change(E) endif() + # - Ensure that the timestamp will change. # - Change the json files referenced by A_CUSTOM_MACRO # - Rebuild -file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") -file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") -file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}") - -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing json files") configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleE_Custom.json") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - -file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") -file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") -file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}") - -if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") -endif() -if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") -endif() -if (NOT plEAfter GREATER plEBefore) - # There's a bug in Ninja on Windows - # https://gitlab.kitware.com/cmake/cmake/issues/16776 - if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) - message(SEND_ERROR "file (${plEFile}) should have changed!") - endif() +sleep() +rebuild(3) +acquire_timestamps(After) +# Test changes +require_change_not(A) +require_change_not(B) +require_change(C) +require_change(D) +# There's a bug in Ninja on Windows +# https://gitlab.kitware.com/cmake/cmake/issues/16776 +if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) + require_change(E) endif() diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt index dcb7a79..33c01ac 100644 --- a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt @@ -9,10 +9,23 @@ add_executable(dummy dummy.cpp) # When a .qrc or a file listed in a .qrc file changes, # the target must be rebuilt -set(timeformat "%Y%j%H%M%S") set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccConfigChange") set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccConfigChange") +# Rebuild macro +macro(rebuild CFG) + message(STATUS "Rebuilding rccConfigChange in ${CFG} configuration.") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build . --config "${CFG}" + WORKING_DIRECTORY "${rccDepBD}" + RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "${CFG} build of rccConfigChange failed.") + else() + message(STATUS "${CFG} build of rccConfigChange finished.") + endif() +endmacro() + # Initial build try_compile(RCC_DEPENDS "${rccDepBD}" @@ -24,19 +37,11 @@ try_compile(RCC_DEPENDS OUTPUT_VARIABLE output ) if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccConfigChange failed. Output: ${output}") + message(FATAL_ERROR "Initial build of rccConfigChange failed. Output: ${output}") endif() -# - Rebuild Release -message("Rebuilding rccConfigChange in Release configuration") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Release build of rccConfigChange failed.") -endif() +# Rebuild: Release +rebuild(Release) -# - Rebuild Debug -message("Rebuilding rccConfigChange in Debug configuration") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Debug build of rccConfigChange failed.") -endif() +# Rebuild: Debug +rebuild(Debug) diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt index 80c5cf0..1301550 100644 --- a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt @@ -3,19 +3,63 @@ project(RerunRccDepends) include("../AutogenCoreTest.cmake") # Tests rcc rebuilding when a resource file changes +# When a .qrc or a file listed in a .qrc file changes, +# the target must be rebuilt # Dummy executable to generate a clean target add_executable(dummy dummy.cpp) -# When a .qrc or a file listed in a .qrc file changes, -# the target must be rebuilt -set(timeformat "%Y%j%H%M%S") +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccDepends") set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccDepends") -# Initial build +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamps When) + file(TIMESTAMP "${rccDepBinPlain}" rdPlain${When} "${timeformat}") + file(TIMESTAMP "${rccDepBinGenerated}" rdGenerated${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName} of rccDepends.") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${rccDepBD}" + RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} of rccDepends failed.") + else() + message(STATUS "Build ${buildName} of rccDepends finished.") + endif() +endmacro() + +macro(require_change type) + if (rd${type}After VERSION_GREATER rd${type}Before) + message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} changed.") + else() + message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} did not change!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n") + endif() +endmacro() + +macro(require_change_not type) + if (rd${type}After VERSION_GREATER rd${type}Before) + message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} changed!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n") + else() + message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} did not change.") + endif() +endmacro() + + +# Initial configuration configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) + +# Initial build try_compile(RCC_DEPENDS "${rccDepBD}" "${rccDepSD}" @@ -26,113 +70,84 @@ try_compile(RCC_DEPENDS OUTPUT_VARIABLE output ) if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}") + message(FATAL_ERROR "Initial build of rccDepends failed. Output: ${output}") endif() # Get name of the output binaries file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8) file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8) list(GET targetListPlain 0 rccDepBinPlain) -list(GET targetListGen 0 rccDepBinGen) -message("Target that uses a plain .qrc file is:\n ${rccDepBinPlain}") -message("Target that uses a GENERATED .qrc file is:\n ${rccDepBinGen}") +list(GET targetListGen 0 rccDepBinGenerated) +message(STATUS "Target that uses a plain .qrc file is:\n ${rccDepBinPlain}") +message(STATUS "Target that uses a GENERATED .qrc file is:\n ${rccDepBinGenerated}") + +# To avoid a race condition where the binary has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch binary to ensure it has a new timestamp +acquire_timestamps(Before) +sleep() +message(STATUS "Touching binary files to ensure new timestamps") +file(TOUCH_NOCREATE "${rccDepBinPlain}" "${rccDepBinGenerated}") +acquire_timestamps(After) +require_change(Plain) +require_change(Generated) -message("Changing a resource files listed in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change a resource files listed in the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing a resource file listed in the .qrc file") file(TOUCH "${rccDepBD}/resPlain/input.txt" "${rccDepBD}/resGen/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Second build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(2) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing the .qrc file") configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Third build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(3) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing a newly added resource files listed in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change a newly added resource files listed in the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing a newly added resource file listed in the .qrc file") file(TOUCH "${rccDepBD}/resPlain/inputAdded.txt" "${rccDepBD}/resGen/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fourth build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(4) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing nothing in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change nothing # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fifth build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +acquire_timestamps(Before) +sleep() +message(STATUS "Changing nothing in the .qrc file") +rebuild(5) +acquire_timestamps(After) # - Test if timestamps changed -if (rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should NOT have changed!") -endif() -if (rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should NOT have changed!") -endif() +require_change_not(Plain) +require_change_not(Generated) diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake index ce8d45b..869fe3d 100644 --- a/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake @@ -10,6 +10,7 @@ project(Minimal NONE) # set(targets aix-C-XL-13.1.3 aix-CXX-XL-13.1.3 + aix-C-XLClang-16.1.0.1 aix-CXX-XLClang-16.1.0.1 craype-C-Cray-8.7 craype-CXX-Cray-8.7 craype-Fortran-Cray-8.7 craype-C-GNU-7.3.0 craype-CXX-GNU-7.3.0 craype-Fortran-GNU-7.3.0 craype-C-Intel-18.0.2.20180210 craype-CXX-Intel-18.0.2.20180210 diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt b/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt index b854e2e..bffe819 100644 --- a/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt @@ -12,6 +12,9 @@ # cmake_minimum_required(VERSION 3.3) +if(POLICY CMP0089) + cmake_policy(SET CMP0089 NEW) +endif() set(lngs C CXX) set(LANGUAGES "${lngs}" CACHE STRING "List of languages to generate inputs for") diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.input new file mode 100644 index 0000000..2f018e6 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.input @@ -0,0 +1,40 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI= +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=XLClang +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=16.1.0.1 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command(s):/usr/bin/gmake cmTC_fcf21/fast +/usr/bin/gmake -f CMakeFiles/cmTC_fcf21.dir/build.make CMakeFiles/cmTC_fcf21.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o +/opt/IBM/xlC/16.1.0/bin/xlclang -V -o CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c +export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang +export XL_ASMOBJFILES=/tmp/xlcASuz87id +export "XL_DIS=/opt/IBM/xlc/16.1.0/exe/dis -o "CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o"" +/opt/IBM/xlC/16.1.0/exe/xlC2entry -qosvar=aix.7.2 -qalias=ansi -qthreaded -D_THREAD_SAFE -Wno-parentheses -Wno-unused-value -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -xc -qasm_as=/bin/as -qc_stdinc=/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -qvac_include_path=/opt/IBM/xlc/16.1.0/include -oCMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o /tmp/CMake/Modules/CMakeCCompilerABI.c /tmp/xlcW0tZ87ia /tmp/xlcW1ub87ib /dev/null /tmp/xlcLu487ieF.lst /dev/null /tmp/xlcW2uj87ic +export XL_BACKEND=/opt/IBM/xlc/16.1.0/exe/xlCcode +export XL_LINKER=/bin/ld +/opt/IBM/xlc/16.1.0/exe/xlCcode -qalias=ansi -qthreaded /tmp/xlcW0tZ87ia /tmp/xlcW1ub87ib CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o /tmp/xlcLu487ieB.lst /tmp/xlcW2uj87ic +rm /tmp/xlcASuz87id +rm /tmp/xlcLu487ie +rm /tmp/xlcW0tZ87ia +rm /tmp/xlcW1ub87ib +rm /tmp/xlcW2uj87ic +Linking C executable cmTC_fcf21 +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_fcf21.dir/link.txt --verbose=1 +/opt/IBM/xlC/16.1.0/bin/xlclang -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -o cmTC_fcf21 -Wl,-blibpath:/usr/lib:/lib +export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang +/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -o cmTC_fcf21 -blibpath:/usr/lib:/lib -L/opt/IBM/xlmass/9.1.0/lib/aix61 -L/opt/IBM/xlc/16.1.0/lib -lxlopt -lxlipa -lxl -lc -lpthreads +rm /tmp/xlcW0vJG7ia +rm /tmp/xlcW1vNG7ib +rm /tmp/xlcW2vRG7ic +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.output new file mode 100644 index 0000000..85399b7 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.output @@ -0,0 +1 @@ +/opt/IBM/xlC/16.1.0/include2;/opt/IBM/xlC/16.1.0/include2/aix;/opt/IBM/xlmass/9.1.0/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.input new file mode 100644 index 0000000..da16db3 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.input @@ -0,0 +1,44 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI= +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=XLClang +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=16.1.0.1 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command(s):/usr/bin/gmake cmTC_b8490/fast +/usr/bin/gmake -f CMakeFiles/cmTC_b8490.dir/build.make CMakeFiles/cmTC_b8490.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o +/opt/IBM/xlC/16.1.0/bin/xlclang++ -x c++ -V -o CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp +export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang++ +export XL_XLCMP_PATH=/opt/IBM/xlc/16.1.0:/opt/IBM/xlC/16.1.0 +export XL_COMPILER=xlc++ +export XL_ASMOBJFILES=/tmp/xlcAS3IXqid +export "XL_DIS=/opt/IBM/xlc/16.1.0/exe/dis -o "CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o"" +/opt/IBM/xlC/16.1.0/exe/xlC2entry -qosvar=aix.7.2 -qalias=ansi -qthreaded -D_THREAD_SAFE -Wno-parentheses -Wno-unused-value -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -xc++ -qasm_as=/bin/as -qcpp_stdinc=/opt/IBM/xlC/16.1.0/include2/c++:/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -qc_stdinc=/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -oCMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW03uXqia /tmp/xlcW137Xqib /dev/null /tmp/xlcL3QXqieF.lst /dev/null /tmp/xlcW23AXqic +export XL_BACKEND=/opt/IBM/xlc/16.1.0/exe/xlCcode +export XL_LINKER=/bin/ld +/opt/IBM/xlc/16.1.0/exe/xlCcode -qalias=ansi -qthreaded /tmp/xlcW03uXqia /tmp/xlcW137Xqib CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcL3QXqieB.lst /tmp/xlcW23AXqic +rm /tmp/xlcAS3IXqid +rm /tmp/xlcL3QXqie +rm /tmp/xlcW03uXqia +rm /tmp/xlcW137Xqib +rm /tmp/xlcW23AXqic +Linking CXX executable cmTC_b8490 +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b8490.dir/link.txt --verbose=1 +/opt/IBM/xlC/16.1.0/bin/xlclang++ -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_b8490 -Wl,-blibpath:/usr/lib:/lib +export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang++ +/bin/ld -b32 /lib/crt0.o /lib/crti.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_b8490 -blibpath:/usr/lib:/lib -bcdtors:all:0:s -btmplrename -L/opt/IBM/xlmass/9.1.0/lib/aix61 -L/opt/IBM/xlc/16.1.0/lib -lxlopt -lxlipa -lxl -L/opt/IBM/xlC/16.1.0/lib -lc++ -lCcore -lpthreads -lm -lc | +/opt/IBM/xlC/16.1.0/bin/c++filt -S | +/bin/sed '/317.*::virtual-fn-table-ptr$/ s/^\(.*: \)*{*\([^}]*\)\(}*.*\)::virtual-fn-table-ptr$/\1Virtual table for class "\2": Some possible causes are: first non-inline virtual function in "\2" is not defined or the class is a template instantiation and an explicit instantiation definition of the class is missing./' +rm /tmp/xlcW05fS7ia +rm /tmp/xlcW15rS7ib +rm /tmp/xlcW25vS7ic +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.output new file mode 100644 index 0000000..e462894 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.output @@ -0,0 +1 @@ +/opt/IBM/xlC/16.1.0/include2/c++;/opt/IBM/xlC/16.1.0/include2;/opt/IBM/xlC/16.1.0/include2/aix;/opt/IBM/xlmass/9.1.0/include;/usr/include diff --git a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake index 6ab3833..dab1c33 100644 --- a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake +++ b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake @@ -40,3 +40,62 @@ if(NOT FoundToolsVersion4) set(RunCMake_TEST_FAILED "Failed to find correct ToolsVersion=\"4.0\" .") return() endif() + +# +# Test solution file deployment items. +# + +set(vcSlnFile "${RunCMake_TEST_BINARY_DIR}/VsCEDebuggerDeploy.sln") +if(NOT EXISTS "${vcSlnFile}") + set(RunCMake_TEST_FAILED "Solution file ${vcSlnFile} does not exist.") + return() +endif() + + +if( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsCE" ) + set(RunCMake_TEST_FAILED "Test only valid for WindowsCE") + return() +endif() + + +set(FooProjGUID "") +set(FoundFooProj FALSE) +set(InFooProj FALSE) +set(FoundReleaseDeploy FALSE) +set(DeployConfigs Debug MinSizeRel RelWithDebInfo ) + +file(STRINGS "${vcSlnFile}" lines) +foreach(line IN LISTS lines) +#message(STATUS "${line}") + if( (NOT InFooProj ) AND (line MATCHES "^[ \\t]*Project\\(\"{[A-F0-9-]+}\"\\) = \"foo\", \"foo.vcxproj\", \"({[A-F0-9-]+})\"[ \\t]*$")) + # First, identify the GUID for the foo project, and record it. + set(FoundFooProj TRUE) + set(InFooProj TRUE) + set(FooProjGUID ${CMAKE_MATCH_1}) + elseif(InFooProj AND line MATCHES "EndProject") + set(InFooProj FALSE) + elseif((NOT InFooProj) AND line MATCHES "${FooProjGUID}\\.Release.*\\.Deploy\\.0") + # If foo's Release configuration is set to deploy, this is the error. + set(FoundReleaseDeploy TRUE) + endif() + if( line MATCHES "{[A-F0-9-]+}\\.([^\\|]+).*\\.Deploy\\.0" ) + # Check that the other configurations ARE set to deploy. + list( REMOVE_ITEM DeployConfigs ${CMAKE_MATCH_1}) + endif() +endforeach() + +if(FoundReleaseDeploy) + set(RunCMake_TEST_FAILED "Release deployment not inhibited by VS_NO_SOLUTION_DEPLOY_Release.") + return() +endif() + +if(NOT FoundFooProj) + set(RunCMake_TEST_FAILED "Failed to find foo project in the solution.") + return() +endif() + +list(LENGTH DeployConfigs length) +if( length GREATER 0 ) + set(RunCMake_TEST_FAILED "Failed to find Deploy lines for non-Release configurations. (${length})") + return() +endif() diff --git a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake index 948f14c..611db0a 100644 --- a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake +++ b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake @@ -4,10 +4,11 @@ set(DEPLOY_DIR "temp\\foodir" ) -add_library(foo foo.cpp) +add_library(foo SHARED foo.cpp) set_target_properties(foo PROPERTIES DEPLOYMENT_ADDITIONAL_FILES "foo.dll|\\foo\\src\\dir\\on\\host|$(RemoteDirectory)|0;bar.dll|\\bar\\src\\dir|$(RemoteDirectory)bardir|0" DEPLOYMENT_REMOTE_DIRECTORY ${DEPLOY_DIR} + VS_NO_SOLUTION_DEPLOY $<CONFIG:Release> ) diff --git a/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake b/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake new file mode 100644 index 0000000..561f9c0 --- /dev/null +++ b/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake @@ -0,0 +1,133 @@ +include(${CMAKE_CURRENT_LIST_DIR}/test_utils.cmake) + +# No keywords that miss any values, _KEYWORDS_MISSING_VALUES should not be defined +cmake_parse_arguments(PREF "" "P1" "P2" P1 p1 P2 p2_a p2_b) + +TEST(PREF_KEYWORDS_MISSING_VALUES "UNDEFINED") + +# Keyword should even be deleted from the actual scope +set(PREF_KEYWORDS_MISSING_VALUES "What ever") +cmake_parse_arguments(PREF "" "" "") + +TEST(PREF_KEYWORDS_MISSING_VALUES "UNDEFINED") + +# Given missing keywords as only option +cmake_parse_arguments(PREF "" "P1" "P2" P1) + +TEST(PREF_KEYWORDS_MISSING_VALUES "P1") +TEST(PREF_P1 "UNDEFINED") +TEST(PREF_UNPARSED_ARGUMENTS "UNDEFINED") + +# Mixed with unparsed arguments +cmake_parse_arguments(UPREF "" "P1" "P2" A B P2 C P1) +TEST(UPREF_KEYWORDS_MISSING_VALUES "P1") +TEST(UPREF_UNPARSED_ARGUMENTS A B) + +# one_value_keyword followed by option +cmake_parse_arguments(REF "OP" "P1" "" P1 OP) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_OP "TRUE") + +# Counter Test +cmake_parse_arguments(REF "OP" "P1" "" P1 p1 OP) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_OP "TRUE") + +# one_value_keyword followed by a one_value_keyword +cmake_parse_arguments(REF "" "P1;P2" "" P1 P2 p2) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "p2") + +# Counter Test +cmake_parse_arguments(REF "" "P1;P2" "" P1 p1 P2 p2) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "p2") + +# one_value_keyword followed by a multi_value_keywords +cmake_parse_arguments(REF "" "P1" "P2" P1 P2 p1 p2) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 p1 p2) + +# Counter Examples +cmake_parse_arguments(REF "" "P1" "P2" P1 p1 P2 p1 p2) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 p1 p2) + +# multi_value_keywords as only option +cmake_parse_arguments(REF "" "P1" "P2" P2) +TEST(REF_KEYWORDS_MISSING_VALUES "P2") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "UNDEFINED") + +# multi_value_keywords followed by option +cmake_parse_arguments(REF "O1" "" "P1" P1 O1) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_O1 "TRUE") + +# counter test +cmake_parse_arguments(REF "O1" "" "P1" P1 p1 p2 O1) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1;p2") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_O1 "TRUE") + +# multi_value_keywords followed by one_value_keyword +cmake_parse_arguments(REF "" "P1" "P2" P2 P1 p1) +TEST(REF_KEYWORDS_MISSING_VALUES "P2") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "UNDEFINED") + +# counter test +cmake_parse_arguments(REF "" "P1" "P2" P2 p2 P1 p1) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "p2") + +# one_value_keyword as last argument +cmake_parse_arguments(REF "" "P1" "P2" A P2 p2 P1) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "A") +TEST(REF_P2 "p2") + +# multi_value_keywords as last argument +cmake_parse_arguments(REF "" "P1" "P2" P1 p1 P2) +TEST(REF_KEYWORDS_MISSING_VALUES "P2") +TEST(REF_P1 "p1") +TEST(REF_P2 "UNDEFINED") + +# Multiple one_value_keyword and multi_value_keywords at different places +cmake_parse_arguments(REF "O1;O2" "P1" "P2" P1 O1 P2 O2) +TEST(REF_KEYWORDS_MISSING_VALUES P1 P2) +TEST(REF_P1 "UNDEFINED") +TEST(REF_P2 "UNDEFINED") + +# Duplicated missing keywords +cmake_parse_arguments(REF "O1;O2" "P1" "P2" P1 O1 P2 O2 P1 P2) +TEST(REF_KEYWORDS_MISSING_VALUES P1 P2) +TEST(REF_P1 "UNDEFINED") +TEST(REF_P2 "UNDEFINED") + +# make sure keywords that are never used, don't get added to KEYWORDS_MISSING_VALUES +cmake_parse_arguments(REF "O1;O2" "P1" "P2") +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_O1 FALSE) +TEST(REF_O2 FALSE) +TEST(REF_P1 UNDEFINED) +TEST(REF_P2 UNDEFINED) diff --git a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake index 1e15b3b..505840d 100644 --- a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake @@ -11,3 +11,4 @@ run_cmake(BadArgvN2) run_cmake(BadArgvN3) run_cmake(BadArgvN4) run_cmake(CornerCasesArgvN) +run_cmake(KeyWordsMissingValues) diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt b/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt b/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt new file mode 100644 index 0000000..83060b4 --- /dev/null +++ b/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt @@ -0,0 +1 @@ +list must be called with at least two arguments diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs.cmake b/Tests/RunCMake/list/POP_BACK-NoArgs.cmake new file mode 100644 index 0000000..518924d --- /dev/null +++ b/Tests/RunCMake/list/POP_BACK-NoArgs.cmake @@ -0,0 +1 @@ +list(POP_FRONT) diff --git a/Tests/RunCMake/list/POP_BACK.cmake b/Tests/RunCMake/list/POP_BACK.cmake new file mode 100644 index 0000000..4794796 --- /dev/null +++ b/Tests/RunCMake/list/POP_BACK.cmake @@ -0,0 +1,79 @@ +cmake_policy(SET CMP0054 NEW) + +function(assert_expected_list_len list_var expected_size) + list(LENGTH ${list_var} _size) + if(NOT _size EQUAL ${expected_size}) + message(FATAL_ERROR "list size expected to be `${expected_size}`, got `${_size}` instead") + endif() +endfunction() + +# Pop from undefined list +list(POP_BACK test) +if(DEFINED test) + message(FATAL_ERROR "`test` expected to be undefined") +endif() + +# Pop from empty list +set(test) +list(POP_BACK test) +if(DEFINED test) + message(FATAL_ERROR "`test` expected to be undefined") +endif() + +# Default pop from 1-item list +list(APPEND test one) +list(POP_BACK test) +assert_expected_list_len(test 0) + +# Pop from 1-item list to var +list(APPEND test one) +list(POP_BACK test one) +assert_expected_list_len(test 0) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() + +unset(one) +unset(two) + +# Pop from 1-item list to vars +list(APPEND test one) +list(POP_BACK test one two) +assert_expected_list_len(test 0) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() +if(DEFINED two) + message(FATAL_ERROR "`two` expected to be undefined") +endif() + +unset(one) +unset(two) + +# Default pop from 2-item list +list(APPEND test one two) +list(POP_BACK test) +assert_expected_list_len(test 1) +if(NOT test STREQUAL "one") + message(FATAL_ERROR "`test` has unexpected value `${test}`") +endif() + +# Pop from 2-item list +list(APPEND test two) +list(POP_BACK test two) +assert_expected_list_len(test 1) +if(NOT DEFINED two) + message(FATAL_ERROR "`two` expected to be defined") +endif() +if(NOT two STREQUAL "two") + message(FATAL_ERROR "`two` has unexpected value `${two}`") +endif() +if(NOT test STREQUAL "one") + message(FATAL_ERROR "`test` has unexpected value `${test}`") +endif() diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt b/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt b/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt new file mode 100644 index 0000000..83060b4 --- /dev/null +++ b/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt @@ -0,0 +1 @@ +list must be called with at least two arguments diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake b/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake new file mode 100644 index 0000000..c5cf837 --- /dev/null +++ b/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake @@ -0,0 +1 @@ +list(POP_BACK) diff --git a/Tests/RunCMake/list/POP_FRONT.cmake b/Tests/RunCMake/list/POP_FRONT.cmake new file mode 100644 index 0000000..a2f8f3c --- /dev/null +++ b/Tests/RunCMake/list/POP_FRONT.cmake @@ -0,0 +1,79 @@ +cmake_policy(SET CMP0054 NEW) + +function(assert_expected_list_len list_var expected_size) + list(LENGTH ${list_var} _size) + if(NOT _size EQUAL ${expected_size}) + message(FATAL_ERROR "list size expected to be `${expected_size}`, got `${_size}` instead") + endif() +endfunction() + +# Pop from undefined list +list(POP_FRONT test) +if(DEFINED test) + message(FATAL_ERROR "`test` expected to be undefined") +endif() + +# Pop from empty list +set(test) +list(POP_FRONT test) +if(DEFINED test) + message(FATAL_ERROR "`test` expected to be undefined") +endif() + +# Default pop from 1-item list +list(APPEND test one) +list(POP_FRONT test) +assert_expected_list_len(test 0) + +# Pop from 1-item list to var +list(APPEND test one) +list(POP_FRONT test one) +assert_expected_list_len(test 0) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() + +unset(one) +unset(two) + +# Pop from 1-item list to vars +list(APPEND test one) +list(POP_FRONT test one two) +assert_expected_list_len(test 0) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() +if(DEFINED two) + message(FATAL_ERROR "`two` expected to be undefined") +endif() + +unset(one) +unset(two) + +# Default pop from 2-item list +list(APPEND test one two) +list(POP_FRONT test) +assert_expected_list_len(test 1) +if(NOT test STREQUAL "two") + message(FATAL_ERROR "`test` has unexpected value `${test}`") +endif() + +# Pop from 2-item list +list(PREPEND test one) +list(POP_FRONT test one) +assert_expected_list_len(test 1) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() +if(NOT test STREQUAL "two") + message(FATAL_ERROR "`test` has unexpected value `${test}`") +endif() diff --git a/Tests/RunCMake/list/PREPEND-NoArgs-result.txt b/Tests/RunCMake/list/PREPEND-NoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/PREPEND-NoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt b/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt new file mode 100644 index 0000000..83060b4 --- /dev/null +++ b/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt @@ -0,0 +1 @@ +list must be called with at least two arguments diff --git a/Tests/RunCMake/list/PREPEND-NoArgs.cmake b/Tests/RunCMake/list/PREPEND-NoArgs.cmake new file mode 100644 index 0000000..8935fa9 --- /dev/null +++ b/Tests/RunCMake/list/PREPEND-NoArgs.cmake @@ -0,0 +1 @@ +list(PREPEND) diff --git a/Tests/RunCMake/list/PREPEND.cmake b/Tests/RunCMake/list/PREPEND.cmake new file mode 100644 index 0000000..17b2921 --- /dev/null +++ b/Tests/RunCMake/list/PREPEND.cmake @@ -0,0 +1,33 @@ +list(PREPEND test) +if(test) + message(FATAL_ERROR "failed") +endif() + +list(PREPEND test satu) +if(NOT test STREQUAL "satu") + message(FATAL_ERROR "failed") +endif() + +list(PREPEND test dua) +if(NOT test STREQUAL "dua;satu") + message(FATAL_ERROR "failed") +endif() + +list(PREPEND test tiga) +if(NOT test STREQUAL "tiga;dua;satu") + message(FATAL_ERROR "failed") +endif() + +# Scope test +function(foo) + list(PREPEND test empat) + if(NOT test STREQUAL "empat;tiga;dua;satu") + message(FATAL_ERROR "failed") + endif() +endfunction() + +foo() + +if(NOT test STREQUAL "tiga;dua;satu") + message(FATAL_ERROR "failed") +endif() diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index bf3d22d..59c7ea5 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -98,3 +98,15 @@ run_cmake(SORT-NoCaseOption) # Successful tests run_cmake(SORT) + +# argument tests +run_cmake(PREPEND-NoArgs) +# Successful tests +run_cmake(PREPEND) + +# argument tests +run_cmake(POP_BACK-NoArgs) +run_cmake(POP_FRONT-NoArgs) +# Successful tests +run_cmake(POP_BACK) +run_cmake(POP_FRONT) diff --git a/Tests/RunCMake/try_compile/CMP0066-stderr.txt b/Tests/RunCMake/try_compile/CMP0066-stderr.txt index b14e290..0b92dcf 100644 --- a/Tests/RunCMake/try_compile/CMP0066-stderr.txt +++ b/Tests/RunCMake/try_compile/CMP0066-stderr.txt @@ -12,4 +12,15 @@ CMake Warning \(dev\) at CMP0066.cmake:[0-9]+ \(try_compile\): test project. Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it.$ +This warning is for project developers. Use -Wno-dev to suppress it. +* +CMake Deprecation Warning at CMP0066.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0066 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/LinkOptions.cmake b/Tests/RunCMake/try_compile/LinkOptions.cmake index 9b246c4..488cab1 100644 --- a/Tests/RunCMake/try_compile/LinkOptions.cmake +++ b/Tests/RunCMake/try_compile/LinkOptions.cmake @@ -5,7 +5,7 @@ cmake_policy(SET CMP0054 NEW) set (lib_name "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lib${CMAKE_STATIC_LIBRARY_SUFFIX}") if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if (RunCMake_C_COMPILER_ID STREQUAL "MSVC") + if (RunCMake_C_COMPILER_ID STREQUAL "MSVC" OR "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") if (CMAKE_SIZEOF_VOID_P EQUAL 4) set (undef_flag /INCLUDE:_func) else() diff --git a/Tests/RunCMake/try_run/LinkOptions.cmake b/Tests/RunCMake/try_run/LinkOptions.cmake index 17af2f7..9939a42 100644 --- a/Tests/RunCMake/try_run/LinkOptions.cmake +++ b/Tests/RunCMake/try_run/LinkOptions.cmake @@ -5,7 +5,7 @@ cmake_policy(SET CMP0054 NEW) set (lib_name "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lib${CMAKE_STATIC_LIBRARY_SUFFIX}") if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if (RunCMake_C_COMPILER_ID STREQUAL "MSVC") + if (RunCMake_C_COMPILER_ID STREQUAL "MSVC" OR "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") if (CMAKE_SIZEOF_VOID_P EQUAL 4) set (undef_flag /INCLUDE:_func) else() |