diff options
Diffstat (limited to 'Tests')
615 files changed, 5450 insertions, 1222 deletions
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt index e156420db..fc7013598 100644 --- a/Tests/AliasTarget/CMakeLists.txt +++ b/Tests/AliasTarget/CMakeLists.txt @@ -4,13 +4,6 @@ project(AliasTarget) set(CMAKE_CXX_STANDARD 98) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 46431bc33..b49803bd6 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -1,4 +1,4 @@ -#include <cmConfigure.h> +#include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/FStream.hxx" #include <iostream> @@ -144,15 +144,11 @@ int main() cmsys::ifstream file("compile_commands.json"); CompileCommandParser parser(file); parser.Parse(); - for (CompileCommandParser::TranslationUnitsType::const_iterator - it = parser.GetTranslationUnits().begin(), - end = parser.GetTranslationUnits().end(); - it != end; ++it) { + for (auto const& tu : parser.GetTranslationUnits()) { std::vector<std::string> command; - cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command); - if (!cmSystemTools::RunSingleCommand(command, CM_NULLPTR, CM_NULLPTR, - CM_NULLPTR, - it->at("directory").c_str())) { + cmSystemTools::ParseUnixCommandLine(tu.at("command").c_str(), command); + if (!cmSystemTools::RunSingleCommand(command, nullptr, nullptr, nullptr, + tu.at("directory").c_str())) { std::cout << "ERROR: Failed to run command \"" << command[0] << "\"" << std::endl; exit(1); diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx index fb5f3d815..c99c46db5 100644 --- a/Tests/CMakeLib/testUTF8.cxx +++ b/Tests/CMakeLib/testUTF8.cxx @@ -8,8 +8,9 @@ typedef char test_utf8_char[5]; static void test_utf8_char_print(test_utf8_char const c) { unsigned char const* d = reinterpret_cast<unsigned char const*>(c); - printf("[0x%02X,0x%02X,0x%02X,0x%02X]", (int)d[0], (int)d[1], (int)d[2], - (int)d[3]); + printf("[0x%02X,0x%02X,0x%02X,0x%02X]", static_cast<int>(d[0]), + static_cast<int>(d[1]), static_cast<int>(d[2]), + static_cast<int>(d[3])); } struct test_utf8_entry diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes b/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes deleted file mode 100644 index 5be3dc5bc..000000000 --- a/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.sln-file -crlf whitespace=cr-at-eol diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx index fe776c587..21bb95292 100644 --- a/Tests/CMakeLib/testXMLSafe.cxx +++ b/Tests/CMakeLib/testXMLSafe.cxx @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include <cmConfigure.h> +#include "cmConfigure.h" // IWYU pragma: keep #include <sstream> #include <stdio.h> @@ -21,7 +21,7 @@ static test_pair const pairs[] = { { "angles <>", "angles <>" }, { "ampersand &", "ampersand &" }, { "bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]" }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, nullptr } }; int testXMLSafe(int /*unused*/, char* /*unused*/ []) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d16df1cf5..533788a44 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -146,6 +146,10 @@ if(BUILD_TESTING) if(NOT CMake_TEST_EXTERNAL_CMAKE) add_subdirectory(CMakeLib) + + if(CMake_TEST_SERVER_MODE) + add_subdirectory(CMakeServerLib) + endif() endif() add_subdirectory(CMakeOnly) add_subdirectory(RunCMake) @@ -264,7 +268,7 @@ if(BUILD_TESTING) endif() add_test(NAME CMake.Copyright - COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake) + COMMAND ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake) # add a bunch of standard build-and-test style tests ADD_TEST_MACRO(CommandLineTest CommandLineTest) @@ -325,7 +329,7 @@ if(BUILD_TESTING) set(CMAKE_SKIP_VSGNUFortran TRUE) endif() if(NOT CMAKE_SKIP_VSGNUFortran) - ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake) + ADD_TEST_MACRO(VSGNUFortran ${CMAKE_CMAKE_COMMAND} -P runtest.cmake) endif() endif() @@ -403,11 +407,14 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) - if(NOT QT4_FOUND) + if(NOT DEFINED CMake_TEST_Qt4) + set(CMake_TEST_Qt4 1) + endif() + if(CMake_TEST_Qt4 AND NOT QT4_FOUND) find_package(Qt4 QUIET) endif() - if(QT4_FOUND) + if(CMake_TEST_Qt4 AND QT4_FOUND) # test whether the Qt4 which has been found works, on some machines # which run nightly builds there were errors like "wrong file format" # for libQtCore.so. So first check it works, and only if it does add @@ -809,31 +816,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory") - #add_test(SimpleExclude ${CMAKE_CTEST_COMMAND} - # --build-and-test - # "${CMake_SOURCE_DIR}/Tests/SimpleExclude" - # "${CMake_BINARY_DIR}/Tests/SimpleExclude" - # ${build_generator_args} - # --build-project SimpleExclude - # --build-two-config - # --build-options ${build_options} - # --test-command t4 - #--test-command "${CMAKE_COMMAND}" - #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}" - #-P "${CMake_BINARY_DIR}/Tests/SimpleExclude/run.cmake" - #) - -# add_test(SameName ${CMAKE_CTEST_COMMAND} -# --build-and-test -# "${CMake_SOURCE_DIR}/Tests/SameName" -# "${CMake_BINARY_DIR}/Tests/SameName" -# ${build_generator_args} -# --build-project SameName -# --build-two-config -# --build-options ${build_options} -# --test-command -# "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2") - add_test(OutOfSource ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/OutOfSource" @@ -1274,8 +1256,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set(QtAutogen_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>) endif() - find_package(Qt5Widgets QUIET NO_MODULE) - if(Qt5Widgets_FOUND) + if(NOT DEFINED CMake_TEST_Qt5) + set(CMake_TEST_Qt5 1) + endif() + if(CMake_TEST_Qt5) + find_package(Qt5Widgets QUIET NO_MODULE) + endif() + if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) add_test(NAME Qt5Autogen COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/QtAutogen" @@ -1285,12 +1272,28 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen" --force-new-ctest-process --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5 + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=5 ${QtAutogen_BUILD_OPTIONS} --test-command ${run_autogen_test} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen") + add_test(NAME Qt5AutogenRerun COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutogenRerun" + "${CMake_BINARY_DIR}/Tests/Qt5AutogenRerun" + ${build_generator_args} + --build-project QtAutogenRerun + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5AutogenRerun" + --force-new-ctest-process + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=5 + ${QtAutogen_BUILD_OPTIONS} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5AutogenRerun") + add_test(Qt5AutoUicInterface ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface" @@ -1315,12 +1318,28 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen" --force-new-ctest-process --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=4 ${QtAutogen_BUILD_OPTIONS} --test-command ${run_autogen_test} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen") + add_test(NAME Qt4AutogenRerun COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutogenRerun" + "${CMake_BINARY_DIR}/Tests/Qt4AutogenRerun" + ${build_generator_args} + --build-project QtAutogenRerun + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutogenRerun" + --force-new-ctest-process + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=4 + ${QtAutogen_BUILD_OPTIONS} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutogenRerun") + add_test(Qt4AutoUicInterface ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface" @@ -1330,7 +1349,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface" --force-new-ctest-process --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=4 --test-command ${run_autouic_test} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface") @@ -1394,6 +1414,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindDoxygen) endif() + if(CMake_TEST_FindEXPAT) + add_subdirectory(FindEXPAT) + endif() + + if(CMake_TEST_FindFreetype) + add_subdirectory(FindFreetype) + endif() + if(CMake_TEST_FindGSL) add_subdirectory(FindGSL) endif() @@ -1447,6 +1475,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindPNG) endif() + if(CMake_TEST_FindPatch) + add_subdirectory(FindPatch) + endif() + if(CMake_TEST_FindProtobuf) add_subdirectory(FindProtobuf) endif() @@ -2082,7 +2114,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]") foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm) get_filename_component(r "${reg_${reg}}" ABSOLUTE) - if(IS_DIRECTORY "${r}") + if(IS_DIRECTORY "${r}" AND NOT "${r}" STREQUAL "/registry") set(${reg} 1) else() set(${reg} 0) @@ -2617,7 +2649,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA" DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage") add_test(NAME CTestGTMCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/MumpsCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestGTMCoverage PROPERTIES @@ -2635,7 +2667,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA" DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage") add_test(NAME CTestCacheCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestCacheCoverage PROPERTIES @@ -2653,7 +2685,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest" DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage") add_test(NAME CTestPythonCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/PythonCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestPythonCoverage PROPERTIES @@ -2671,7 +2703,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release file(COPY "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/src" DESTINATION "${CMake_BINARY_DIR}/Testing/CoberturaCoverage") add_test(NAME CTestCoberturaCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/CoberturaCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestCoberturaCoverage PROPERTIES @@ -2690,7 +2722,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release configure_file("${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml.in" "${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml") add_test(NAME CTestJacocoCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/JacocoCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestJacocoCoverage PROPERTIES @@ -2709,7 +2741,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release DESTINATION "${CMake_BINARY_DIR}/Testing/JavascriptCoverage" FILES_MATCHING PATTERN "*.js") add_test(NAME CTestJavascriptCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/JavascriptCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestJavascriptCoverage PROPERTIES @@ -2727,7 +2759,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html.in" "${CMake_BINARY_DIR}/Testing/DelphiCoverage/UTCovTest(UTCovTest.pas).html") add_test(NAME CTestDelphiCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/DelphiCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestDelphiCoverage PROPERTIES @@ -2785,13 +2817,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions) ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options) - if(CMake_TEST_SERVER_MODE) - # The cmake server-mode test requires python for a simple client. - find_package(PythonInterp QUIET) - if(PYTHON_EXECUTABLE) - set(Server_BUILD_OPTIONS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}) - ADD_TEST_MACRO(Server Server) - endif() + # The cmake server-mode test requires python for a simple client. + find_package(PythonInterp QUIET) + if(PYTHON_EXECUTABLE) + set(Server_BUILD_OPTIONS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}) + ADD_TEST_MACRO(Server Server) endif() configure_file( diff --git a/Tests/CMakeServerLib/CMakeLists.txt b/Tests/CMakeServerLib/CMakeLists.txt new file mode 100644 index 000000000..f5351fd12 --- /dev/null +++ b/Tests/CMakeServerLib/CMakeLists.txt @@ -0,0 +1,17 @@ +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMake_BINARY_DIR}/Source + ${CMake_SOURCE_DIR}/Source + ) + +set(CMakeServerLib_TESTS + testServerBuffering + ) + +create_test_sourcelist(CMakeLib_TEST_SRCS CMakeServerLibTests.cxx ${CMakeServerLib_TESTS}) +add_executable(CMakeServerLibTests ${CMakeLib_TEST_SRCS}) +target_link_libraries(CMakeServerLibTests CMakeLib CMakeServerLib) + +foreach(test ${CMakeServerLib_TESTS}) + add_test(CMakeServerLib.${test} CMakeServerLibTests ${test} ${${test}_ARGS}) +endforeach() diff --git a/Tests/CMakeServerLib/testServerBuffering.cpp b/Tests/CMakeServerLib/testServerBuffering.cpp new file mode 100644 index 000000000..97be89191 --- /dev/null +++ b/Tests/CMakeServerLib/testServerBuffering.cpp @@ -0,0 +1,86 @@ +#include "cmConnection.h" +#include "cmServerConnection.h" +#include <iostream> +#include <stddef.h> +#include <string> +#include <vector> + +void print_error(const std::vector<std::string>& input, + const std::vector<std::string>& output) +{ + std::cerr << "Responses don't equal input messages input." << std::endl; + std::cerr << "Responses: " << std::endl; + + for (auto& msg : output) { + std::cerr << "'" << msg << "'" << std::endl; + } + + std::cerr << "Input messages" << std::endl; + for (auto& msg : input) { + std::cerr << "'" << msg << "'" << std::endl; + } +} + +std::string trim_newline(const std::string& _buffer) +{ + auto buffer = _buffer; + while (!buffer.empty() && (buffer.back() == '\n' || buffer.back() == '\r')) { + buffer.pop_back(); + } + return buffer; +} + +int testServerBuffering(int, char** const) +{ + std::vector<std::string> messages = { + "{ \"test\": 10}", "{ \"test\": { \"test2\": false} }", + "{ \"test\": [1, 2, 3] }", + "{ \"a\": { \"1\": {}, \n\n\n \"2\":[] \t\t\t\t}}" + }; + + std::string fullMessage; + for (auto& msg : messages) { + fullMessage += "[== \"CMake Server\" ==[\n"; + fullMessage += msg; + fullMessage += "\n]== \"CMake Server\" ==]\n"; + } + + // The buffering strategy should cope with any fragmentation, including + // just getting the characters one at a time. + auto bufferingStrategy = + std::unique_ptr<cmConnectionBufferStrategy>(new cmServerBufferStrategy); + std::vector<std::string> response; + std::string rawBuffer; + for (size_t i = 0; i < fullMessage.size(); i++) { + rawBuffer += fullMessage[i]; + std::string packet = bufferingStrategy->BufferMessage(rawBuffer); + do { + if (!packet.empty() && packet != "\r\n") { + response.push_back(trim_newline(packet)); + } + packet = bufferingStrategy->BufferMessage(rawBuffer); + } while (!packet.empty()); + } + + if (response != messages) { + print_error(messages, response); + return 1; + } + + // We should also be able to deal with getting a bunch at once + response.clear(); + std::string packet = bufferingStrategy->BufferMessage(fullMessage); + do { + if (!packet.empty() && packet != "\r\n") { + response.push_back(trim_newline(packet)); + } + packet = bufferingStrategy->BufferMessage(fullMessage); + } while (!packet.empty()); + + if (response != messages) { + print_error(messages, response); + return 1; + } + + return 0; +} diff --git a/Tests/CMakeTests/.gitattributes b/Tests/CMakeTests/.gitattributes deleted file mode 100644 index c34e350e5..000000000 --- a/Tests/CMakeTests/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -File-HASH-Input.txt crlf=input diff --git a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in index 3294a2f0d..a3c2b055a 100644 --- a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in +++ b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in @@ -22,6 +22,25 @@ try_and_print(TOTAL_VIRTUAL_MEMORY) try_and_print(AVAILABLE_VIRTUAL_MEMORY) try_and_print(TOTAL_PHYSICAL_MEMORY) try_and_print(AVAILABLE_PHYSICAL_MEMORY) +try_and_print(IS_64BIT) +try_and_print(HAS_FPU) +try_and_print(HAS_MMX) +try_and_print(HAS_MMX_PLUS) +try_and_print(HAS_SSE) +try_and_print(HAS_SSE2) +try_and_print(HAS_SSE_FP) +try_and_print(HAS_SSE_MMX) +try_and_print(HAS_AMD_3DNOW) +try_and_print(HAS_AMD_3DNOW_PLUS) +try_and_print(HAS_IA64) +try_and_print(HAS_SERIAL_NUMBER) +try_and_print(PROCESSOR_SERIAL_NUMBER) +try_and_print(PROCESSOR_NAME) +try_and_print(PROCESSOR_DESCRIPTION) +try_and_print(OS_NAME) +try_and_print(OS_RELEASE) +try_and_print(OS_VERSION) +try_and_print(OS_PLATFORM) include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") diff --git a/Tests/CMakeTests/PushCheckStateTest.cmake.in b/Tests/CMakeTests/PushCheckStateTest.cmake.in index b4c48f4f4..cbd879def 100644 --- a/Tests/CMakeTests/PushCheckStateTest.cmake.in +++ b/Tests/CMakeTests/PushCheckStateTest.cmake.in @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.8) include(CMakePushCheckState) set(CMAKE_EXTRA_INCLUDE_FILES file1) @@ -26,6 +27,27 @@ set(CMAKE_REQUIRED_LIBRARIES lib3) set(CMAKE_REQUIRED_FLAGS flag3) set(CMAKE_REQUIRED_QUIET 3) +cmake_push_check_state(RESET) + +foreach(pair IN ITEMS + EXTRA_INCLUDE_FILES| + REQUIRED_INCLUDES| + REQUIRED_DEFINITIONS| + REQUIRED_LIBRARIES| + REQUIRED_FLAGS| + REQUIRED_QUIET| + ) + string(REPLACE "|" ";" pair "${pair}") + list(GET pair 0 var) + list(GET pair 1 expected) + if (NOT "${CMAKE_${var}}" STREQUAL "${expected}") + set(fatal TRUE) + message("ERROR: CMAKE_${var} is \"${CMAKE_${var}}\" (expected \"${expected}\")" ) + endif() +endforeach() + +cmake_pop_check_state() + cmake_pop_check_state() foreach(pair IN ITEMS diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake index 70d6edf49..73fd0abe2 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake index 415d5360a..81dbbc515 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) set(config_verbose -V) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake index 337cc1675..ad52f56b7 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake index 35ca74cdd..af27c5183 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake @@ -7,7 +7,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake index f1391cd73..1fe9258b9 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake @@ -5,7 +5,7 @@ endif() include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # TODO: currently debian doens't produce lower cased names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake index fcfc7eaee..e57488cbb 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake @@ -9,7 +9,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # requirements # debian now produces lower case names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake index 351bf2148..5ee057a3d 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) set(config_verbose -V) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake index c97ecb019..13a626a45 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake @@ -5,7 +5,7 @@ endif() include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # TODO: currently debian doens't produce lower cased names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2_*.deb") set(expected_count 1) set(actual_output) diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index a5b38fdb6..2c3a8494a 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -60,7 +60,7 @@ elseif (CPackGen MATCHES "RPM") set(expected_count 1) endif () elseif (CPackGen MATCHES "DEB") - set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2-1_*.deb") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2_*.deb") if (${CPackComponentWay} STREQUAL "default") set(expected_count 1) elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") diff --git a/Tests/CompileFeatures/.gitattributes b/Tests/CompileFeatures/.gitattributes deleted file mode 100644 index 83da28dac..000000000 --- a/Tests/CompileFeatures/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Do not format a source containing C++11 '>>' syntax as C++98. -cxx_right_angle_brackets.cpp -format.clang-format diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 4a5558d48..b560acd7e 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -428,6 +428,14 @@ else() HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> ) + if (CMAKE_CXX_STANDARD_DEFAULT) + target_compile_definitions(CompileFeaturesGenex PRIVATE + TEST_CXX_STD + HAVE_CXX_STD_11=$<COMPILE_FEATURES:cxx_std_11> + HAVE_CXX_STD_14=$<COMPILE_FEATURES:cxx_std_14> + HAVE_CXX_STD_17=$<COMPILE_FEATURES:cxx_std_17> + ) + endif() add_executable(CompileFeaturesGenex2 genex_test.cpp) target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_std_11) diff --git a/Tests/CompileFeatures/cxx_digit_separators.cpp b/Tests/CompileFeatures/cxx_digit_separators.cpp index a40ac0aac..abcd1c8fa 100644 --- a/Tests/CompileFeatures/cxx_digit_separators.cpp +++ b/Tests/CompileFeatures/cxx_digit_separators.cpp @@ -1,5 +1,6 @@ int someFunc() { - int one_thousand = 1'000; return one_thousand - 1000; + int one_thousand = 1'000; + return one_thousand - 1000; } diff --git a/Tests/CompileFeatures/cxx_raw_string_literals.cpp b/Tests/CompileFeatures/cxx_raw_string_literals.cpp index ea4d2312c..0f83a7c9a 100644 --- a/Tests/CompileFeatures/cxx_raw_string_literals.cpp +++ b/Tests/CompileFeatures/cxx_raw_string_literals.cpp @@ -1,7 +1,7 @@ void someFunc() { -const char p[] = R"(a\ + const char p[] = R"(a\ b c)"; } diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp index 3dc25704d..695123052 100644 --- a/Tests/CompileFeatures/cxx_variadic_templates.cpp +++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp @@ -35,7 +35,7 @@ struct eval }; template <template <typename...> class T, typename... U> -struct eval<T<U...> > +struct eval<T<U...>> { enum { @@ -62,11 +62,11 @@ struct D // Note: This test assumes that a compiler supporting this feature // supports static_assert. Add a workaround if that does not hold. -static_assert(eval<A<> >::Matched, "A Matches"); -static_assert(eval<A<int> >::Matched, "A Matches"); -static_assert(eval<A<int, char> >::Matched, "A Matches"); -static_assert(eval<B<int> >::Matched, "B Matches"); -static_assert(eval<C<int, char> >::Matched, "C Matches"); -static_assert(eval<D<int, char> >::Matched, "D Matches"); -static_assert(eval<D<int, char, bool> >::Matched, "D Matches"); -static_assert(eval<D<int, char, bool, double> >::Matched, "D Matches"); +static_assert(eval<A<>>::Matched, "A Matches"); +static_assert(eval<A<int>>::Matched, "A Matches"); +static_assert(eval<A<int, char>>::Matched, "A Matches"); +static_assert(eval<B<int>>::Matched, "B Matches"); +static_assert(eval<C<int, char>>::Matched, "C Matches"); +static_assert(eval<D<int, char>>::Matched, "D Matches"); +static_assert(eval<D<int, char, bool>>::Matched, "D Matches"); +static_assert(eval<D<int, char, bool, double>>::Matched, "D Matches"); diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index 9b65b424a..0de11255f 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -2,25 +2,30 @@ template <long l> struct Outputter; +#if defined(_MSC_VER) && defined(_MSVC_LANG) +#define CXX_STD _MSVC_LANG +#else +#define CXX_STD __cplusplus +#endif + #if DEFAULT_CXX17 -#if __cplusplus <= 201402L -Outputter<__cplusplus> o; +#if CXX_STD <= 201402L +Outputter<CXX_STD> o; #endif #elif DEFAULT_CXX14 -#if __cplusplus != 201402L -Outputter<__cplusplus> o; +#if CXX_STD != 201402L +Outputter<CXX_STD> o; #endif #elif DEFAULT_CXX11 -#if __cplusplus != 201103L -Outputter<__cplusplus> o; +#if CXX_STD != 201103L +Outputter<CXX_STD> o; #endif #else #if !DEFAULT_CXX98 #error Buildsystem error #endif -#if __cplusplus != 199711L && __cplusplus != 1 && \ - !defined(__GXX_EXPERIMENTAL_CXX0X__) -Outputter<__cplusplus> o; +#if CXX_STD != 199711L && CXX_STD != 1 && !defined(__GXX_EXPERIMENTAL_CXX0X__) +Outputter<CXX_STD> o; #endif #endif diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index 5ae8a7880..5303e738e 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -11,6 +11,18 @@ #error EXPECT_OVERRIDE_CONTROL not defined #endif +#ifdef TEST_CXX_STD +#if !HAVE_CXX_STD_11 +#error HAVE_CXX_STD_11 is false with CXX_STANDARD == 11 +#endif +#if HAVE_CXX_STD_14 +#error HAVE_CXX_STD_14 is true with CXX_STANDARD == 11 +#endif +#if HAVE_CXX_STD_17 +#error HAVE_CXX_STD_17 is true with CXX_STANDARD == 11 +#endif +#endif + #if !HAVE_OVERRIDE_CONTROL #if EXPECT_OVERRIDE_CONTROL #error "Expect override control feature" diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 075faa768..2e4175442 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -356,6 +356,8 @@ endwhile() set(SHOULD_BE_ZERO ) set(SHOULD_BE_ONE 1) +set(SHOULD_BE_ZERO_AND_INDENTED ) +set(SHOULD_BE_ONE_AND_INDENTED 1) # test elseif functionality, the mess below tries to catch problem # of clauses being executed early or late etc @@ -438,13 +440,6 @@ set(CMAKE_CXX_STANDARD 98) # set(CMAKE_CXX_EXTENSIONS TRUE) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 3b09229ba..ca39870f2 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -261,6 +261,12 @@ int main() cmPassed("ONE_VAR is defined."); #endif +#ifndef ONE_VAR_AND_INDENTED + cmFailed("cmakedefine is broken, ONE_VAR_AND_INDENTED is not defined."); +#else + cmPassed("ONE_VAR_AND_INDENTED is defined."); +#endif + #ifndef ONE_VAR_IS_DEFINED cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, " "ONE_VAR_IS_DEFINED is not defined."); @@ -274,6 +280,12 @@ int main() cmPassed("ZERO_VAR is not defined."); #endif +#ifdef ZERO_VAR_AND_INDENTED + cmFailed("cmakedefine is broken, ZERO_VAR_AND_INDENTED is defined."); +#else + cmPassed("ZERO_VAR_AND_INDENTED is not defined."); +#endif + #ifndef STRING_VAR cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined."); #else @@ -1030,6 +1042,16 @@ int main() } else { cmFailed("cmakedefine01 is not working for 1"); } + if (SHOULD_BE_ZERO_AND_INDENTED == 0) { + cmPassed("cmakedefine01 is working for 0 and indented"); + } else { + cmFailed("cmakedefine01 is not working for 0 and indented"); + } + if (SHOULD_BE_ONE_AND_INDENTED == 1) { + cmPassed("cmakedefine01 is working for 1 and indented"); + } else { + cmFailed("cmakedefine01 is not working for 1 and indented"); + } #ifdef FORCE_TEST cmFailed("CMake SET CACHE FORCE"); #else diff --git a/Tests/Complex/VarTests.cmake b/Tests/Complex/VarTests.cmake index 8be59be5e..9761986ab 100644 --- a/Tests/Complex/VarTests.cmake +++ b/Tests/Complex/VarTests.cmake @@ -2,6 +2,7 @@ # Test SET # set (ZERO_VAR 0) +set (ZERO_VAR_AND_INDENTED 0) set (ZERO_VAR2 0) if(ZERO_VAR) @@ -11,6 +12,7 @@ else() endif() set(ONE_VAR 1) +set(ONE_VAR_AND_INDENTED 1) set(ONE_VAR2 1) set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable") diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in index d7424b184..72317bcc8 100644 --- a/Tests/Complex/cmTestConfigure.h.in +++ b/Tests/Complex/cmTestConfigure.h.in @@ -1,8 +1,10 @@ // Test SET, VARIABLE_REQUIRES #cmakedefine ONE_VAR +# cmakedefine ONE_VAR_AND_INDENTED #cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ZERO_VAR +# cmakedefine ZERO_VAR_AND_INDENTED #define STRING_VAR "${STRING_VAR}" @@ -32,6 +34,8 @@ #cmakedefine01 SHOULD_BE_ZERO #cmakedefine01 SHOULD_BE_ONE +# cmakedefine01 SHOULD_BE_ZERO_AND_INDENTED +# cmakedefine01 SHOULD_BE_ONE_AND_INDENTED // Needed to check for files #define BINARY_DIR "${Complex_BINARY_DIR}" diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index 1b833b241..628cd4ec3 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -313,6 +313,8 @@ endwhile() set(SHOULD_BE_ZERO ) set(SHOULD_BE_ONE 1) +set(SHOULD_BE_ZERO_AND_INDENTED ) +set(SHOULD_BE_ONE_AND_INDENTED 1) # test elseif functionality, the mess below tries to catch problem # of clauses being executed early or late etc @@ -395,13 +397,6 @@ set(CMAKE_CXX_STANDARD 98) # set(CMAKE_CXX_EXTENSIONS TRUE) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 9e4eaadf7..9b94962e1 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -261,6 +261,12 @@ int main() cmPassed("ONE_VAR is defined."); #endif +#ifndef ONE_VAR_AND_INDENTED + cmFailed("cmakedefine is broken, ONE_VAR_AND_INDENTED is not defined."); +#else + cmPassed("ONE_VAR_AND_INDENTED is defined."); +#endif + #ifndef ONE_VAR_IS_DEFINED cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, " "ONE_VAR_IS_DEFINED is not defined."); @@ -274,6 +280,12 @@ int main() cmPassed("ZERO_VAR is not defined."); #endif +#ifdef ZERO_VAR_AND_INDENTED + cmFailed("cmakedefine is broken, ZERO_VAR_AND_INDENTED is defined."); +#else + cmPassed("ZERO_VAR_AND_INDENTED is not defined."); +#endif + #ifndef STRING_VAR cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined."); #else @@ -1030,6 +1042,16 @@ int main() } else { cmFailed("cmakedefine01 is not working for 1"); } + if (SHOULD_BE_ZERO_AND_INDENTED == 0) { + cmPassed("cmakedefine01 is working for 0 and indented"); + } else { + cmFailed("cmakedefine01 is not working for 0 and indented"); + } + if (SHOULD_BE_ONE_AND_INDENTED == 1) { + cmPassed("cmakedefine01 is working for 1 and indented"); + } else { + cmFailed("cmakedefine01 is not working for 1 and indented"); + } #ifdef FORCE_TEST cmFailed("CMake SET CACHE FORCE"); #else diff --git a/Tests/ComplexOneConfig/VarTests.cmake b/Tests/ComplexOneConfig/VarTests.cmake index 7dd851974..42afd19ea 100644 --- a/Tests/ComplexOneConfig/VarTests.cmake +++ b/Tests/ComplexOneConfig/VarTests.cmake @@ -2,6 +2,7 @@ # Test SET # set (ZERO_VAR 0) +set (ZERO_VAR_AND_INDENTED 0) set (ZERO_VAR2 0) if(ZERO_VAR) @@ -11,6 +12,7 @@ else() endif() set(ONE_VAR 1) +set(ONE_VAR_AND_INDENTED 1) set(ONE_VAR2 1) set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable") diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in index d7424b184..72317bcc8 100644 --- a/Tests/ComplexOneConfig/cmTestConfigure.h.in +++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in @@ -1,8 +1,10 @@ // Test SET, VARIABLE_REQUIRES #cmakedefine ONE_VAR +# cmakedefine ONE_VAR_AND_INDENTED #cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ZERO_VAR +# cmakedefine ZERO_VAR_AND_INDENTED #define STRING_VAR "${STRING_VAR}" @@ -32,6 +34,8 @@ #cmakedefine01 SHOULD_BE_ZERO #cmakedefine01 SHOULD_BE_ONE +# cmakedefine01 SHOULD_BE_ZERO_AND_INDENTED +# cmakedefine01 SHOULD_BE_ONE_AND_INDENTED // Needed to check for files #define BINARY_DIR "${Complex_BINARY_DIR}" diff --git a/Tests/Cuda/.clang-format b/Tests/Cuda/.clang-format deleted file mode 100644 index a77589a2d..000000000 --- a/Tests/Cuda/.clang-format +++ /dev/null @@ -1,9 +0,0 @@ ---- -# This configuration requires clang-format 3.8 or higher. -BasedOnStyle: Mozilla -AlignOperands: false -AlwaysBreakAfterReturnType: None -AlwaysBreakAfterDefinitionReturnType: None -ColumnLimit: 79 -Standard: Cpp11 -... diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt index 450ef487c..a7137e3ae 100644 --- a/Tests/Cuda/Complex/CMakeLists.txt +++ b/Tests/Cuda/Complex/CMakeLists.txt @@ -42,7 +42,6 @@ add_executable(CudaComplex main.cpp) target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib) if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaComplex PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaComplex PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/Cuda/ObjectLibrary/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/CMakeLists.txt index 1d93be732..276dc9225 100644 --- a/Tests/Cuda/ObjectLibrary/CMakeLists.txt +++ b/Tests/Cuda/ObjectLibrary/CMakeLists.txt @@ -10,8 +10,8 @@ add_library(CudaMixedObjectLib OBJECT static.cu static.cpp) add_executable(CudaObjectLibrary main.cpp $<TARGET_OBJECTS:CudaMixedObjectLib>) + if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaObjectLibrary PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaObjectLibrary PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt index 1f25ab43e..831ce12c9 100644 --- a/Tests/Cuda/WithC/CMakeLists.txt +++ b/Tests/Cuda/WithC/CMakeLists.txt @@ -6,7 +6,6 @@ string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") add_executable(CudaWithC main.c cuda.cu) if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaWithC PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaWithC PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/CudaOnly/.clang-format b/Tests/CudaOnly/.clang-format deleted file mode 100644 index a77589a2d..000000000 --- a/Tests/CudaOnly/.clang-format +++ /dev/null @@ -1,9 +0,0 @@ ---- -# This configuration requires clang-format 3.8 or higher. -BasedOnStyle: Mozilla -AlignOperands: false -AlwaysBreakAfterReturnType: None -AlwaysBreakAfterDefinitionReturnType: None -ColumnLimit: 79 -Standard: Cpp11 -... diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt index 10249c614..65d524339 100644 --- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt +++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt @@ -67,9 +67,8 @@ target_compile_definitions(CudaOnlyExportPTX PRIVATE "CONFIG_TYPE=gen_$<LOWER_CASE:$<CONFIG>>") if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaOnlyExportPTX PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyExportPTX PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() #Verify that we can install object targets properly diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index b96bb984b..8d6551b7c 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -46,7 +46,6 @@ add_executable(CudaOnlyResolveDeviceSymbols main.cu) target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib) if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyResolveDeviceSymbols PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index 3d4a17073..7ef626f67 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -48,8 +48,7 @@ if (CMAKE_GENERATOR MATCHES "^Visual Studio") PROPERTIES CUDA_SEPARABLE_COMPILATION ON) endif() -if (APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaOnlySeparateCompilation PRIVATE -Wl,-rpath,/usr/local/cuda/lib) +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index e25f141ea..9b823667f 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -4,7 +4,11 @@ project (CudaOnlyWithDefs CUDA) #verify that we can pass explicit cuda arch flags string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") -set(debug_compile_flags --generate-code arch=compute_20,code=sm_20) +if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 9) + set(debug_compile_flags --generate-code arch=compute_32,code=sm_32) +else() + set(debug_compile_flags --generate-code arch=compute_20,code=sm_20) +endif() if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC") list(APPEND debug_compile_flags -Xcompiler=-WX) else() @@ -37,8 +41,7 @@ target_compile_definitions(CudaOnlyWithDefs $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>> ) -#we need to add an rpath for the cuda library so that everything -#loads properly on the mac -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - set_target_properties(CudaOnlyWithDefs PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/FindEXPAT/CMakeLists.txt b/Tests/FindEXPAT/CMakeLists.txt new file mode 100644 index 000000000..a74174a30 --- /dev/null +++ b/Tests/FindEXPAT/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindEXPAT.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindEXPAT/Test" + "${CMake_BINARY_DIR}/Tests/FindEXPAT/Test" + ${build_generator_args} + --build-project TestFindEXPAT + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindEXPAT/Test/CMakeLists.txt b/Tests/FindEXPAT/Test/CMakeLists.txt new file mode 100644 index 000000000..5681f7471 --- /dev/null +++ b/Tests/FindEXPAT/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.9) +project(TestFindEXPAT C) +include(CTest) + +find_package(EXPAT REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_EXPAT_VERSION="${EXPAT_VERSION_STRING}") + +add_executable(testexpat_tgt main.c) +target_link_libraries(testexpat_tgt EXPAT::EXPAT) +add_test(NAME testexpat_tgt COMMAND testexpat_tgt) + +add_executable(testexpat_var main.c) +target_include_directories(testexpat_var PRIVATE ${EXPAT_INCLUDE_DIRS}) +target_link_libraries(testexpat_var PRIVATE ${EXPAT_LIBRARIES}) +add_test(NAME testexpat_var COMMAND testexpat_var) diff --git a/Tests/FindEXPAT/Test/main.c b/Tests/FindEXPAT/Test/main.c new file mode 100644 index 000000000..94ee3ef24 --- /dev/null +++ b/Tests/FindEXPAT/Test/main.c @@ -0,0 +1,21 @@ +#include <expat.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main() +{ + XML_Expat_Version expat_version; + char expat_version_string[16]; + + expat_version = XML_ExpatVersionInfo(); + + snprintf(expat_version_string, 16, "%i.%i.%i", expat_version.major, + expat_version.minor, expat_version.micro); + + if (strcmp(expat_version_string, CMAKE_EXPECTED_EXPAT_VERSION) != 0) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/Tests/FindFreetype/CMakeLists.txt b/Tests/FindFreetype/CMakeLists.txt new file mode 100644 index 000000000..490c25bd6 --- /dev/null +++ b/Tests/FindFreetype/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindFreetype.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindFreetype/Test" + "${CMake_BINARY_DIR}/Tests/FindFreetype/Test" + ${build_generator_args} + --build-project TestFindFreetype + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindFreetype/Test/CMakeLists.txt b/Tests/FindFreetype/Test/CMakeLists.txt new file mode 100644 index 000000000..bc869a13f --- /dev/null +++ b/Tests/FindFreetype/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.9) +project(TestFindFreetype C) +include(CTest) + +find_package(Freetype REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_FREETYPE_VERSION="${FREETYPE_VERSION_STRING}") + +add_executable(testfreetype_tgt main.c) +target_link_libraries(testfreetype_tgt Freetype::Freetype) +add_test(NAME testfreetype_tgt COMMAND testfreetype_tgt) + +add_executable(testfreetype_var main.c) +target_include_directories(testfreetype_var PRIVATE ${FREETYPE_INCLUDE_DIRS}) +target_link_libraries(testfreetype_var PRIVATE ${FREETYPE_LIBRARIES}) +add_test(NAME testfreetype_var COMMAND testfreetype_var) diff --git a/Tests/FindFreetype/Test/main.c b/Tests/FindFreetype/Test/main.c new file mode 100644 index 000000000..bb838a5ce --- /dev/null +++ b/Tests/FindFreetype/Test/main.c @@ -0,0 +1,34 @@ +#include <ft2build.h> +#include <stdlib.h> +#include FT_FREETYPE_H +#include <string.h> + +int main() +{ + FT_Library library; + FT_Error error; + + error = FT_Init_FreeType(&library); + if (error) { + return EXIT_FAILURE; + } + + FT_Int major = 0; + FT_Int minor = 0; + FT_Int patch = 0; + FT_Library_Version(library, &major, &minor, &patch); + + char ft_version_string[16]; + snprintf(ft_version_string, 16, "%i.%i.%i", major, minor, patch); + + if (strcmp(ft_version_string, CMAKE_EXPECTED_FREETYPE_VERSION) != 0) { + return EXIT_FAILURE; + } + + error = FT_Done_FreeType(library); + if (error) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/Tests/FindGTest/Test/main.cxx b/Tests/FindGTest/Test/main.cxx index 0572a5ddc..19d29675b 100644 --- a/Tests/FindGTest/Test/main.cxx +++ b/Tests/FindGTest/Test/main.cxx @@ -2,5 +2,7 @@ TEST(FindCMake, LinksAndRuns) { + using namespace testing; + EXPECT_FALSE(GTEST_FLAG(list_tests)); ASSERT_TRUE(true); } diff --git a/Tests/FindMPI/Test/CMakeLists.txt b/Tests/FindMPI/Test/CMakeLists.txt index 3910c254f..efe8c6261 100644 --- a/Tests/FindMPI/Test/CMakeLists.txt +++ b/Tests/FindMPI/Test/CMakeLists.txt @@ -20,12 +20,17 @@ foreach(c C CXX Fortran) endif() endforeach() +set(MPI_CXX_SKIP_MPICXX TRUE) +set(MPI_CXX_VALIDATE_SKIP_MPICXX TRUE) find_package(MPI REQUIRED) foreach(c C CXX Fortran) if(NOT "${MPI_TEST_${c}}") continue() endif() + if(${c} STREQUAL CXX AND MPI_MPICXX_FOUND) + message(FATAL_ERROR "Could not suppress MPI-2 C++ bindings for this MPI.") + endif() source_code_mapper_helper(${c}) add_executable(test_tgt_${c} ${MPITEST_SOURCE_FILE}) target_link_libraries(test_tgt_${c} MPI::MPI_${c}) diff --git a/Tests/FindOpenGL/CMakeLists.txt b/Tests/FindOpenGL/CMakeLists.txt index 9aa3abafb..97c9e6052 100644 --- a/Tests/FindOpenGL/CMakeLists.txt +++ b/Tests/FindOpenGL/CMakeLists.txt @@ -1,3 +1,9 @@ +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMake_TEST_FindOpenGL_VND) + set(_vnd_testing TRUE) +else() + set(_vnd_testing FALSE) +endif() + add_test(NAME FindOpenGL.Test COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -6,5 +12,6 @@ add_test(NAME FindOpenGL.Test COMMAND ${build_generator_args} --build-project TestFindOpenGL --build-options ${build_options} + -DOpenGL_TEST_VND=${_vnd_testing} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) diff --git a/Tests/FindOpenGL/Test/CMakeLists.txt b/Tests/FindOpenGL/Test/CMakeLists.txt index cac342488..3b5ffeecd 100644 --- a/Tests/FindOpenGL/Test/CMakeLists.txt +++ b/Tests/FindOpenGL/Test/CMakeLists.txt @@ -1,14 +1,70 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.9) project(TestFindOpenGL C) include(CTest) find_package(OpenGL REQUIRED) +# import target for GLU add_executable(test_tgt main.c) target_link_libraries(test_tgt OpenGL::GLU) add_test(NAME test_tgt COMMAND test_tgt) +# OPENGL_LIBRARIES should be whatever libraries are needed to link. add_executable(test_var main.c) target_include_directories(test_var PRIVATE ${OPENGL_INGLUDE_DIRS}) target_link_libraries(test_var PRIVATE ${OPENGL_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +# VND support adds an ::OpenGL import target. This can be used for OpenGL-only +# code (code that does not manipulate contexts, like our 'main.c'). Without +# VND, ::GL can be used for both context and non-context OpenGL code. +if(OpenGL_TEST_VND) + add_executable(test_comp_none main.c) + target_link_libraries(test_comp_none PRIVATE OpenGL::OpenGL) + add_test(NAME test_comp_none COMMAND test_comp_none) +else() + add_executable(test_comp_none main.c) + target_link_libraries(test_comp_none PRIVATE OpenGL::GL) + add_test(NAME test_comp_none COMMAND test_comp_none) +endif() + +# GLX +if(OpenGL_TEST_VND) + find_package(OpenGL REQUIRED COMPONENTS OpenGL GLX) + add_executable(test_comp_glx main.c) + target_link_libraries(test_comp_glx PRIVATE OpenGL::OpenGL OpenGL::GLX) + add_test(NAME test_comp_glx COMMAND test_comp_glx) +else() + # non-VND systems won't have it, but an optional search for GLX should still + # be okay. + find_package(OpenGL COMPONENTS GLX) + add_executable(test_comp_glx_novnd main.c) + target_link_libraries(test_comp_glx_novnd PRIVATE OpenGL::GL) + add_test(NAME test_comp_glx_novnd COMMAND test_comp_glx_novnd) +endif() + +# EGL is only available on Linux+GLVND at present. +if(OpenGL_TEST_VND) + find_package(OpenGL COMPONENTS OpenGL EGL) + if(OpenGL_EGL_FOUND) + add_executable(test_comp_egl main.c) + target_link_libraries(test_comp_egl PRIVATE OpenGL::OpenGL OpenGL::EGL) + add_test(NAME test_comp_egl COMMAND test_comp_egl) + # EGL-only code should not link to GLX. + execute_process(COMMAND ldd test_comp_egl + OUTPUT_VARIABLE LDD_OUT + ERROR_VARIABLE LDD_ERR) + if("${LDD_OUT}" MATCHES "GLX") + message(FATAL_ERROR "EGL-only code links to GLX!") + endif() + endif() + + # all three COMPONENTS together. + find_package(OpenGL COMPONENTS OpenGL EGL GLX) + if(OpenGL_EGL_FOUND AND OpenGL_GLX_FOUND) + add_executable(test_comp_both main.c) + target_link_libraries(test_comp_both PRIVATE OpenGL::OpenGL OpenGL::EGL + OpenGL::GLX) + add_test(NAME test_comp_both COMMAND test_comp_both) + endif() +endif() diff --git a/Tests/FindPatch/CMakeLists.txt b/Tests/FindPatch/CMakeLists.txt new file mode 100644 index 000000000..541f5bd15 --- /dev/null +++ b/Tests/FindPatch/CMakeLists.txt @@ -0,0 +1,8 @@ +add_test(NAME FindPatch.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPatch/Test" + "${CMake_BINARY_DIR}/Tests/FindPatch/Test" + ${build_generator_args} + --build-options ${build_options} +) diff --git a/Tests/FindPatch/Test/CMakeLists.txt b/Tests/FindPatch/Test/CMakeLists.txt new file mode 100644 index 000000000..f4cd621d1 --- /dev/null +++ b/Tests/FindPatch/Test/CMakeLists.txt @@ -0,0 +1,77 @@ +cmake_minimum_required(VERSION 3.8) +project(TestFindPatch VERSION 1.0 LANGUAGES NONE) + +macro(_check) + if(NOT EXISTS "${Patch_EXECUTABLE}") + message(FATAL_ERROR "Failed to lookup Patch_EXECUTABLE [${Patch_EXECUTABLE}]") + endif() + + if(NOT DEFINED PATCH_FOUND) + message(FATAL_ERROR "Variable PATCH_FOUND is not defined") + endif() + + # Is import target available ? + if(NOT TARGET Patch::patch) + message(FATAL_ERROR "Target Patch::patch is not defined") + endif() + + # Check Patch::patch imported location + get_property(_imported_location TARGET Patch::patch PROPERTY IMPORTED_LOCATION) + if(NOT "${Patch_EXECUTABLE}" STREQUAL "${_imported_location}") + message(FATAL_ERROR "\ +Patch_EXECUTABLE is expected to be equal to Patch::patch IMPORTED_LOCATION + Patch_EXECUTABLE [${Patch_EXECUTABLE}] + Patch::patch IMPORTED_LOCATION [${_imported_location}] +") + endif() + +endmacro() + +find_package(Patch REQUIRED) +_check() + +# Calling twice should not fail +find_package(Patch REQUIRED) +_check() + +add_custom_target(TestPatchVersion ALL + COMMAND ${Patch_EXECUTABLE} -v + ) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/QUOTE.txt.baseline" +[=[Because it's there. +- George Mallory, 1923 +]=] +) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/QUOTE.txt" "Because it's there.\n") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/quote-add-author.patch" +[=[diff --git a/QUOTE.txt b/QUOTE.txt +index b36681d..68059b3 100644 +--- a/QUOTE.txt ++++ b/QUOTE.txt +@@ -1 +1,2 @@ + Because it's there. ++- George Mallory +]=] +) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/quote-add-date.patch" +[=[diff --git a/QUOTE.txt b/QUOTE.txt +index 68059b3..c6f30c2 100644 +--- a/QUOTE.txt ++++ b/QUOTE.txt +@@ -1,2 +1,2 @@ + Because it's there. +-- George Mallory ++- George Mallory, 1923 +]=] +) + +add_custom_target(TestPatch ALL + COMMAND ${Patch_EXECUTABLE} -p1 -i quote-add-author.patch + COMMAND Patch::patch -p1 -i quote-add-date.patch + COMMAND ${CMAKE_COMMAND} -E compare_files QUOTE.txt QUOTE.txt.baseline + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) diff --git a/Tests/FindProtobuf/Test/CMakeLists.txt b/Tests/FindProtobuf/Test/CMakeLists.txt index 8b6e38a8e..bc89190b3 100644 --- a/Tests/FindProtobuf/Test/CMakeLists.txt +++ b/Tests/FindProtobuf/Test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.8) project(TestFindProtobuf CXX) include(CTest) @@ -30,3 +30,21 @@ add_executable(test_var_protoc main-protoc.cxx) target_include_directories(test_var_protoc PRIVATE ${Protobuf_INCLUDE_DIRS}) target_link_libraries(test_var_protoc PRIVATE ${Protobuf_PROTOC_LIBRARIES}) add_test(NAME test_var_protoc COMMAND test_var_protoc) + +add_test(NAME test_tgt_protoc_version COMMAND protobuf::protoc --version) + +set(Protobuf_IMPORT_DIRS ${Protobuf_INCLUDE_DIRS}) +PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER msgs/example.proto) +PROTOBUF_GENERATE_CPP(DESC_PROTO_SRC DESC_PROTO_HEADER DESCRIPTORS DESC_PROTO_DESC msgs/example_desc.proto) +add_library(msgs ${PROTO_SRC} ${PROTO_HEADER}) + +add_executable(test_generate main-generate.cxx ${PROTO_SRC}) +target_include_directories(test_generate PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(test_generate msgs ${Protobuf_LIBRARIES}) +add_test(NAME test_generate COMMAND test_generate) + +add_executable(test_desc main-desc.cxx ${DESC_PROTO_SRC}) +target_compile_features(test_desc PRIVATE cxx_std_11) +target_include_directories(test_desc PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(test_desc msgs ${Protobuf_LIBRARIES}) +add_test(NAME test_desc COMMAND test_desc ${DESC_PROTO_DESC}) diff --git a/Tests/FindProtobuf/Test/main-desc.cxx b/Tests/FindProtobuf/Test/main-desc.cxx new file mode 100644 index 000000000..a26e562d5 --- /dev/null +++ b/Tests/FindProtobuf/Test/main-desc.cxx @@ -0,0 +1,57 @@ +#include <fstream> +#include <google/protobuf/descriptor.h> +#include <google/protobuf/descriptor.pb.h> +#include <google/protobuf/dynamic_message.h> +#include <google/protobuf/text_format.h> +#include <iostream> +#include <string> + +int main(int argc, char* argv[]) +{ + std::ifstream fs; + fs.open(argv[1], std::ifstream::in); + google::protobuf::FileDescriptorSet file_descriptor_set; + file_descriptor_set.ParseFromIstream(&fs); + + const google::protobuf::DescriptorPool* compiled_pool = + google::protobuf::DescriptorPool::generated_pool(); + + if (compiled_pool == NULL) { + std::cerr << "compiled pool is NULL." << std::endl; + return 1; + } + + google::protobuf::DescriptorPool pool(compiled_pool); + google::protobuf::DynamicMessageFactory dynamic_message_factory(&pool); + + for (const google::protobuf::FileDescriptorProto& file_descriptor_proto : + file_descriptor_set.file()) { + const google::protobuf::FileDescriptor* file_descriptor = + pool.BuildFile(file_descriptor_proto); + if (file_descriptor == NULL) { + continue; + } + + const google::protobuf::Descriptor* descriptor = + pool.FindMessageTypeByName("example.msgs.ExampleDesc"); + + if (descriptor == NULL) { + continue; + } + + google::protobuf::Message* msg = + dynamic_message_factory.GetPrototype(descriptor)->New(); + std::string data = "data: 1"; + bool success = google::protobuf::TextFormat::ParseFromString(data, msg); + + if (success) { + return 0; + } else { + std::cerr << "Failed to parse message." << std::endl; + return 2; + } + } + + std::cerr << "No matching message found." << std::endl; + return 3; +} diff --git a/Tests/FindProtobuf/Test/main-generate.cxx b/Tests/FindProtobuf/Test/main-generate.cxx new file mode 100644 index 000000000..ca33a6856 --- /dev/null +++ b/Tests/FindProtobuf/Test/main-generate.cxx @@ -0,0 +1,8 @@ +#include <example.pb.h> + +int main() +{ + example::msgs::Example msg; + + return 0; +} diff --git a/Tests/FindProtobuf/Test/msgs/example.proto b/Tests/FindProtobuf/Test/msgs/example.proto new file mode 100644 index 000000000..d27262e1d --- /dev/null +++ b/Tests/FindProtobuf/Test/msgs/example.proto @@ -0,0 +1,6 @@ +syntax = "proto2"; +package example.msgs; + +message Example { + required int32 data = 1; +} diff --git a/Tests/FindProtobuf/Test/msgs/example_desc.proto b/Tests/FindProtobuf/Test/msgs/example_desc.proto new file mode 100644 index 000000000..44544736d --- /dev/null +++ b/Tests/FindProtobuf/Test/msgs/example_desc.proto @@ -0,0 +1,10 @@ +syntax = "proto2"; +package example.msgs; + +import "google/protobuf/descriptor.proto"; + +message ExampleDesc { + required int32 data = 1; + + optional google.protobuf.FileDescriptorSet desc = 2; +} diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 8ac341912..83fd11d65 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -258,11 +258,13 @@ add_custom_target(check-part4 ALL VERBATIM ) +add_executable(srcgenex srcgenex.c) +set_property(SOURCE srcgenex.c PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>") + #----------------------------------------------------------------------------- # Cover test properties with generator expressions. add_executable(echo echo.c) add_executable(pwd pwd.c) -set_property(SOURCE echo.c PROPERTY COMPILE_FLAGS $<1:-DSRC_GENEX_WORKS>) add_test(NAME echo-configuration COMMAND echo $<CONFIGURATION>) set_property(TEST echo-configuration PROPERTY diff --git a/Tests/GeneratorExpression/echo.c b/Tests/GeneratorExpression/echo.c index 41596a21d..06b0844b3 100644 --- a/Tests/GeneratorExpression/echo.c +++ b/Tests/GeneratorExpression/echo.c @@ -3,9 +3,6 @@ int main(int argc, char* argv[]) { -#ifndef SRC_GENEX_WORKS -#error SRC_GENEX_WORKS not defined -#endif printf("%s\n", argv[1]); return EXIT_SUCCESS; } diff --git a/Tests/GeneratorExpression/srcgenex.c b/Tests/GeneratorExpression/srcgenex.c new file mode 100644 index 000000000..56d3c3f95 --- /dev/null +++ b/Tests/GeneratorExpression/srcgenex.c @@ -0,0 +1,12 @@ +int srcgenex(void) +{ + return 0; +} + +int main(int argc, char* argv[]) +{ +#ifndef NAME +#error NAME not defined +#endif + return NAME(); +} diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index 33c4b9073..3db210a5d 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -64,7 +64,6 @@ target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTO add_executable(exec_whitelist dummy.cpp) target_link_libraries(exec_whitelist iface_whitelist) -set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1) add_library(iface_imported INTERFACE IMPORTED) set_property(TARGET iface_imported PROPERTY INTERFACE_COMPILE_DEFINITIONS diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt index 03a3b4942..cfaebade4 100644 --- a/Tests/LoadCommand/CMakeLists.txt +++ b/Tests/LoadCommand/CMakeLists.txt @@ -22,13 +22,6 @@ else() ${LoadCommand_SOURCE_DIR}/CMakeCommands CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO OUTPUT_VARIABLE OUTPUT ) -# do another TRY_COMPILE to get around make -# problem on hp - try_compile(COMPILE_OK - ${LoadCommand_BINARY_DIR}/CMakeCommands - ${LoadCommand_SOURCE_DIR}/CMakeCommands - CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO - OUTPUT_VARIABLE OUTPUT ) endif() message("Output from try compile: ${OUTPUT}") diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt index 6affd343f..65de04230 100644 --- a/Tests/LoadCommandOneConfig/CMakeLists.txt +++ b/Tests/LoadCommandOneConfig/CMakeLists.txt @@ -28,13 +28,6 @@ else() ${LoadCommand_SOURCE_DIR}/CMakeCommands CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO OUTPUT_VARIABLE OUTPUT ) -# do another TRY_COMPILE to get around make -# problem on hp - try_compile(COMPILE_OK - ${LoadCommand_BINARY_DIR}/CMakeCommands - ${LoadCommand_SOURCE_DIR}/CMakeCommands - CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO - OUTPUT_VARIABLE OUTPUT ) endif() message("Output from try compile: ${OUTPUT}") diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in index e6bfabd33..bf98e918c 100644 --- a/Tests/MFC/CMakeLists.txt.in +++ b/Tests/MFC/CMakeLists.txt.in @@ -45,6 +45,11 @@ set(files set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@") +FIND_PACKAGE(MFC) +IF (NOT MFC_FOUND) + MESSAGE(FATAL_ERROR "MFC Could not be found during the MFC test") +ENDIF() + if("${CMAKE_MFC_FLAG}" STREQUAL "1") msvc_link_to_static_crt() else() diff --git a/Tests/MFC/mfc1/.gitattributes b/Tests/MFC/mfc1/.gitattributes deleted file mode 100644 index 59be5dcfb..000000000 --- a/Tests/MFC/mfc1/.gitattributes +++ /dev/null @@ -1,6 +0,0 @@ -.gitattributes export-ignore - -*.sln -crlf -*.vcproj -crlf - -* -whitespace diff --git a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt index 607dcd33a..4a41a988d 100644 --- a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-C LANGUAGES C) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_C) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.c) diff --git a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt index 2dede930b..1bb2b8496 100644 --- a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-CXX LANGUAGES CXX) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_CXX) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.cpp) diff --git a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt index dee5c25bd..3872b567b 100644 --- a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-Fortran LANGUAGES Fortran) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_Fortran) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.f) diff --git a/Tests/Module/ExternalData/MD5/.gitattributes b/Tests/Module/ExternalData/MD5/.gitattributes deleted file mode 100644 index 3e51d39db..000000000 --- a/Tests/Module/ExternalData/MD5/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* -crlf diff --git a/Tests/Module/ExternalData/SHA1/.gitattributes b/Tests/Module/ExternalData/SHA1/.gitattributes deleted file mode 100644 index 3e51d39db..000000000 --- a/Tests/Module/ExternalData/SHA1/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* -crlf diff --git a/Tests/Module/ExternalData/SHA224/.gitattributes b/Tests/Module/ExternalData/SHA224/.gitattributes deleted file mode 100644 index 3e51d39db..000000000 --- a/Tests/Module/ExternalData/SHA224/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* -crlf diff --git a/Tests/Module/ExternalData/SHA256/.gitattributes b/Tests/Module/ExternalData/SHA256/.gitattributes deleted file mode 100644 index 3e51d39db..000000000 --- a/Tests/Module/ExternalData/SHA256/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* -crlf diff --git a/Tests/Module/ExternalData/SHA3_256/.gitattributes b/Tests/Module/ExternalData/SHA3_256/.gitattributes deleted file mode 100644 index 3e51d39db..000000000 --- a/Tests/Module/ExternalData/SHA3_256/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* -crlf diff --git a/Tests/MumpsCoverage/.gitattributes b/Tests/MumpsCoverage/.gitattributes deleted file mode 100644 index b6806125d..000000000 --- a/Tests/MumpsCoverage/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -*.cmcov -crlf -whitespace -*.mcov -crlf -whitespace diff --git a/Tests/MumpsCoverage/ZZCOVTST.cmcov b/Tests/MumpsCoverage/ZZCOVTST.cmcov index 7a5df6105..41c0ff398 100644 --- a/Tests/MumpsCoverage/ZZCOVTST.cmcov +++ b/Tests/MumpsCoverage/ZZCOVTST.cmcov @@ -42,4 +42,4 @@ ZZCOVTST,1,1,"ZZCOVTST;OSEHRA/JPS -- Test routine for Coverage Parsing;4/28/2014 ,41,1," . S ZZBLAH=""blah"""
,42,1," W ""Ending T6"",!"
,43,0," ;"
-Totals for ZZCOVTST,,25,
\ No newline at end of file +Totals for ZZCOVTST,,25,
diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index 9e2b4abd9..227d990af 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -28,13 +28,6 @@ include_directories( ${Plugin_SOURCE_DIR}/include ) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/PositionIndependentTargets/.gitattributes b/Tests/PositionIndependentTargets/.gitattributes deleted file mode 100644 index ed36631f4..000000000 --- a/Tests/PositionIndependentTargets/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Do not format a source where we want a long line preserved. -pic_test.h -format.clang-format diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt index ae0a02bb6..2ca11e40b 100644 --- a/Tests/Qt4Targets/CMakeLists.txt +++ b/Tests/Qt4Targets/CMakeLists.txt @@ -20,6 +20,16 @@ if (WIN32) endif() endif() +# Qt4 moc does not support utf8 paths in _parameter files generated by +# qt4_wrap_cpp and qt4_generate_moc +# https://bugreports.qt.io/browse/QTBUG-35480 +# Do a simple check if there is are non ASCII character in the build path +string(REGEX MATCH "[^ -~]+" NON_ASCII_BDIR ${CMAKE_CURRENT_BINARY_DIR}) +if(NON_ASCII_BDIR) + message(WARNING "Build path contains non ASCII characters. Skipping Qt4 test.") + return() +endif() + qt4_generate_moc(main_gen_test.cpp "${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc" TARGET Qt4GenerateMacroTest diff --git a/Tests/QtAutoUicInterface/CMakeLists.txt b/Tests/QtAutoUicInterface/CMakeLists.txt index 3ea12943a..a5c2d99b2 100644 --- a/Tests/QtAutoUicInterface/CMakeLists.txt +++ b/Tests/QtAutoUicInterface/CMakeLists.txt @@ -53,8 +53,9 @@ set_property(TARGET KI18n APPEND PROPERTY # END upstream -if(${CMAKE_GENERATOR} MATCHES "Visual Studio") -set(INC_DIR "include_${CMAKE_BUILD_TYPE}" ) +get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_GENERATOR_IS_MULTI_CONFIG) +set(INC_DIR "include_$<CONFIG>" ) else() set(INC_DIR "include" ) endif() diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 073c5fdef..32c2950cb 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -1,14 +1,7 @@ -cmake_minimum_required(VERSION 3.7) - +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0071 NEW) project(QtAutogen) -# Tell find_package(Qt5) where to find Qt. -if(QT_QMAKE_EXECUTABLE) - get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) - get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH) - set(CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) -endif() - if (QT_TEST_VERSION STREQUAL 4) find_package(Qt4 REQUIRED) @@ -22,6 +15,9 @@ if (QT_TEST_VERSION STREQUAL 4) macro(qtx_wrap_cpp) qt4_wrap_cpp(${ARGN}) endmacro() + macro(qtx_generate_moc) + qt4_generate_moc(${ARGN}) + endmacro() else() if (NOT QT_TEST_VERSION STREQUAL 5) @@ -41,11 +37,48 @@ else() macro(qtx_wrap_cpp) qt5_wrap_cpp(${ARGN}) endmacro() + macro(qtx_generate_moc) + qt5_generate_moc(${ARGN}) + endmacro() endif() get_property(QT_COMPILE_FEATURES TARGET ${QT_QTCORE_TARGET} PROPERTY INTERFACE_COMPILE_FEATURES) +# Qt4 moc does not support utf8 paths in _parameter files generated by +# qtx_wrap_cpp +# https://bugreports.qt.io/browse/QTBUG-35480 +# Do a simple check if there is are non ASCII character in the build path +string(REGEX MATCH "[^ -~]+" NON_ASCII_BDIR ${CMAKE_CURRENT_BINARY_DIR}) +if((NOT NON_ASCII_BDIR) OR (NOT QT_TEST_VERSION STREQUAL 4)) + set(ALLOW_WRAP_CPP TRUE) +endif() +# On windows qtx_wrap_cpp also fails in Qt5 when used on a path that +# contains non ASCII characters +if(NON_ASCII_BDIR AND WIN32) + set(ALLOW_WRAP_CPP FALSE) +endif() + +# -- Test +# MOC only +add_executable(mocOnly mocOnlySource/main.cpp mocOnlySource/StyleA.cpp mocOnlySource/StyleB.cpp) +set_property(TARGET mocOnly PROPERTY AUTOMOC ON) +target_link_libraries(mocOnly ${QT_LIBRARIES}) + +add_executable(mocOnlyOpts mocOnlySource/main.cpp mocOnlySource/StyleA.cpp mocOnlySource/StyleB.cpp) +set_property(TARGET mocOnlyOpts PROPERTY AUTOMOC ON) +set_property(TARGET mocOnlyOpts PROPERTY AUTOMOC_MOC_OPTIONS "-nw") +target_link_libraries(mocOnlyOpts ${QT_LIBRARIES}) + +# -- Test +# UIC only +if(ALLOW_WRAP_CPP) + qtx_wrap_cpp(uicOnlyMoc uicOnlySource/uiconly.h) + add_executable(uicOnly uicOnlySource/uiconly.cpp ${uicOnlyMoc}) + set_property(TARGET uicOnly PROPERTY AUTOUIC ON) + target_link_libraries(uicOnly ${QT_LIBRARIES}) +endif() + # -- Test # RCC only add_executable(rccOnly rccOnly.cpp rccOnlyRes.qrc) @@ -59,13 +92,6 @@ set_property(TARGET rccEmpty PROPERTY AUTORCC ON) target_link_libraries(rccEmpty ${QT_QTCORE_TARGET}) # -- Test -# UIC only -qtx_wrap_cpp(uicOnlyMoc uicOnlySource/uiconly.h) -add_executable(uicOnly uicOnlySource/uiconly.cpp ${uicOnlyMoc}) -set_property(TARGET uicOnly PROPERTY AUTOUIC ON) -target_link_libraries(uicOnly ${QT_LIBRARIES}) - -# -- Test # Add not_generated_file.qrc to the source list to get the file-level # dependency, but don't generate a c++ file from it. Disable the AUTORCC # feature for this target. This tests that qrc files in the sources don't @@ -80,154 +106,41 @@ set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE) target_compile_features(no_link_language PRIVATE ${QT_COMPILE_FEATURES}) target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES}) -# -- Test -# When a file listed in a .qrc file changes the target must be rebuilt -set(timeformat "%Y%j%H%M%S") -set(RCC_DEPENDS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends") -set(RCC_DEPENDS_BIN "${CMAKE_CURRENT_BINARY_DIR}/rccDepends") -configure_file(${RCC_DEPENDS_SRC}/res1a.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY) -configure_file(${RCC_DEPENDS_SRC}/res2a.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY) -try_compile(RCC_DEPENDS - "${RCC_DEPENDS_BIN}" - "${RCC_DEPENDS_SRC}" - rccDepends - CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" - "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output -) -if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}") -endif() -# Get name and timestamp of the output binary -file(STRINGS "${RCC_DEPENDS_BIN}/target.txt" targetList) -list(GET targetList 0 rccDependsBin) -file(TIMESTAMP "${rccDependsBin}" timeBegin "${timeformat}") -# Sleep, touch regular qrc input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Second build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep1 "${timeformat}") -if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the first step!") -endif() -# Sleep, update regular qrc file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -configure_file(${RCC_DEPENDS_SRC}/res1b.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Third build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep2 "${timeformat}") -if (NOT timeStep2 GREATER timeStep1) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the second step!") -endif() -# Sleep, touch regular qrc newly added input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fourth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep3 "${timeformat}") -if (NOT timeStep3 GREATER timeStep2) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the third step!") -endif() -# Sleep, touch generated qrc input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fifth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep4 "${timeformat}") -if (NOT timeStep4 GREATER timeStep3) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fourth step!") -endif() -# Sleep, update generated qrc file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -configure_file(${RCC_DEPENDS_SRC}/res2b.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Sixth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep5 "${timeformat}") -if (NOT timeStep5 GREATER timeStep4) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fitfh step!") -endif() -# Sleep, touch generated qrc newly added input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Seventh build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep6 "${timeformat}") -if (NOT timeStep6 GREATER timeStep5) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the sixth step!") -endif() - - -# -- Test -# Ensure a repeated build succeeds when a header containing a QObject changes -set(timeformat "%Y%j%H%M%S") -configure_file(mocRerun/test1a.h.in mocRerun/test1.h COPYONLY) -try_compile(MOC_RERUN - "${CMAKE_CURRENT_BINARY_DIR}/mocRerun" - "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun" - mocRerun - CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" - "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output -) -if (NOT MOC_RERUN) - message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}") -endif() -# Get name and timestamp of the output binary -file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/mocRerun/target1.txt" target1List) -list(GET target1List 0 binFile) -file(TIMESTAMP "${binFile}" timeBegin "${timeformat}") -# Change file content and rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun" - RESULT_VARIABLE mocRerun_result - ) -if (mocRerun_result) - message(SEND_ERROR "Second build of mocRerun failed.") -endif() -# Compare timestamps -file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}") -if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "File (${binFile}) should have changed in the first step!") -endif() # -- Test # Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target -qtx_wrap_cpp(skipMocWrapMoc - skipSource/qItemA.hpp - skipSource/qItemB.hpp) -set(skipMocSources - skipMoc.cpp - skipSource/qItemA.cpp - skipSource/qItemB.cpp - skipSource/qItemC.cpp) -set_property(SOURCE skipSource/qItemA.cpp PROPERTY SKIP_AUTOMOC ON) -set_property(SOURCE skipSource/qItemB.cpp PROPERTY SKIP_AUTOGEN ON) -# AUTOMOC enabled only -add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) -set_property(TARGET skipMocA PROPERTY AUTOMOC ON) -target_link_libraries(skipMocA ${QT_LIBRARIES}) -# AUTOMOC and AUTOUIC enabled -add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc}) -set_property(TARGET skipMocB PROPERTY AUTOMOC ON) -set_property(TARGET skipMocB PROPERTY AUTOUIC ON) -target_link_libraries(skipMocB ${QT_LIBRARIES}) +if(ALLOW_WRAP_CPP) + # Generate header mocs manually + qtx_wrap_cpp(skipMocWrapMoc + skipSource/qItemA.hpp + skipSource/qItemB.hpp + skipSource/qItemC.hpp + skipSource/qItemD.hpp + ) + set(skipMocSources + skipMoc.cpp + skipSource/qItemA.cpp + skipSource/qItemB.cpp + skipSource/qItemC.cpp + skipSource/qItemD.cpp + ) + # When cpp files are skipped, the hpp won't be processed either, + # unless they are mentioned in the sources - which they aren't. + set_property(SOURCE skipSource/qItemA.cpp PROPERTY SKIP_AUTOMOC ON) + set_property(SOURCE skipSource/qItemB.cpp PROPERTY SKIP_AUTOGEN ON) + # When hpp files are skipped, the cpp still get processed. + set_property(SOURCE skipSource/qItemC.hpp PROPERTY SKIP_AUTOMOC ON) + set_property(SOURCE skipSource/qItemD.hpp PROPERTY SKIP_AUTOGEN ON) + # AUTOMOC enabled only + add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) + set_property(TARGET skipMocA PROPERTY AUTOMOC ON) + target_link_libraries(skipMocA ${QT_LIBRARIES}) + # AUTOMOC and AUTOUIC enabled + add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc}) + set_property(TARGET skipMocB PROPERTY AUTOMOC ON) + set_property(TARGET skipMocB PROPERTY AUTOUIC ON) + target_link_libraries(skipMocB ${QT_LIBRARIES}) +endif() # -- Test # Test for SKIP_AUTOUIC and SKIP_AUTOGEN on an AUTOUIC enabled target @@ -271,8 +184,10 @@ set_property(TARGET skipRccB PROPERTY AUTOMOC ON) target_link_libraries(skipRccB ${QT_LIBRARIES}) # -- Test -# Source files with the same basename in different subdirectories -add_subdirectory(sameName) +# MOC AUTOMOC_MACRO_NAMES +if (NOT QT_TEST_VERSION STREQUAL 4) + add_subdirectory(mocMacroName) +endif() # -- Test # Tests AUTOMOC with generated sources @@ -280,85 +195,32 @@ add_subdirectory(mocDepends) # -- Test # Tests various include moc patterns -add_subdirectory(mocIncludeStrict) +if(ALLOW_WRAP_CPP) + add_subdirectory(mocIncludeStrict) + add_subdirectory(mocIncludeRelaxed) +endif() # -- Test -# Tests various include moc patterns -add_subdirectory(mocIncludeRelaxed) +# Tests policy 0071 +if(ALLOW_WRAP_CPP) + add_subdirectory(mocCMP0071) +endif() # -- Test -# Tests Q_PLUGIN_METADATA json file change detection -if (NOT QT_TEST_VERSION STREQUAL 4) - try_compile(MOC_PLUGIN - "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin" - "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin" - mocPlugin - CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output - ) - if (NOT MOC_PLUGIN) - message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}") - endif() - - set(timeformat "%Y%j%H%M%S") - set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin") - set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin") - 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) - - file(TIMESTAMP "${plAFile}" plABefore "${timeformat}") - file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}") - file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") - file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") - - # Ensure that the timestamp will change and change the json files - execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) - configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json") - configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.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}") - - 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() +# Tests various .ui include directories +add_subdirectory(uicInclude) - # Test custom macro - file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") - file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") - execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) - configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json") - configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json") - execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") - file(TIMESTAMP "${plDFile}" plDAfter "${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() +# -- Test +# OBJECT libraries +add_subdirectory(objectLibrary) -endif() +# -- Test +# Source files with the same basename in different subdirectories +add_subdirectory(sameName) # -- Test -# Tests various .ui include directories -add_subdirectory(uicInclude) +# Tests static library cycles +add_subdirectory(staticLibraryCycle) # -- Test # Complex test case diff --git a/Tests/QtAutogen/complex/CMakeLists.txt b/Tests/QtAutogen/complex/CMakeLists.txt index d48f6cc54..2043ccf58 100644 --- a/Tests/QtAutogen/complex/CMakeLists.txt +++ b/Tests/QtAutogen/complex/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.9) # -- Test: AUTOMOC AUTORCC AUTOUIC add_definitions(-DFOO -DSomeDefine="Barx") diff --git a/Tests/QtAutogen/mocCMP0071/CMakeLists.txt b/Tests/QtAutogen/mocCMP0071/CMakeLists.txt new file mode 100644 index 000000000..003fa088f --- /dev/null +++ b/Tests/QtAutogen/mocCMP0071/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.9) +project(mocCMP0071 CXX) +add_subdirectory(OLD) +add_subdirectory(NEW) diff --git a/Tests/QtAutogen/mocCMP0071/NEW/CMakeLists.txt b/Tests/QtAutogen/mocCMP0071/NEW/CMakeLists.txt new file mode 100644 index 000000000..0237afc39 --- /dev/null +++ b/Tests/QtAutogen/mocCMP0071/NEW/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0071 NEW) + +# *Generate* files +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) +add_custom_command( + OUTPUT ${CBD}/Obj_p.h ${CBD}/Obj.hpp ${CBD}/Obj.cpp ${CBD}/main.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj_p.h ${CBD}/Obj_p.h + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.hpp ${CBD}/Obj.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.cpp ${CBD}/Obj.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../main.cpp ${CBD}/main.cpp) + +add_executable(mocCMP0071New ${CBD}/Obj.cpp ${CBD}/main.cpp) +target_link_libraries(mocCMP0071New ${QT_LIBRARIES}) +set_target_properties(mocCMP0071New PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/mocCMP0071/OLD/CMakeLists.txt b/Tests/QtAutogen/mocCMP0071/OLD/CMakeLists.txt new file mode 100644 index 000000000..569943336 --- /dev/null +++ b/Tests/QtAutogen/mocCMP0071/OLD/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0071 OLD) + +# *Generate* files +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) +add_custom_command( + OUTPUT ${CBD}/Obj_p.h ${CBD}/Obj.hpp ${CBD}/Obj.cpp ${CBD}/main.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj_p.h ${CBD}/Obj_p.h + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.hpp ${CBD}/Obj.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.cpp ${CBD}/Obj.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../main.cpp ${CBD}/main.cpp) + +# Generate moc files externally +qtx_wrap_cpp(mocCMP0071OldMoc ${CBD}/Obj.hpp ${CBD}/Obj_p.h) +add_executable(mocCMP0071Old ${CBD}/Obj.cpp ${CBD}/main.cpp ${mocCMP0071OldMoc}) +target_link_libraries(mocCMP0071Old ${QT_LIBRARIES}) +set_target_properties(mocCMP0071Old PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/mocCMP0071/Obj.cpp b/Tests/QtAutogen/mocCMP0071/Obj.cpp new file mode 100644 index 000000000..1ae50edc9 --- /dev/null +++ b/Tests/QtAutogen/mocCMP0071/Obj.cpp @@ -0,0 +1,20 @@ +#include "Obj.hpp" +#include "Obj_p.h" + +ObjPrivate::ObjPrivate() +{ +} + +ObjPrivate::~ObjPrivate() +{ +} + +Obj::Obj() + : d(new ObjPrivate) +{ +} + +Obj::~Obj() +{ + delete d; +} diff --git a/Tests/QtAutogen/mocCMP0071/Obj.hpp b/Tests/QtAutogen/mocCMP0071/Obj.hpp new file mode 100644 index 000000000..f064e4793 --- /dev/null +++ b/Tests/QtAutogen/mocCMP0071/Obj.hpp @@ -0,0 +1,19 @@ +#ifndef OBJ_HPP +#define OBJ_HPP + +#include <QObject> + +// Object source comes without any _moc/.moc includes +class ObjPrivate; +class Obj : public QObject +{ + Q_OBJECT +public: + Obj(); + ~Obj(); + +private: + ObjPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/mocCMP0071/Obj_p.h b/Tests/QtAutogen/mocCMP0071/Obj_p.h new file mode 100644 index 000000000..cb1e5df71 --- /dev/null +++ b/Tests/QtAutogen/mocCMP0071/Obj_p.h @@ -0,0 +1,14 @@ +#ifndef OBJ_P_HPP +#define OBJ_P_HPP + +#include <QObject> + +class ObjPrivate : public QObject +{ + Q_OBJECT +public: + ObjPrivate(); + ~ObjPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocCMP0071/main.cpp b/Tests/QtAutogen/mocCMP0071/main.cpp new file mode 100644 index 000000000..3887840ba --- /dev/null +++ b/Tests/QtAutogen/mocCMP0071/main.cpp @@ -0,0 +1,7 @@ +#include "Obj.hpp" + +int main(int argv, char** args) +{ + Obj obj; + return 0; +} diff --git a/Tests/QtAutogen/mocDepends/CMakeLists.txt b/Tests/QtAutogen/mocDepends/CMakeLists.txt index 6241ef93d..8217b8dbf 100644 --- a/Tests/QtAutogen/mocDepends/CMakeLists.txt +++ b/Tests/QtAutogen/mocDepends/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0071 NEW) project(mocDepends CXX) if (QT_TEST_VERSION STREQUAL 4) @@ -43,7 +44,6 @@ add_custom_command( add_executable(mocDepGenFile testGenFile.cpp ${CBD}/GenFile.hpp) target_link_libraries(mocDepGenFile ${QT_CORE_TARGET}) set_target_properties(mocDepGenFile PROPERTIES AUTOMOC TRUE) -set_property(TARGET mocDepGenFile PROPERTY __UNDOCUMENTED_AUTOGEN_GENERATED_FILES 1) # -- Test dependency on header generating custom target diff --git a/Tests/QtAutogen/mocInclude/EObjA.cpp b/Tests/QtAutogen/mocInclude/EObjA.cpp new file mode 100644 index 000000000..ca713b261 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjA.cpp @@ -0,0 +1,43 @@ +#include "EObjA.hpp" +#include "EObjAExtra.hpp" +#include "EObjA_p.hpp" + +class EObjALocal : public QObject +{ + Q_OBJECT +public: + EObjALocal(); + ~EObjALocal(); +}; + +EObjALocal::EObjALocal() +{ +} + +EObjALocal::~EObjALocal() +{ +} + +EObjAPrivate::EObjAPrivate() +{ + EObjALocal localObj; + EObjAExtra extraObj; +} + +EObjAPrivate::~EObjAPrivate() +{ +} + +EObjA::EObjA() + : d(new EObjAPrivate) +{ +} + +EObjA::~EObjA() +{ +} + +// For EObjALocal +#include "EObjA.moc" +// - Not the own header +#include "moc_EObjAExtra.cpp" diff --git a/Tests/QtAutogen/mocInclude/EObjA.hpp b/Tests/QtAutogen/mocInclude/EObjA.hpp new file mode 100644 index 000000000..0939ab66d --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjA.hpp @@ -0,0 +1,19 @@ +#ifndef EOBJA_HPP +#define EOBJA_HPP + +#include <QObject> + +// Sources includes a moc_ includes of an extra object +class EObjAPrivate; +class EObjA : public QObject +{ + Q_OBJECT +public: + EObjA(); + ~EObjA(); + +private: + EObjAPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/EObjAExtra.cpp b/Tests/QtAutogen/mocInclude/EObjAExtra.cpp new file mode 100644 index 000000000..369ca8f77 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjAExtra.cpp @@ -0,0 +1,20 @@ +#include "EObjAExtra.hpp" +#include "EObjAExtra_p.hpp" + +EObjAExtraPrivate::EObjAExtraPrivate() +{ +} + +EObjAExtraPrivate::~EObjAExtraPrivate() +{ +} + +EObjAExtra::EObjAExtra() + : d(new EObjAExtraPrivate) +{ +} + +EObjAExtra::~EObjAExtra() +{ + delete d; +} diff --git a/Tests/QtAutogen/mocInclude/EObjAExtra.hpp b/Tests/QtAutogen/mocInclude/EObjAExtra.hpp new file mode 100644 index 000000000..b10681d59 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjAExtra.hpp @@ -0,0 +1,18 @@ +#ifndef EOBJAEXTRA_HPP +#define EOBJAEXTRA_HPP + +#include <QObject> + +class EObjAExtraPrivate; +class EObjAExtra : public QObject +{ + Q_OBJECT +public: + EObjAExtra(); + ~EObjAExtra(); + +private: + EObjAExtraPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/EObjAExtra_p.hpp b/Tests/QtAutogen/mocInclude/EObjAExtra_p.hpp new file mode 100644 index 000000000..dea6cb5ab --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjAExtra_p.hpp @@ -0,0 +1,12 @@ +#ifndef EOBJAEXTRA_P_HPP +#define EOBJAEXTRA_P_HPP + +class EObjAExtraPrivate : public QObject +{ + Q_OBJECT +public: + EObjAExtraPrivate(); + ~EObjAExtraPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/EObjA_p.hpp b/Tests/QtAutogen/mocInclude/EObjA_p.hpp new file mode 100644 index 000000000..1e0d7e11d --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjA_p.hpp @@ -0,0 +1,12 @@ +#ifndef EOBJA_P_HPP +#define EOBJA_P_HPP + +class EObjAPrivate : public QObject +{ + Q_OBJECT +public: + EObjAPrivate(); + ~EObjAPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/EObjB.cpp b/Tests/QtAutogen/mocInclude/EObjB.cpp new file mode 100644 index 000000000..d19fbfa6c --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjB.cpp @@ -0,0 +1,44 @@ +#include "EObjB.hpp" +#include "EObjB_p.hpp" +#include "subExtra/EObjBExtra.hpp" + +class EObjBLocal : public QObject +{ + Q_OBJECT +public: + EObjBLocal(); + ~EObjBLocal(); +}; + +EObjBLocal::EObjBLocal() +{ +} + +EObjBLocal::~EObjBLocal() +{ +} + +EObjBPrivate::EObjBPrivate() +{ + EObjBLocal localObj; + EObjBExtra extraObj; +} + +EObjBPrivate::~EObjBPrivate() +{ +} + +EObjB::EObjB() + : d(new EObjBPrivate) +{ +} + +EObjB::~EObjB() +{ +} + +// For EObjBLocal +#include "EObjB.moc" +// - Not the own header +// - in a subdirectory +#include "subExtra/moc_EObjBExtra.cpp" diff --git a/Tests/QtAutogen/mocInclude/EObjB.hpp b/Tests/QtAutogen/mocInclude/EObjB.hpp new file mode 100644 index 000000000..6632bdb07 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjB.hpp @@ -0,0 +1,19 @@ +#ifndef EOBJB_HPP +#define EOBJB_HPP + +#include <QObject> + +// Sources includes a moc_ includes of an extra object in a subdirectory +class EObjBPrivate; +class EObjB : public QObject +{ + Q_OBJECT +public: + EObjB(); + ~EObjB(); + +private: + EObjBPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/EObjB_p.hpp b/Tests/QtAutogen/mocInclude/EObjB_p.hpp new file mode 100644 index 000000000..2905f2891 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/EObjB_p.hpp @@ -0,0 +1,12 @@ +#ifndef EOBJB_P_HPP +#define EOBJB_P_HPP + +class EObjBPrivate : public QObject +{ + Q_OBJECT +public: + EObjBPrivate(); + ~EObjBPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/LObjA.cpp b/Tests/QtAutogen/mocInclude/LObjA.cpp new file mode 100644 index 000000000..9aae9917f --- /dev/null +++ b/Tests/QtAutogen/mocInclude/LObjA.cpp @@ -0,0 +1,39 @@ +#include "LObjA.hpp" +#include "LObjA_p.h" + +class LObjALocal : public QObject +{ + Q_OBJECT +public: + LObjALocal(); + ~LObjALocal(); +}; + +LObjALocal::LObjALocal() +{ +} + +LObjALocal::~LObjALocal() +{ +} + +LObjAPrivate::LObjAPrivate() +{ + LObjALocal localObj; +} + +LObjAPrivate::~LObjAPrivate() +{ +} + +LObjA::LObjA() + : d(new LObjAPrivate) +{ +} + +LObjA::~LObjA() +{ + delete d; +} + +#include "LObjA.moc" diff --git a/Tests/QtAutogen/mocInclude/LObjA.hpp b/Tests/QtAutogen/mocInclude/LObjA.hpp new file mode 100644 index 000000000..aac670c00 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/LObjA.hpp @@ -0,0 +1,19 @@ +#ifndef LOBJA_HPP +#define LOBJA_HPP + +#include <QObject> + +// Object source comes with a .moc include +class LObjAPrivate; +class LObjA : public QObject +{ + Q_OBJECT +public: + LObjA(); + ~LObjA(); + +private: + LObjAPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/LObjA_p.h b/Tests/QtAutogen/mocInclude/LObjA_p.h new file mode 100644 index 000000000..ebe839579 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/LObjA_p.h @@ -0,0 +1,12 @@ +#ifndef LOBJA_P_HPP +#define LOBJA_P_HPP + +class LObjAPrivate : public QObject +{ + Q_OBJECT +public: + LObjAPrivate(); + ~LObjAPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/LObjB.cpp b/Tests/QtAutogen/mocInclude/LObjB.cpp new file mode 100644 index 000000000..7485d8fca --- /dev/null +++ b/Tests/QtAutogen/mocInclude/LObjB.cpp @@ -0,0 +1,40 @@ +#include "LObjB.hpp" +#include "LObjB_p.h" + +class LObjBLocal : public QObject +{ + Q_OBJECT +public: + LObjBLocal(); + ~LObjBLocal(); +}; + +LObjBLocal::LObjBLocal() +{ +} + +LObjBLocal::~LObjBLocal() +{ +} + +LObjBPrivate::LObjBPrivate() +{ + LObjBLocal localObj; +} + +LObjBPrivate::~LObjBPrivate() +{ +} + +LObjB::LObjB() + : d(new LObjBPrivate) +{ +} + +LObjB::~LObjB() +{ + delete d; +} + +#include "LObjB.moc" +#include "moc_LObjB.cpp" diff --git a/Tests/QtAutogen/mocInclude/LObjB.hpp b/Tests/QtAutogen/mocInclude/LObjB.hpp new file mode 100644 index 000000000..eb4e58d79 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/LObjB.hpp @@ -0,0 +1,19 @@ +#ifndef LLObjB_HPP +#define LLObjB_HPP + +#include <QObject> + +// Object source comes with a .moc and a _moc include +class LObjBPrivate; +class LObjB : public QObject +{ + Q_OBJECT +public: + LObjB(); + ~LObjB(); + +private: + LObjBPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/LObjB_p.h b/Tests/QtAutogen/mocInclude/LObjB_p.h new file mode 100644 index 000000000..b871f2d2a --- /dev/null +++ b/Tests/QtAutogen/mocInclude/LObjB_p.h @@ -0,0 +1,12 @@ +#ifndef LOBJB_P_HPP +#define LOBJB_P_HPP + +class LObjBPrivate : public QObject +{ + Q_OBJECT +public: + LObjBPrivate(); + ~LObjBPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/ObjA.cpp b/Tests/QtAutogen/mocInclude/ObjA.cpp index 1b0311d30..6f6b90ef1 100644 --- a/Tests/QtAutogen/mocInclude/ObjA.cpp +++ b/Tests/QtAutogen/mocInclude/ObjA.cpp @@ -1,24 +1,20 @@ #include "ObjA.hpp" +#include "ObjA_p.h" -class SubObjA : public QObject +ObjAPrivate::ObjAPrivate() { - Q_OBJECT - -public: - SubObjA() {} - ~SubObjA() {} - - Q_SLOT - void aSlot(); -}; +} -void SubObjA::aSlot() +ObjAPrivate::~ObjAPrivate() { } -void ObjA::go() +ObjA::ObjA() + : d(new ObjAPrivate) { - SubObjA subObj; } -#include "ObjA.moc" +ObjA::~ObjA() +{ + delete d; +} diff --git a/Tests/QtAutogen/mocInclude/ObjA.hpp b/Tests/QtAutogen/mocInclude/ObjA.hpp index 281e90d86..f16c924aa 100644 --- a/Tests/QtAutogen/mocInclude/ObjA.hpp +++ b/Tests/QtAutogen/mocInclude/ObjA.hpp @@ -3,11 +3,17 @@ #include <QObject> +// Object source comes without any _moc/.moc includes +class ObjAPrivate; class ObjA : public QObject { Q_OBJECT - Q_SLOT - void go(); +public: + ObjA(); + ~ObjA(); + +private: + ObjAPrivate* const d; }; #endif diff --git a/Tests/QtAutogen/mocInclude/ObjA_p.h b/Tests/QtAutogen/mocInclude/ObjA_p.h new file mode 100644 index 000000000..eb60c9800 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/ObjA_p.h @@ -0,0 +1,12 @@ +#ifndef OBJA_P_HPP +#define OBJA_P_HPP + +class ObjAPrivate : public QObject +{ + Q_OBJECT +public: + ObjAPrivate(); + ~ObjAPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/ObjB.cpp b/Tests/QtAutogen/mocInclude/ObjB.cpp index 5ff315dc7..a6f2509af 100644 --- a/Tests/QtAutogen/mocInclude/ObjB.cpp +++ b/Tests/QtAutogen/mocInclude/ObjB.cpp @@ -1,25 +1,22 @@ #include "ObjB.hpp" +#include "ObjB_p.h" -class SubObjB : public QObject +ObjBPrivate::ObjBPrivate() { - Q_OBJECT - -public: - SubObjB() {} - ~SubObjB() {} +} - Q_SLOT - void aSlot(); -}; +ObjBPrivate::~ObjBPrivate() +{ +} -void SubObjB::aSlot() +ObjB::ObjB() + : d(new ObjBPrivate) { } -void ObjB::go() +ObjB::~ObjB() { - SubObjB subObj; + delete d; } -#include "ObjB.moc" #include "moc_ObjB.cpp" diff --git a/Tests/QtAutogen/mocInclude/ObjB.hpp b/Tests/QtAutogen/mocInclude/ObjB.hpp index 94f3d498c..2ac8d1700 100644 --- a/Tests/QtAutogen/mocInclude/ObjB.hpp +++ b/Tests/QtAutogen/mocInclude/ObjB.hpp @@ -1,13 +1,19 @@ -#ifndef OBJB_HPP -#define OBJB_HPP +#ifndef ObjB_HPP +#define ObjB_HPP #include <QObject> +// Object source comes with a _moc include +class ObjBPrivate; class ObjB : public QObject { Q_OBJECT - Q_SLOT - void go(); +public: + ObjB(); + ~ObjB(); + +private: + ObjBPrivate* const d; }; #endif diff --git a/Tests/QtAutogen/mocInclude/ObjB_p.h b/Tests/QtAutogen/mocInclude/ObjB_p.h new file mode 100644 index 000000000..418da6578 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/ObjB_p.h @@ -0,0 +1,12 @@ +#ifndef OBJB_P_HPP +#define OBJB_P_HPP + +class ObjBPrivate : public QObject +{ + Q_OBJECT +public: + ObjBPrivate(); + ~ObjBPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/ObjC.cpp b/Tests/QtAutogen/mocInclude/ObjC.cpp deleted file mode 100644 index 8ca34cbb4..000000000 --- a/Tests/QtAutogen/mocInclude/ObjC.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "ObjC.hpp" - -class SubObjC : public QObject -{ - Q_OBJECT - -public: - SubObjC() {} - ~SubObjC() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjC::aSlot() -{ -} - -void ObjC::go() -{ - SubObjC subObj; -} - -#include "ObjC.moc" -// Not the own header -#include "moc_ObjD.cpp" diff --git a/Tests/QtAutogen/mocInclude/ObjC.hpp b/Tests/QtAutogen/mocInclude/ObjC.hpp deleted file mode 100644 index a8e98eb1e..000000000 --- a/Tests/QtAutogen/mocInclude/ObjC.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef OBJC_HPP -#define OBJC_HPP - -#include <QObject> - -class ObjC : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; - -#endif diff --git a/Tests/QtAutogen/mocInclude/ObjD.cpp b/Tests/QtAutogen/mocInclude/ObjD.cpp deleted file mode 100644 index c18aec152..000000000 --- a/Tests/QtAutogen/mocInclude/ObjD.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "ObjD.hpp" - -class SubObjD : public QObject -{ - Q_OBJECT - -public: - SubObjD() {} - ~SubObjD() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjD::aSlot() -{ -} - -void ObjD::go() -{ - SubObjD subObj; -} - -#include "ObjD.moc" -// Header in subdirectory -#include "subA/moc_SubObjA.cpp" diff --git a/Tests/QtAutogen/mocInclude/ObjD.hpp b/Tests/QtAutogen/mocInclude/ObjD.hpp deleted file mode 100644 index b6ee09808..000000000 --- a/Tests/QtAutogen/mocInclude/ObjD.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef OBJD_HPP -#define OBJD_HPP - -#include <QObject> - -class ObjD : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; - -#endif diff --git a/Tests/QtAutogen/mocInclude/SObjA.cpp b/Tests/QtAutogen/mocInclude/SObjA.cpp new file mode 100644 index 000000000..7e75bf973 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjA.cpp @@ -0,0 +1,11 @@ +#include "SObjA.hpp" + +SObjA::SObjA() +{ +} + +SObjA::~SObjA() +{ +} + +#include "SObjA.moc" diff --git a/Tests/QtAutogen/mocInclude/SObjA.hpp b/Tests/QtAutogen/mocInclude/SObjA.hpp new file mode 100644 index 000000000..1436abc6c --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjA.hpp @@ -0,0 +1,15 @@ +#ifndef SOBJA_HPP +#define SOBJA_HPP + +#include <QObject> + +// Object source includes externally generated .moc file +class SObjA : public QObject +{ + Q_OBJECT +public: + SObjA(); + ~SObjA(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/SObjB.cpp.in b/Tests/QtAutogen/mocInclude/SObjB.cpp.in new file mode 100644 index 000000000..b1cc12ab2 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjB.cpp.in @@ -0,0 +1,11 @@ +#include "SObjB.hpp" + +SObjB::SObjB() +{ +} + +SObjB::~SObjB() +{ +} + +#include "SObjB.moc" diff --git a/Tests/QtAutogen/mocInclude/SObjB.hpp.in b/Tests/QtAutogen/mocInclude/SObjB.hpp.in new file mode 100644 index 000000000..5e396aea8 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjB.hpp.in @@ -0,0 +1,15 @@ +#ifndef SOBJB_HPP +#define SOBJB_HPP + +#include <QObject> + +// Object source includes externally generated .moc file +class SObjB : public QObject +{ + Q_OBJECT +public: + SObjB(); + ~SObjB(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/SObjC.cpp b/Tests/QtAutogen/mocInclude/SObjC.cpp new file mode 100644 index 000000000..1e8d397f9 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjC.cpp @@ -0,0 +1,35 @@ +#include "SObjC.hpp" + +void SObjCLocalFunction(); + +class SObjCLocal : public QObject +{ + Q_OBJECT + +public: + SObjCLocal(); + ~SObjCLocal(); +}; + +SObjCLocal::SObjCLocal() +{ +} + +SObjCLocal::~SObjCLocal() +{ +} + +SObjC::SObjC() +{ + SObjCLocal localObject; + SObjCLocalFunction(); +} + +SObjC::~SObjC() +{ +} + +#include "SObjC.moc" +#include "moc_SObjC.cpp" +// Include moc_ file for which the header is SKIP_AUTOMOC enabled +#include "moc_SObjCExtra.cpp" diff --git a/Tests/QtAutogen/mocInclude/SObjC.hpp b/Tests/QtAutogen/mocInclude/SObjC.hpp new file mode 100644 index 000000000..def0f9d96 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjC.hpp @@ -0,0 +1,15 @@ +#ifndef SOBJC_HPP +#define SOBJC_HPP + +#include <QObject> + +// Object source includes externally generated .moc file +class SObjC : public QObject +{ + Q_OBJECT +public: + SObjC(); + ~SObjC(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/SObjCExtra.cpp b/Tests/QtAutogen/mocInclude/SObjCExtra.cpp new file mode 100644 index 000000000..55dd1c315 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjCExtra.cpp @@ -0,0 +1,31 @@ +#include "SObjCExtra.hpp" + +class SObjCLocalExtra : public QObject +{ + Q_OBJECT + +public: + SObjCLocalExtra(); + ~SObjCLocalExtra(); +}; + +SObjCLocalExtra::SObjCLocalExtra() +{ +} + +SObjCLocalExtra::~SObjCLocalExtra() +{ +} + +SObjCExtra::SObjCExtra() +{ +} + +SObjCExtra::~SObjCExtra() +{ +} + +// Externally generated header moc +#include "SObjCExtra_extMoc.cpp" +// AUTOMOC generated source moc +#include "SObjCExtra.moc" diff --git a/Tests/QtAutogen/mocInclude/SObjCExtra.hpp b/Tests/QtAutogen/mocInclude/SObjCExtra.hpp new file mode 100644 index 000000000..08545ac29 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjCExtra.hpp @@ -0,0 +1,15 @@ +#ifndef SOBJCEXTRA_HPP +#define SOBJCEXTRA_HPP + +#include <QObject> + +// Object source includes externally generated .moc file +class SObjCExtra : public QObject +{ + Q_OBJECT +public: + SObjCExtra(); + ~SObjCExtra(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/SObjCExtra.moc.in b/Tests/QtAutogen/mocInclude/SObjCExtra.moc.in new file mode 100644 index 000000000..00fc4aabe --- /dev/null +++ b/Tests/QtAutogen/mocInclude/SObjCExtra.moc.in @@ -0,0 +1,4 @@ + +void SObjCLocalFunction() +{ +} diff --git a/Tests/QtAutogen/mocInclude/shared.cmake b/Tests/QtAutogen/mocInclude/shared.cmake new file mode 100644 index 000000000..d05f27c27 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/shared.cmake @@ -0,0 +1,71 @@ +# Test moc include patterns +include_directories("../mocInclude") +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +# Generate .moc file externally and enabled SKIP_AUTOMOC on the file +qtx_generate_moc( + ${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/SObjA.hpp + ${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc) +set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/SObjA.cpp PROPERTY SKIP_AUTOMOC ON) + +# Generate .moc file externally from generated source file +# and enabled SKIP_AUTOMOC on the source file +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/SObjB.hpp.in + ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/SObjB.cpp.in + ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp) +qtx_generate_moc( + ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp + ${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc) +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp PROPERTY SKIP_AUTOMOC ON) + +# Generate moc file externally and enabled SKIP_AUTOMOC on the header +qtx_generate_moc( + ${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/SObjCExtra.hpp + ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp) +set_property( + SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/SObjCExtra.hpp + PROPERTY SKIP_AUTOMOC ON) +# Custom target to depend on +set(SOBJC_MOC ${CMAKE_CURRENT_BINARY_DIR}/moc_SObjCExtra.cpp) +add_custom_target("${MOC_INCLUDE_NAME}_SOBJC" + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp + BYPRODUCTS ${SOBJC_MOC} + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/SObjCExtra.moc.in + ${SOBJC_MOC}) + +# MOC_INCLUDE_NAME must be defined by the includer +add_executable(${MOC_INCLUDE_NAME} + # Common sources + ../mocInclude/ObjA.cpp + ../mocInclude/ObjB.cpp + + ../mocInclude/LObjA.cpp + ../mocInclude/LObjB.cpp + + ../mocInclude/EObjA.cpp + ../mocInclude/EObjAExtra.cpp + ../mocInclude/EObjB.cpp + ../mocInclude/subExtra/EObjBExtra.cpp + + ../mocInclude/SObjA.cpp + ${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc + ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp + ${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc + ../mocInclude/SObjC.cpp + ../mocInclude/SObjCExtra.hpp + ../mocInclude/SObjCExtra.cpp + + ../mocInclude/subGlobal/GObj.cpp + main.cpp +) +add_dependencies(${MOC_INCLUDE_NAME} "${MOC_INCLUDE_NAME}_SOBJC") +target_link_libraries(${MOC_INCLUDE_NAME} ${QT_LIBRARIES}) +set_target_properties(${MOC_INCLUDE_NAME} PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp b/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp deleted file mode 100644 index a05f6e37e..000000000 --- a/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "SubObjA.hpp" - -namespace subA { - -class SubObjA : public QObject -{ - Q_OBJECT - -public: - SubObjA() {} - ~SubObjA() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjA::aSlot() -{ -} - -void ObjA::go() -{ - SubObjA subObj; -} -} - -#include "SubObjA.moc" diff --git a/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp b/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp deleted file mode 100644 index 31a18b618..000000000 --- a/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef SUBOBJA_HPP -#define SUBOBJA_HPP - -#include <QObject> - -namespace subA { - -class ObjA : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; -} - -#endif diff --git a/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp b/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp deleted file mode 100644 index 1e77639b2..000000000 --- a/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "SubObjB.hpp" - -namespace subB { - -class SubObjB : public QObject -{ - Q_OBJECT - -public: - SubObjB() {} - ~SubObjB() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjB::aSlot() -{ -} - -void ObjB::go() -{ - SubObjB subObj; -} -} - -#include "SubObjB.moc" diff --git a/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp b/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp deleted file mode 100644 index 3f29fa289..000000000 --- a/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef SUBOBJB_HPP -#define SUBOBJB_HPP - -#include <QObject> - -namespace subB { - -class ObjB : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; -} - -#endif diff --git a/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp b/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp deleted file mode 100644 index c2d94ef26..000000000 --- a/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "SubObjC.hpp" - -namespace subC { - -class SubObjC : public QObject -{ - Q_OBJECT - -public: - SubObjC() {} - ~SubObjC() {} - - Q_SLOT - void aSlot(); -}; - -void SubObjC::aSlot() -{ -} - -void ObjC::go() -{ - SubObjC subObj; -} -} - -#include "SubObjC.moc" diff --git a/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp b/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp deleted file mode 100644 index dc251fd61..000000000 --- a/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef SUBOBJC_HPP -#define SUBOBJC_HPP - -#include <QObject> - -namespace subC { - -class ObjC : public QObject -{ - Q_OBJECT - Q_SLOT - void go(); -}; -} - -#endif diff --git a/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra.cpp b/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra.cpp new file mode 100644 index 000000000..c697866e7 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra.cpp @@ -0,0 +1,20 @@ +#include "EObjBExtra.hpp" +#include "EObjBExtra_p.hpp" + +EObjBExtraPrivate::EObjBExtraPrivate() +{ +} + +EObjBExtraPrivate::~EObjBExtraPrivate() +{ +} + +EObjBExtra::EObjBExtra() + : d(new EObjBExtraPrivate) +{ +} + +EObjBExtra::~EObjBExtra() +{ + delete d; +} diff --git a/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra.hpp b/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra.hpp new file mode 100644 index 000000000..3798d7f52 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra.hpp @@ -0,0 +1,18 @@ +#ifndef EOBJBEXTRA_HPP +#define EOBJBEXTRA_HPP + +#include <QObject> + +class EObjBExtraPrivate; +class EObjBExtra : public QObject +{ + Q_OBJECT +public: + EObjBExtra(); + ~EObjBExtra(); + +private: + EObjBExtraPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra_p.hpp b/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra_p.hpp new file mode 100644 index 000000000..db8a0961f --- /dev/null +++ b/Tests/QtAutogen/mocInclude/subExtra/EObjBExtra_p.hpp @@ -0,0 +1,12 @@ +#ifndef EOBJBEXTRA_P_HPP +#define EOBJBEXTRA_P_HPP + +class EObjBExtraPrivate : public QObject +{ + Q_OBJECT +public: + EObjBExtraPrivate(); + ~EObjBExtraPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/mocInclude/subGlobal/GObj.cpp b/Tests/QtAutogen/mocInclude/subGlobal/GObj.cpp new file mode 100644 index 000000000..6b92f2194 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/subGlobal/GObj.cpp @@ -0,0 +1,41 @@ +#include "GObj.hpp" +#include "GObj_p.hpp" + +namespace subGlobal { + +class GObjLocal : public QObject +{ + Q_OBJECT +public: + GObjLocal(); + ~GObjLocal(); +}; + +GObjLocal::GObjLocal() +{ +} + +GObjLocal::~GObjLocal() +{ +} + +GObjPrivate::GObjPrivate() +{ +} + +GObjPrivate::~GObjPrivate() +{ +} + +GObj::GObj() +{ + GObjLocal localObj; +} + +GObj::~GObj() +{ +} +} + +// For the local QObject +#include "GObj.moc" diff --git a/Tests/QtAutogen/mocInclude/subGlobal/GObj.hpp b/Tests/QtAutogen/mocInclude/subGlobal/GObj.hpp new file mode 100644 index 000000000..2f9ee8207 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/subGlobal/GObj.hpp @@ -0,0 +1,17 @@ +#ifndef GOBJ_HPP +#define GOBJ_HPP + +#include <QObject> + +namespace subGlobal { + +class GObj : public QObject +{ + Q_OBJECT +public: + GObj(); + ~GObj(); +}; +} + +#endif diff --git a/Tests/QtAutogen/mocInclude/subGlobal/GObj_p.hpp b/Tests/QtAutogen/mocInclude/subGlobal/GObj_p.hpp new file mode 100644 index 000000000..7b37dfd18 --- /dev/null +++ b/Tests/QtAutogen/mocInclude/subGlobal/GObj_p.hpp @@ -0,0 +1,15 @@ +#ifndef GOBJ_P_HPP +#define GOBJ_P_HPP + +namespace subGlobal { + +class GObjPrivate : public QObject +{ + Q_OBJECT +public: + GObjPrivate(); + ~GObjPrivate(); +}; +} + +#endif diff --git a/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt b/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt index 6a0829df7..97ba1df51 100644 --- a/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt +++ b/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt @@ -2,17 +2,16 @@ set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) -include_directories("../mocInclude") +# Shared executable +set(MOC_INCLUDE_NAME "mocIncludeRelaxed") +include(${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/shared.cmake) -add_executable(mocIncludeRelaxed - ../mocInclude/ObjA.cpp - ../mocInclude/ObjB.cpp - ../mocInclude/ObjC.cpp - ../mocInclude/ObjD.cpp - ../mocInclude/subA/SubObjA.cpp - ../mocInclude/subB/SubObjB.cpp - ../mocInclude/subC/SubObjC.cpp - main.cpp +# Relaxed ony executable +add_executable(mocIncludeRelaxedOnly + RObjA.cpp + RObjB.cpp + RObjC.cpp + RMain.cpp ) -target_link_libraries(mocIncludeRelaxed ${QT_LIBRARIES}) -set_target_properties(mocIncludeRelaxed PROPERTIES AUTOMOC ON) +target_link_libraries(mocIncludeRelaxedOnly ${QT_LIBRARIES}) +set_target_properties(mocIncludeRelaxedOnly PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/mocIncludeRelaxed/RMain.cpp b/Tests/QtAutogen/mocIncludeRelaxed/RMain.cpp new file mode 100644 index 000000000..5b2c07032 --- /dev/null +++ b/Tests/QtAutogen/mocIncludeRelaxed/RMain.cpp @@ -0,0 +1,12 @@ +// Relaxed AUTOMOC objects +#include "RObjA.hpp" +#include "RObjB.hpp" +#include "RObjC.hpp" + +int main(int argv, char** args) +{ + RObjA rObjA; + RObjB rObjB; + RObjC rObjC; + return 0; +} diff --git a/Tests/QtAutogen/mocIncludeRelaxed/RObjA.cpp b/Tests/QtAutogen/mocIncludeRelaxed/RObjA.cpp new file mode 100644 index 000000000..2e2cf6a48 --- /dev/null +++ b/Tests/QtAutogen/mocIncludeRelaxed/RObjA.cpp @@ -0,0 +1,12 @@ +#include "RObjA.hpp" + +RObjA::RObjA() +{ +} + +RObjA::~RObjA() +{ +} + +// Relaxed include should moc the header instead +#include "RObjA.moc" diff --git a/Tests/QtAutogen/mocIncludeRelaxed/RObjA.hpp b/Tests/QtAutogen/mocIncludeRelaxed/RObjA.hpp new file mode 100644 index 000000000..597418773 --- /dev/null +++ b/Tests/QtAutogen/mocIncludeRelaxed/RObjA.hpp @@ -0,0 +1,14 @@ +#ifndef ROBJA_HPP +#define ROBJA_HPP + +#include <QObject> + +class RObjA : public QObject +{ + Q_OBJECT +public: + RObjA(); + ~RObjA(); +}; + +#endif diff --git a/Tests/QtAutogen/mocIncludeRelaxed/RObjB.cpp b/Tests/QtAutogen/mocIncludeRelaxed/RObjB.cpp new file mode 100644 index 000000000..c56d10f04 --- /dev/null +++ b/Tests/QtAutogen/mocIncludeRelaxed/RObjB.cpp @@ -0,0 +1,22 @@ +#include "RObjB.hpp" +#include "RObjBExtra.hpp" + +RObjBExtra::RObjBExtra() +{ +} + +RObjBExtra::~RObjBExtra() +{ +} + +RObjB::RObjB() +{ + RObjBExtra extraObject; +} + +RObjB::~RObjB() +{ +} + +// Relaxed mode should run moc on RObjBExtra.hpp instead +#include "RObjBExtra.moc" diff --git a/Tests/QtAutogen/mocIncludeRelaxed/RObjB.hpp b/Tests/QtAutogen/mocIncludeRelaxed/RObjB.hpp new file mode 100644 index 000000000..d6d0474ad --- /dev/null +++ b/Tests/QtAutogen/mocIncludeRelaxed/RObjB.hpp @@ -0,0 +1,14 @@ +#ifndef ROBJB_HPP +#define ROBJB_HPP + +#include <QObject> + +class RObjB : public QObject +{ + Q_OBJECT +public: + RObjB(); + ~RObjB(); +}; + +#endif diff --git a/Tests/QtAutogen/mocIncludeRelaxed/RObjBExtra.hpp b/Tests/QtAutogen/mocIncludeRelaxed/RObjBExtra.hpp new file mode 100644 index 000000000..5d6be752f --- /dev/null +++ b/Tests/QtAutogen/mocIncludeRelaxed/RObjBExtra.hpp @@ -0,0 +1,14 @@ +#ifndef ROBJBEXTRA_HPP +#define ROBJBEXTRA_HPP + +#include <QObject> + +class RObjBExtra : public QObject +{ + Q_OBJECT +public: + RObjBExtra(); + ~RObjBExtra(); +}; + +#endif diff --git a/Tests/QtAutogen/mocIncludeRelaxed/RObjC.cpp b/Tests/QtAutogen/mocIncludeRelaxed/RObjC.cpp new file mode 100644 index 000000000..4ba32f54b --- /dev/null +++ b/Tests/QtAutogen/mocIncludeRelaxed/RObjC.cpp @@ -0,0 +1,30 @@ +#include "RObjC.hpp" +#include <QObject> + +class RObjCPrivate : public QObject +{ + Q_OBJECT +public: + RObjCPrivate(); + ~RObjCPrivate(); +}; + +RObjCPrivate::RObjCPrivate() +{ +} + +RObjCPrivate::~RObjCPrivate() +{ +} + +RObjC::RObjC() +{ + RObjCPrivate privateObject; +} + +RObjC::~RObjC() +{ +} + +// Relaxed include should moc this source instead of the header +#include "moc_RObjC.cpp" diff --git a/Tests/QtAutogen/mocIncludeRelaxed/RObjC.hpp b/Tests/QtAutogen/mocIncludeRelaxed/RObjC.hpp new file mode 100644 index 000000000..5552ede4a --- /dev/null +++ b/Tests/QtAutogen/mocIncludeRelaxed/RObjC.hpp @@ -0,0 +1,14 @@ +#ifndef ROBJC_HPP +#define ROBJC_HPP + +#include <QObject> + +class RObjC : public QObject +{ + Q_OBJECT +public: + RObjC(); + ~RObjC(); +}; + +#endif diff --git a/Tests/QtAutogen/mocIncludeRelaxed/main.cpp b/Tests/QtAutogen/mocIncludeRelaxed/main.cpp index 142d59e69..5a3148dda 100644 --- a/Tests/QtAutogen/mocIncludeRelaxed/main.cpp +++ b/Tests/QtAutogen/mocIncludeRelaxed/main.cpp @@ -1,14 +1,26 @@ +#include "EObjA.hpp" +#include "EObjB.hpp" +#include "LObjA.hpp" +#include "LObjB.hpp" #include "ObjA.hpp" #include "ObjB.hpp" -#include "ObjC.hpp" +#include "SObjA.hpp" +#include "SObjB.hpp" +#include "subGlobal/GObj.hpp" int main(int argv, char** args) { + subGlobal::GObj gObj; ObjA objA; ObjB objB; - ObjC objC; + LObjA lObjA; + LObjB lObjB; + EObjA eObjA; + EObjB eObjB; + SObjA sObjA; + SObjB sObjB; return 0; } // Header in global subdirectory -#include "subB/moc_SubObjB.cpp" +#include "subGlobal/moc_GObj.cpp" diff --git a/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt b/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt index 22e93a8ba..789354a22 100644 --- a/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt +++ b/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt @@ -1,18 +1,6 @@ # Test moc include patterns set(CMAKE_AUTOMOC_RELAXED_MODE FALSE) +set(MOC_INCLUDE_NAME "mocIncludeStrict") -include_directories("../mocInclude") - -add_executable(mocIncludeStrict - ../mocInclude/ObjA.cpp - ../mocInclude/ObjB.cpp - ../mocInclude/ObjC.cpp - ../mocInclude/ObjD.cpp - ../mocInclude/subA/SubObjA.cpp - ../mocInclude/subB/SubObjB.cpp - ../mocInclude/subC/SubObjC.cpp - main.cpp -) -target_link_libraries(mocIncludeStrict ${QT_LIBRARIES}) -set_target_properties(mocIncludeStrict PROPERTIES AUTOMOC ON) +include(${CMAKE_CURRENT_SOURCE_DIR}/../mocInclude/shared.cmake) diff --git a/Tests/QtAutogen/mocIncludeStrict/main.cpp b/Tests/QtAutogen/mocIncludeStrict/main.cpp index 142d59e69..5a3148dda 100644 --- a/Tests/QtAutogen/mocIncludeStrict/main.cpp +++ b/Tests/QtAutogen/mocIncludeStrict/main.cpp @@ -1,14 +1,26 @@ +#include "EObjA.hpp" +#include "EObjB.hpp" +#include "LObjA.hpp" +#include "LObjB.hpp" #include "ObjA.hpp" #include "ObjB.hpp" -#include "ObjC.hpp" +#include "SObjA.hpp" +#include "SObjB.hpp" +#include "subGlobal/GObj.hpp" int main(int argv, char** args) { + subGlobal::GObj gObj; ObjA objA; ObjB objB; - ObjC objC; + LObjA lObjA; + LObjB lObjB; + EObjA eObjA; + EObjB eObjB; + SObjA sObjA; + SObjB sObjB; return 0; } // Header in global subdirectory -#include "subB/moc_SubObjB.cpp" +#include "subGlobal/moc_GObj.cpp" diff --git a/Tests/QtAutogen/mocMacroName/CMakeLists.txt b/Tests/QtAutogen/mocMacroName/CMakeLists.txt new file mode 100644 index 000000000..08e680314 --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.9) + +list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "QO1_ALIAS") + +add_executable(mmn main.cpp Gadget.cpp Object.cpp Object1Aliased.cpp Object2Aliased.cpp) +set_property(TARGET mmn PROPERTY AUTOMOC ON) +set_property(TARGET mmn APPEND PROPERTY AUTOMOC_MACRO_NAMES "QO2_ALIAS") +target_link_libraries(mmn ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/mocMacroName/CustomMacros.hpp b/Tests/QtAutogen/mocMacroName/CustomMacros.hpp new file mode 100644 index 000000000..93e5bfdc1 --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/CustomMacros.hpp @@ -0,0 +1,8 @@ +#ifndef CUSTOM_MACROS_HPP +#define CUSTOM_MACROS_HPP + +#include <QObject> +#define QO1_ALIAS Q_OBJECT +#define QO2_ALIAS Q_OBJECT + +#endif diff --git a/Tests/QtAutogen/mocMacroName/Gadget.cpp b/Tests/QtAutogen/mocMacroName/Gadget.cpp new file mode 100644 index 000000000..167faebd3 --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/Gadget.cpp @@ -0,0 +1,6 @@ +#include "Gadget.hpp" + +Gadget::Gadget() + : test(0) +{ +} diff --git a/Tests/QtAutogen/mocMacroName/Gadget.hpp b/Tests/QtAutogen/mocMacroName/Gadget.hpp new file mode 100644 index 000000000..2587ed275 --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/Gadget.hpp @@ -0,0 +1,15 @@ +#ifndef GADGET_HPP +#define GADGET_HPP + +#include <QMetaType> + +class Gadget +{ + Q_GADGET + Q_PROPERTY(int test MEMBER test) +public: + Gadget(); + int test; +}; + +#endif diff --git a/Tests/QtAutogen/mocMacroName/Object.cpp b/Tests/QtAutogen/mocMacroName/Object.cpp new file mode 100644 index 000000000..c0b4f33fc --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/Object.cpp @@ -0,0 +1,9 @@ +#include "Object.hpp" + +Object::Object() +{ +} + +void Object::aSlot() +{ +} diff --git a/Tests/QtAutogen/mocMacroName/Object.hpp b/Tests/QtAutogen/mocMacroName/Object.hpp new file mode 100644 index 000000000..0c40824ad --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/Object.hpp @@ -0,0 +1,19 @@ +#ifndef OBJECT_HPP +#define OBJECT_HPP + +#include <QObject> + +class Object : public QObject +{ + Q_OBJECT + Q_PROPERTY(int test MEMBER test) +public: + Object(); + + Q_SLOT + void aSlot(); + + int test; +}; + +#endif diff --git a/Tests/QtAutogen/mocMacroName/Object1Aliased.cpp b/Tests/QtAutogen/mocMacroName/Object1Aliased.cpp new file mode 100644 index 000000000..b8b4806c6 --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/Object1Aliased.cpp @@ -0,0 +1,9 @@ +#include "Object1Aliased.hpp" + +Object1Aliased::Object1Aliased() +{ +} + +void Object1Aliased::aSlot() +{ +} diff --git a/Tests/QtAutogen/mocMacroName/Object1Aliased.hpp b/Tests/QtAutogen/mocMacroName/Object1Aliased.hpp new file mode 100644 index 000000000..6c6bb4088 --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/Object1Aliased.hpp @@ -0,0 +1,20 @@ +#ifndef OBJECTALIASED_HPP +#define OBJECTALIASED_HPP + +#include "CustomMacros.hpp" + +// Test Qt object macro hidden in a macro (AUTOMOC_MACRO_NAMES) +class Object1Aliased : public QObject +{ + QO1_ALIAS +public: + Object1Aliased(); + +signals: + void aSignal(); + +public slots: + void aSlot(); +}; + +#endif diff --git a/Tests/QtAutogen/mocMacroName/Object2Aliased.cpp b/Tests/QtAutogen/mocMacroName/Object2Aliased.cpp new file mode 100644 index 000000000..4b09dd1bc --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/Object2Aliased.cpp @@ -0,0 +1,9 @@ +#include "Object2Aliased.hpp" + +Object2Aliased::Object2Aliased() +{ +} + +void Object2Aliased::aSlot() +{ +} diff --git a/Tests/QtAutogen/mocMacroName/Object2Aliased.hpp b/Tests/QtAutogen/mocMacroName/Object2Aliased.hpp new file mode 100644 index 000000000..b9bdc126f --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/Object2Aliased.hpp @@ -0,0 +1,20 @@ +#ifndef OBJECT2ALIASED_HPP +#define OBJECT2ALIASED_HPP + +#include "CustomMacros.hpp" + +// Test Qt object macro hidden in a macro (AUTOMOC_MACRO_NAMES) +class Object2Aliased : public QObject +{ + QO2_ALIAS +public: + Object2Aliased(); + +signals: + void aSignal(); + +public slots: + void aSlot(); +}; + +#endif diff --git a/Tests/QtAutogen/mocMacroName/main.cpp b/Tests/QtAutogen/mocMacroName/main.cpp new file mode 100644 index 000000000..3b45d042d --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/main.cpp @@ -0,0 +1,13 @@ +#include "Gadget.hpp" +#include "Object.hpp" +#include "Object1Aliased.hpp" +#include "Object2Aliased.hpp" + +int main(int argv, char** args) +{ + Gadget gadget; + Object object; + Object1Aliased object1Aliased; + Object2Aliased object2Aliased; + return 0; +} diff --git a/Tests/QtAutogen/mocOnlySource/StyleA.cpp b/Tests/QtAutogen/mocOnlySource/StyleA.cpp new file mode 100644 index 000000000..ced1dd151 --- /dev/null +++ b/Tests/QtAutogen/mocOnlySource/StyleA.cpp @@ -0,0 +1,5 @@ +#include "StyleA.hpp" + +StyleA::StyleA() +{ +} diff --git a/Tests/QtAutogen/mocOnlySource/StyleA.hpp b/Tests/QtAutogen/mocOnlySource/StyleA.hpp new file mode 100644 index 000000000..66735b63b --- /dev/null +++ b/Tests/QtAutogen/mocOnlySource/StyleA.hpp @@ -0,0 +1,15 @@ +#ifndef STYLEA_HPP +#define STYLEA_HPP + +#include <QObject> + +/// Q_OBJECT on a single new line +/// +class StyleA : public QObject +{ + Q_OBJECT +public: + StyleA(); +}; + +#endif diff --git a/Tests/QtAutogen/mocOnlySource/StyleB.cpp b/Tests/QtAutogen/mocOnlySource/StyleB.cpp new file mode 100644 index 000000000..bec6c1c36 --- /dev/null +++ b/Tests/QtAutogen/mocOnlySource/StyleB.cpp @@ -0,0 +1,5 @@ +#include "StyleB.hpp" + +StyleB::StyleB() +{ +} diff --git a/Tests/QtAutogen/mocOnlySource/StyleB.hpp b/Tests/QtAutogen/mocOnlySource/StyleB.hpp new file mode 100644 index 000000000..425daf845 --- /dev/null +++ b/Tests/QtAutogen/mocOnlySource/StyleB.hpp @@ -0,0 +1,16 @@ +#ifndef STYLEB_HPP +#define STYLEB_HPP + +#include <QObject> + +/* clang-format off */ +/// Q_OBJECT behind a brace +/// +class StyleB : public QObject +{ Q_OBJECT +public: + StyleB(); +}; +/* clang-format on */ + +#endif diff --git a/Tests/QtAutogen/mocOnlySource/main.cpp b/Tests/QtAutogen/mocOnlySource/main.cpp new file mode 100644 index 000000000..06f8d8106 --- /dev/null +++ b/Tests/QtAutogen/mocOnlySource/main.cpp @@ -0,0 +1,9 @@ +#include "StyleA.hpp" +#include "StyleB.hpp" + +int main(int argv, char** args) +{ + StyleA styleA; + StyleB styleB; + return 0; +} diff --git a/Tests/QtAutogen/mocPlugin/StyleE.hpp b/Tests/QtAutogen/mocPlugin/StyleE.hpp deleted file mode 100644 index e7915a8e5..000000000 --- a/Tests/QtAutogen/mocPlugin/StyleE.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef STYLEE_HPP -#define STYLEE_HPP - -#include "StyleCommon.hpp" -#include <QStylePlugin> - -class StyleE : public QStylePlugin -{ - Q_OBJECT - // No Json file - Q_PLUGIN_METADATA(IID "org.styles.E") - A_CUSTOM_MACRO(SomeArg, InvalidFileArg, AnotherArg) -public: - QStyle* create(const QString& key); -}; - -#endif diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json b/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json deleted file mode 100644 index 129cac41f..000000000 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "Rocket", "StarbusterB" ] } diff --git a/Tests/QtAutogen/objectLibrary/CMakeLists.txt b/Tests/QtAutogen/objectLibrary/CMakeLists.txt new file mode 100644 index 000000000..9b29a4075 --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/CMakeLists.txt @@ -0,0 +1,14 @@ +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) + +# Object library a defined in a subdirectory +add_subdirectory(a) + +# Object library b defined locally +include_directories(b) +add_library(b OBJECT b/classb.cpp) +target_compile_features(b PRIVATE ${QT_COMPILE_FEATURES}) + +# Executable with OBJECT library generator expressions +add_executable(someProgram main.cpp $<TARGET_OBJECTS:a> $<TARGET_OBJECTS:b>) +target_link_libraries(someProgram ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/objectLibrary/a/CMakeLists.txt b/Tests/QtAutogen/objectLibrary/a/CMakeLists.txt new file mode 100644 index 000000000..fe76ac32c --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/a/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(a OBJECT classa.cpp) +target_compile_features(a PRIVATE ${QT_COMPILE_FEATURES}) diff --git a/Tests/QtAutogen/objectLibrary/a/classa.cpp b/Tests/QtAutogen/objectLibrary/a/classa.cpp new file mode 100644 index 000000000..4f08fda84 --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/a/classa.cpp @@ -0,0 +1,7 @@ +#include "classa.h" +#include <QDebug> + +void ClassA::slotDoSomething() +{ + qDebug() << m_member; +} diff --git a/Tests/QtAutogen/objectLibrary/a/classa.h b/Tests/QtAutogen/objectLibrary/a/classa.h new file mode 100644 index 000000000..fa5fed941 --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/a/classa.h @@ -0,0 +1,23 @@ +#ifndef CLASSA_H +#define CLASSA_H + +#include <QObject> +#include <QString> + +class ClassA : public QObject +{ + Q_OBJECT +public: + ClassA() + : m_member("Hello A") + { + } + +public slots: + void slotDoSomething(); + +private: + QString m_member; +}; + +#endif diff --git a/Tests/QtAutogen/objectLibrary/b/classb.cpp b/Tests/QtAutogen/objectLibrary/b/classb.cpp new file mode 100644 index 000000000..26e09261c --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/b/classb.cpp @@ -0,0 +1,7 @@ +#include "classb.h" +#include <QDebug> + +void ClassB::slotDoSomething() +{ + qDebug() << m_member; +} diff --git a/Tests/QtAutogen/objectLibrary/b/classb.h b/Tests/QtAutogen/objectLibrary/b/classb.h new file mode 100644 index 000000000..783bb48ce --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/b/classb.h @@ -0,0 +1,23 @@ +#ifndef CLASSB_H +#define CLASSB_H + +#include <QObject> +#include <QString> + +class ClassB : public QObject +{ + Q_OBJECT +public: + ClassB() + : m_member("Hello B") + { + } + +public slots: + void slotDoSomething(); + +private: + QString m_member; +}; + +#endif diff --git a/Tests/QtAutogen/objectLibrary/main.cpp b/Tests/QtAutogen/objectLibrary/main.cpp new file mode 100644 index 000000000..cacf0fdae --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/main.cpp @@ -0,0 +1,13 @@ +#include "a/classa.h" +#include "b/classb.h" + +int main(int argc, char** argv) +{ + ClassA a; + a.slotDoSomething(); + + ClassB b; + b.slotDoSomething(); + + return 0; +} diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt deleted file mode 100644 index 878ae5d35..000000000 --- a/Tests/QtAutogen/rccDepends/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -cmake_minimum_required(VERSION 3.7) -project(rccDepends) - -set(CMAKE_AUTORCC ON) - -if (QT_TEST_VERSION STREQUAL 4) - find_package(Qt4 REQUIRED) - set(QT_CORE_TARGET Qt4::QtCore) -else() - if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") - endif() - - find_package(Qt5Core REQUIRED) - set(QT_CORE_TARGET Qt5::Core) -endif() - -configure_file(res/input1.txt.in res1/input.txt COPYONLY) -configure_file(res/input1.txt.in res1/inputAdded.txt COPYONLY) -configure_file(res/input2.txt.in res2/input.txt COPYONLY) -configure_file(res/input2.txt.in res2/inputAdded.txt COPYONLY) -# Dependency generated qrc file -add_custom_command(OUTPUT res2.qrc - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in - COMMAND ${CMAKE_COMMAND} -E sleep 2 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc - ) - -add_executable(rccDepends - main.cpp - ${CMAKE_CURRENT_BINARY_DIR}/res1.qrc - ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc ) -target_link_libraries(rccDepends ${QT_CORE_TARGET}) -add_custom_command(TARGET rccDepends POST_BUILD COMMAND - ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDepends>" > target.txt) diff --git a/Tests/QtAutogen/rccDepends/res/input1.txt.in b/Tests/QtAutogen/rccDepends/res/input1.txt.in deleted file mode 100644 index da627624b..000000000 --- a/Tests/QtAutogen/rccDepends/res/input1.txt.in +++ /dev/null @@ -1 +0,0 @@ -Res1 input. diff --git a/Tests/QtAutogen/rccDepends/res/input2.txt.in b/Tests/QtAutogen/rccDepends/res/input2.txt.in deleted file mode 100644 index 08e14b7bd..000000000 --- a/Tests/QtAutogen/rccDepends/res/input2.txt.in +++ /dev/null @@ -1 +0,0 @@ -Res2 input. diff --git a/Tests/QtAutogen/rccDepends/res1a.qrc.in b/Tests/QtAutogen/rccDepends/res1a.qrc.in deleted file mode 100644 index d111ffbc7..000000000 --- a/Tests/QtAutogen/rccDepends/res1a.qrc.in +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/Texts1"> - <file>res1/input.txt</file> - </qresource> -</RCC> diff --git a/Tests/QtAutogen/rccDepends/res1b.qrc.in b/Tests/QtAutogen/rccDepends/res1b.qrc.in deleted file mode 100644 index 4cb3f047c..000000000 --- a/Tests/QtAutogen/rccDepends/res1b.qrc.in +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/Texts1"> - <file>res1/input.txt</file> - <file alias="Added">res1/inputAdded.txt</file> - </qresource> -</RCC> diff --git a/Tests/QtAutogen/rccDepends/res2a.qrc.in b/Tests/QtAutogen/rccDepends/res2a.qrc.in deleted file mode 100644 index 19f34ac90..000000000 --- a/Tests/QtAutogen/rccDepends/res2a.qrc.in +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/Texts2"> - <file>res2/input.txt</file> - </qresource> -</RCC> diff --git a/Tests/QtAutogen/rccDepends/res2b.qrc.in b/Tests/QtAutogen/rccDepends/res2b.qrc.in deleted file mode 100644 index 19e8ba10c..000000000 --- a/Tests/QtAutogen/rccDepends/res2b.qrc.in +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/Texts2"> - <file>res2/input.txt</file> - <file alias="Added">res2/inputAdded.txt</file> - </qresource> -</RCC> diff --git a/Tests/QtAutogen/sameName/CMakeLists.txt b/Tests/QtAutogen/sameName/CMakeLists.txt index 4d2dcd9d2..f695875cb 100644 --- a/Tests/QtAutogen/sameName/CMakeLists.txt +++ b/Tests/QtAutogen/sameName/CMakeLists.txt @@ -17,7 +17,10 @@ add_executable(sameName main.cpp ) target_link_libraries(sameName ${QT_LIBRARIES}) -set_target_properties(sameName PROPERTIES AUTOMOC TRUE AUTORCC TRUE) +set_target_properties(sameName PROPERTIES + AUTOMOC TRUE + AUTOUIC TRUE + AUTORCC TRUE) # Set different compression levels if (QT_TEST_VERSION STREQUAL 4) diff --git a/Tests/QtAutogen/sameName/aaa/bbb/item.cpp b/Tests/QtAutogen/sameName/aaa/bbb/item.cpp index 20d00445e..850206f6b 100644 --- a/Tests/QtAutogen/sameName/aaa/bbb/item.cpp +++ b/Tests/QtAutogen/sameName/aaa/bbb/item.cpp @@ -3,8 +3,20 @@ namespace aaa { namespace bbb { +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + void Item::go() { + MocLocal obj; } } } + +#include "aaa/bbb/item.moc" diff --git a/Tests/QtAutogen/sameName/aaa/item.cpp b/Tests/QtAutogen/sameName/aaa/item.cpp index 95dd3b674..e35d3d128 100644 --- a/Tests/QtAutogen/sameName/aaa/item.cpp +++ b/Tests/QtAutogen/sameName/aaa/item.cpp @@ -1,8 +1,22 @@ #include "item.hpp" +// Include ui_view.h only in header namespace aaa { +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + void Item::go() { + Ui_ViewAAA ui; + MocLocal obj; } } + +#include "aaa/item.moc" diff --git a/Tests/QtAutogen/sameName/aaa/item.hpp b/Tests/QtAutogen/sameName/aaa/item.hpp index b63466f6d..875f72fdb 100644 --- a/Tests/QtAutogen/sameName/aaa/item.hpp +++ b/Tests/QtAutogen/sameName/aaa/item.hpp @@ -2,6 +2,8 @@ #define AAA_ITEM_HPP #include <QObject> +// Include ui_view.h only in header +#include <aaa/ui_view.h> namespace aaa { diff --git a/Tests/QtAutogen/sameName/aaa/view.ui b/Tests/QtAutogen/sameName/aaa/view.ui new file mode 100644 index 000000000..0f0998006 --- /dev/null +++ b/Tests/QtAutogen/sameName/aaa/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewAAA</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/sameName/bbb/aaa/item.cpp b/Tests/QtAutogen/sameName/bbb/aaa/item.cpp index ac4b2c27b..7ad01c3ef 100644 --- a/Tests/QtAutogen/sameName/bbb/aaa/item.cpp +++ b/Tests/QtAutogen/sameName/bbb/aaa/item.cpp @@ -3,8 +3,20 @@ namespace bbb { namespace aaa { +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + void Item::go() { + MocLocal obj; } } } + +#include "bbb/aaa/item.moc" diff --git a/Tests/QtAutogen/sameName/bbb/item.cpp b/Tests/QtAutogen/sameName/bbb/item.cpp index f97a1431e..9ef128ed0 100644 --- a/Tests/QtAutogen/sameName/bbb/item.cpp +++ b/Tests/QtAutogen/sameName/bbb/item.cpp @@ -1,8 +1,23 @@ #include "item.hpp" +// Include ui_view.h only in source +#include <bbb/ui_view.h> namespace bbb { +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; + void Item::go() { + Ui_ViewBBB ui; + MocLocal obj; } } + +#include "bbb/item.moc" diff --git a/Tests/QtAutogen/sameName/bbb/item.hpp b/Tests/QtAutogen/sameName/bbb/item.hpp index 5b7f9850b..d39a9d711 100644 --- a/Tests/QtAutogen/sameName/bbb/item.hpp +++ b/Tests/QtAutogen/sameName/bbb/item.hpp @@ -2,6 +2,7 @@ #define BBB_ITEM_HPP #include <QObject> +// Include ui_view.h only in source namespace bbb { diff --git a/Tests/QtAutogen/sameName/bbb/view.ui b/Tests/QtAutogen/sameName/bbb/view.ui new file mode 100644 index 000000000..a8f506e88 --- /dev/null +++ b/Tests/QtAutogen/sameName/bbb/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewBBB</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/sameName/ccc/item.cpp b/Tests/QtAutogen/sameName/ccc/item.cpp index d90b2b8c7..ab8a2817b 100644 --- a/Tests/QtAutogen/sameName/ccc/item.cpp +++ b/Tests/QtAutogen/sameName/ccc/item.cpp @@ -1,23 +1,25 @@ #include "item.hpp" +// Include ui_view.h in source and header +#include <ccc/ui_view.h> namespace ccc { -void Item::go() -{ -} - -class MocTest : public QObject +class MocLocal : public QObject { Q_OBJECT; - Q_SLOT - void go(); + +public: + MocLocal() = default; + ~MocLocal() = default; }; -void MocTest::go() +void Item::go() { + Ui_ViewCCC ui; + MocLocal obj; } } // Include own moc files -#include "item.moc" +#include "ccc/item.moc" #include "moc_item.cpp" diff --git a/Tests/QtAutogen/sameName/ccc/item.hpp b/Tests/QtAutogen/sameName/ccc/item.hpp index 96fcc245c..20d9dd978 100644 --- a/Tests/QtAutogen/sameName/ccc/item.hpp +++ b/Tests/QtAutogen/sameName/ccc/item.hpp @@ -2,6 +2,8 @@ #define CCC_ITEM_HPP #include <QObject> +// Include ui_view.h in source and header +#include <ccc/ui_view.h> namespace ccc { diff --git a/Tests/QtAutogen/sameName/ccc/view.ui b/Tests/QtAutogen/sameName/ccc/view.ui new file mode 100644 index 000000000..7989c6973 --- /dev/null +++ b/Tests/QtAutogen/sameName/ccc/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewCCC</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/sameName/item.cpp b/Tests/QtAutogen/sameName/item.cpp index e013cf392..3d1fbe7cf 100644 --- a/Tests/QtAutogen/sameName/item.cpp +++ b/Tests/QtAutogen/sameName/item.cpp @@ -1,5 +1,20 @@ #include "item.hpp" +// Include ui_view.h in source and header +#include <ui_view.h> + +class MocLocal : public QObject +{ + Q_OBJECT; + +public: + MocLocal() = default; + ~MocLocal() = default; +}; void Item::go() { + Ui_View ui; + MocLocal obj; } + +#include "item.moc" diff --git a/Tests/QtAutogen/sameName/item.hpp b/Tests/QtAutogen/sameName/item.hpp index 91bba3b4d..75e83f483 100644 --- a/Tests/QtAutogen/sameName/item.hpp +++ b/Tests/QtAutogen/sameName/item.hpp @@ -2,6 +2,8 @@ #define ITEM_HPP #include <QObject> +// Include ui_view.h in source and header +#include <ui_view.h> class Item : public QObject { diff --git a/Tests/QtAutogen/sameName/view.ui b/Tests/QtAutogen/sameName/view.ui new file mode 100644 index 000000000..2ffe7344c --- /dev/null +++ b/Tests/QtAutogen/sameName/view.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>View</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/skipMoc.cpp b/Tests/QtAutogen/skipMoc.cpp index 85305f590..d6b292ff3 100644 --- a/Tests/QtAutogen/skipMoc.cpp +++ b/Tests/QtAutogen/skipMoc.cpp @@ -2,12 +2,14 @@ #include "skipSource/qItemA.hpp" #include "skipSource/qItemB.hpp" #include "skipSource/qItemC.hpp" +#include "skipSource/qItemD.hpp" int main(int, char**) { QItemA itemA; - QItemA itemB; - QItemA itemC; + QItemB itemB; + QItemC itemC; + QItemD itemD; // Fails to link if the symbol is not present. return 0; diff --git a/Tests/QtAutogen/skipSource/qItemC.cpp b/Tests/QtAutogen/skipSource/qItemC.cpp index 700abd6db..622f2829e 100644 --- a/Tests/QtAutogen/skipSource/qItemC.cpp +++ b/Tests/QtAutogen/skipSource/qItemC.cpp @@ -1,5 +1,17 @@ #include "qItemC.hpp" +class QItemC_Local : public QObject +{ + Q_OBJECT +public: + QItemC_Local(){}; + ~QItemC_Local(){}; +}; + void QItemC::go() { + QItemC_Local localObject; } + +// We need AUTOMOC processing +#include "qItemC.moc" diff --git a/Tests/QtAutogen/skipSource/qItemD.cpp b/Tests/QtAutogen/skipSource/qItemD.cpp new file mode 100644 index 000000000..fe0f4e4da --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemD.cpp @@ -0,0 +1,17 @@ +#include "qItemD.hpp" + +class QItemD_Local : public QObject +{ + Q_OBJECT +public: + QItemD_Local(){}; + ~QItemD_Local(){}; +}; + +void QItemD::go() +{ + QItemD_Local localObject; +} + +// We need AUTOMOC processing +#include "qItemD.moc" diff --git a/Tests/QtAutogen/skipSource/qItemD.hpp b/Tests/QtAutogen/skipSource/qItemD.hpp new file mode 100644 index 000000000..99e0acbed --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemD.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMD_HPP +#define QITEMD_HPP + +#include <QObject> + +class QItemD : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/staticLibraryCycle/CMakeLists.txt b/Tests/QtAutogen/staticLibraryCycle/CMakeLists.txt new file mode 100644 index 000000000..144a435f4 --- /dev/null +++ b/Tests/QtAutogen/staticLibraryCycle/CMakeLists.txt @@ -0,0 +1,17 @@ +# Test AUTOMOC and AUTORCC on source files with the same name +# but in different subdirectories + +set(CMAKE_AUTOMOC ON) + +# Cyclic static libraries +add_library(slc_a STATIC a.cpp) +target_link_libraries(slc_a ${QT_LIBRARIES} slc_b) + +add_library(slc_b STATIC b.cpp) +target_link_libraries(slc_b ${QT_LIBRARIES} slc_c) + +add_library(slc_c STATIC c.cpp) +target_link_libraries(slc_c ${QT_LIBRARIES} slc_a) + +add_executable(slc main.cpp) +target_link_libraries(slc ${QT_LIBRARIES} slc_a) diff --git a/Tests/QtAutogen/staticLibraryCycle/a.cpp b/Tests/QtAutogen/staticLibraryCycle/a.cpp new file mode 100644 index 000000000..97cc66e2d --- /dev/null +++ b/Tests/QtAutogen/staticLibraryCycle/a.cpp @@ -0,0 +1,7 @@ +#include "a.h" +#include "b.h" + +A::A() +{ + B b; +} diff --git a/Tests/QtAutogen/staticLibraryCycle/a.h b/Tests/QtAutogen/staticLibraryCycle/a.h new file mode 100644 index 000000000..71761708b --- /dev/null +++ b/Tests/QtAutogen/staticLibraryCycle/a.h @@ -0,0 +1,13 @@ +#ifndef CLASSA_HPP +#define CLASSA_HPP + +#include <QObject> + +class A : public QObject +{ + Q_OBJECT +public: + A(); +}; + +#endif diff --git a/Tests/QtAutogen/staticLibraryCycle/b.cpp b/Tests/QtAutogen/staticLibraryCycle/b.cpp new file mode 100644 index 000000000..a807d89cf --- /dev/null +++ b/Tests/QtAutogen/staticLibraryCycle/b.cpp @@ -0,0 +1,7 @@ +#include "b.h" +#include "c.h" + +B::B() +{ + C c; +} diff --git a/Tests/QtAutogen/staticLibraryCycle/b.h b/Tests/QtAutogen/staticLibraryCycle/b.h new file mode 100644 index 000000000..ededbd803 --- /dev/null +++ b/Tests/QtAutogen/staticLibraryCycle/b.h @@ -0,0 +1,13 @@ +#ifndef CLASSB_HPP +#define CLASSB_HPP + +#include <QObject> + +class B : public QObject +{ + Q_OBJECT +public: + B(); +}; + +#endif diff --git a/Tests/QtAutogen/staticLibraryCycle/c.cpp b/Tests/QtAutogen/staticLibraryCycle/c.cpp new file mode 100644 index 000000000..7d427c234 --- /dev/null +++ b/Tests/QtAutogen/staticLibraryCycle/c.cpp @@ -0,0 +1,7 @@ +#include "c.h" +#include "a.h" + +C::C() +{ + A a; +} diff --git a/Tests/QtAutogen/staticLibraryCycle/c.h b/Tests/QtAutogen/staticLibraryCycle/c.h new file mode 100644 index 000000000..20f3725e9 --- /dev/null +++ b/Tests/QtAutogen/staticLibraryCycle/c.h @@ -0,0 +1,13 @@ +#ifndef CLASSC_HPP +#define CLASSC_HPP + +#include <QObject> + +class C : public QObject +{ + Q_OBJECT +public: + C(); +}; + +#endif diff --git a/Tests/QtAutogen/staticLibraryCycle/main.cpp b/Tests/QtAutogen/staticLibraryCycle/main.cpp new file mode 100644 index 000000000..f5b7fd227 --- /dev/null +++ b/Tests/QtAutogen/staticLibraryCycle/main.cpp @@ -0,0 +1,8 @@ +#include "a.h" + +int main(int argv, char** args) +{ + // Object instances + A a; + return 0; +} diff --git a/Tests/QtAutogenRerun/CMakeLists.txt b/Tests/QtAutogenRerun/CMakeLists.txt new file mode 100644 index 000000000..e72c1912e --- /dev/null +++ b/Tests/QtAutogenRerun/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0071 NEW) +project(QtAutogenRerun) + +# Tell find_package(Qt5) where to find Qt. +if(QT_QMAKE_EXECUTABLE) + get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) + get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH) + set(CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) +endif() + +if (QT_TEST_VERSION STREQUAL 4) + find_package(Qt4 REQUIRED) + + # Include this directory before using the UseQt4 file. + add_subdirectory(defines_test) + + include(UseQt4) + + set(QT_QTCORE_TARGET Qt4::QtCore) + +else() + if (NOT QT_TEST_VERSION STREQUAL 5) + message(SEND_ERROR "Invalid Qt version specified.") + endif() + find_package(Qt5Widgets REQUIRED) + + set(QT_QTCORE_TARGET Qt5::Core) + + include_directories(${Qt5Widgets_INCLUDE_DIRS}) + set(QT_LIBRARIES Qt5::Widgets) + + if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) + add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) + endif() + +endif() + +# Dummy executable to generate clean target +add_executable(dummy dummy.cpp) + +# -- Test +include("mocRerun.cmake") + +# -- Test +# Tests Q_PLUGIN_METADATA json file change detection +if (NOT QT_TEST_VERSION STREQUAL 4) + include("mocPlugin.cmake") +endif() + +# -- Test +include("rccDepends.cmake") diff --git a/Tests/QtAutogenRerun/defines_test/CMakeLists.txt b/Tests/QtAutogenRerun/defines_test/CMakeLists.txt new file mode 100644 index 000000000..9ee9a228a --- /dev/null +++ b/Tests/QtAutogenRerun/defines_test/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_executable(defines_test defines_test.cpp) +set_target_properties(defines_test PROPERTIES AUTOMOC TRUE) +target_link_libraries(defines_test Qt4::QtGui) diff --git a/Tests/QtAutogenRerun/defines_test/defines_test.cpp b/Tests/QtAutogenRerun/defines_test/defines_test.cpp new file mode 100644 index 000000000..cf4e9cb5b --- /dev/null +++ b/Tests/QtAutogenRerun/defines_test/defines_test.cpp @@ -0,0 +1,38 @@ + +#include <QObject> + +#ifdef QT_GUI_LIB +#include <QTextDocument> + +class SomeDocument : public QTextDocument +{ + Q_OBJECT + +Q_SIGNALS: + void someSig(); +}; +#endif + +#ifdef QT_CORE_LIB +class SomeObject : public QObject +{ + Q_OBJECT + +Q_SIGNALS: + void someSig(); +}; +#endif + +int main(int argc, char** argv) +{ +#ifdef QT_CORE_LIB + QMetaObject sosmo = SomeObject::staticMetaObject; +#endif +#ifdef QT_GUI_LIB + QMetaObject sdsmo = SomeDocument::staticMetaObject; +#endif + + return 0; +} + +#include "defines_test.moc" diff --git a/Tests/QtAutogenRerun/dummy.cpp b/Tests/QtAutogenRerun/dummy.cpp new file mode 100644 index 000000000..4837a76b8 --- /dev/null +++ b/Tests/QtAutogenRerun/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int argv, char** args) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/mocPlugin.cmake b/Tests/QtAutogenRerun/mocPlugin.cmake new file mode 100644 index 000000000..7ad5ccb18 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin.cmake @@ -0,0 +1,96 @@ + +# Utility variables +set(timeformat "%Y%j%H%M%S") +set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin") +set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin") + +# Initial buid +try_compile(MOC_PLUGIN + "${mocPlugBinDir}" + "${mocPlugSrcDir}" + mocPlugin + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" + OUTPUT_VARIABLE output +) +if (NOT MOC_PLUGIN) + message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}") +endif() + +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) + +# - 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) +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() +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) +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() +endif() diff --git a/Tests/QtAutogen/mocPlugin/CMakeLists.txt b/Tests/QtAutogenRerun/mocPlugin/CMakeLists.txt index f80aa2934..b7cc5e9ff 100644 --- a/Tests/QtAutogen/mocPlugin/CMakeLists.txt +++ b/Tests/QtAutogenRerun/mocPlugin/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.9) project(mocPlugin CXX) set(CMAKE_AUTOMOC_DEPEND_FILTERS @@ -16,9 +16,11 @@ if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) endif() configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json) -configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json) configure_file(jsonIn/StyleC.json jsonFiles/StyleC_Custom.json) +configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json) configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD_Custom.json) +configure_file(jsonIn/StyleE.json jsonFiles/StyleE.json) +configure_file(jsonIn/StyleE.json jsonFiles/StyleE_Custom.json) # Enable automoc set(CMAKE_AUTOMOC TRUE) diff --git a/Tests/QtAutogen/mocPlugin/StyleA.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleA.cpp index b5e87533c..b5e87533c 100644 --- a/Tests/QtAutogen/mocPlugin/StyleA.cpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleA.cpp diff --git a/Tests/QtAutogen/mocPlugin/StyleA.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleA.hpp index 1b6154d16..35158a4b0 100644 --- a/Tests/QtAutogen/mocPlugin/StyleA.hpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleA.hpp @@ -1,13 +1,13 @@ #ifndef STYLEA_HPP #define STYLEA_HPP -#include "StyleCommon.hpp" +#include "UtilityMacros.hpp" #include <QStylePlugin> class StyleA : public QStylePlugin { Q_OBJECT - // Json file in local directory + // Json file in source local directory Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json") A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg) public: diff --git a/Tests/QtAutogen/mocPlugin/StyleA.json b/Tests/QtAutogenRerun/mocPlugin/StyleA.json index cc3395369..cc3395369 100644 --- a/Tests/QtAutogen/mocPlugin/StyleA.json +++ b/Tests/QtAutogenRerun/mocPlugin/StyleA.json diff --git a/Tests/QtAutogen/mocPlugin/StyleA_Custom.json b/Tests/QtAutogenRerun/mocPlugin/StyleA_Custom.json index cc3395369..cc3395369 100644 --- a/Tests/QtAutogen/mocPlugin/StyleA_Custom.json +++ b/Tests/QtAutogenRerun/mocPlugin/StyleA_Custom.json diff --git a/Tests/QtAutogen/mocPlugin/StyleB.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleB.cpp index 17d440035..17d440035 100644 --- a/Tests/QtAutogen/mocPlugin/StyleB.cpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleB.cpp diff --git a/Tests/QtAutogen/mocPlugin/StyleB.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleB.hpp index 163c9b20a..15b79c598 100644 --- a/Tests/QtAutogen/mocPlugin/StyleB.hpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleB.hpp @@ -1,13 +1,13 @@ #ifndef STYLEB_HPP #define STYLEB_HPP -#include "StyleCommon.hpp" +#include "UtilityMacros.hpp" #include <QStylePlugin> class StyleB : public QStylePlugin { Q_OBJECT - // Json file in local subdirectory + // Json file in source local subdirectory Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json") A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg) public: diff --git a/Tests/QtAutogen/mocPlugin/StyleC.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleC.cpp index 37e756487..37e756487 100644 --- a/Tests/QtAutogen/mocPlugin/StyleC.cpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleC.cpp diff --git a/Tests/QtAutogen/mocPlugin/StyleC.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleC.hpp index 52a887acf..b0a41150b 100644 --- a/Tests/QtAutogen/mocPlugin/StyleC.hpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleC.hpp @@ -1,7 +1,7 @@ #ifndef STYLEC_HPP #define STYLEC_HPP -#include "StyleCommon.hpp" +#include "UtilityMacros.hpp" #include <QStylePlugin> class StyleC : public QStylePlugin diff --git a/Tests/QtAutogen/mocPlugin/StyleD.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleD.cpp index 7e4b121fc..7e4b121fc 100644 --- a/Tests/QtAutogen/mocPlugin/StyleD.cpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleD.cpp diff --git a/Tests/QtAutogen/mocPlugin/StyleD.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleD.hpp index df8a4399d..9696aaa26 100644 --- a/Tests/QtAutogen/mocPlugin/StyleD.hpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleD.hpp @@ -1,7 +1,7 @@ #ifndef STYLED_HPP #define STYLED_HPP -#include "StyleCommon.hpp" +#include "UtilityMacros.hpp" #include <QStylePlugin> class StyleD : public QStylePlugin diff --git a/Tests/QtAutogen/mocPlugin/StyleE.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleE.cpp index 8fc9a7f68..344831969 100644 --- a/Tests/QtAutogen/mocPlugin/StyleE.cpp +++ b/Tests/QtAutogenRerun/mocPlugin/StyleE.cpp @@ -4,3 +4,6 @@ QStyle* StyleE::create(const QString& key) { return 0; } + +// AUTOMOC the StyleEInclude.hpp header +#include "moc_StyleEInclude.cpp" diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleE.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleE.hpp new file mode 100644 index 000000000..a0690343d --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleE.hpp @@ -0,0 +1,10 @@ +#ifndef STYLEE_HPP +#define STYLEE_HPP + +// The included file is not in the sources list and won't be detected by +// AUTOMOC source file with the same base name. +// It is registered to AUTOMOCed via a moc_<NAME>.cpp include in StyleE.cpp +// though. +#include "StyleEInclude.hpp" + +#endif diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleEInclude.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleEInclude.hpp new file mode 100644 index 000000000..f9734db4d --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleEInclude.hpp @@ -0,0 +1,17 @@ +#ifndef STYLEE_INCLUDE_HPP +#define STYLEE_INCLUDE_HPP + +#include "UtilityMacros.hpp" +#include <QStylePlugin> + +class StyleE : public QStylePlugin +{ + Q_OBJECT + // Json files in global root directory + Q_PLUGIN_METADATA(IID "org.styles.E" FILE "StyleE.json") + A_CUSTOM_MACRO(SomeArg, "StyleE_Custom.json", AnotherArg) +public: + QStyle* create(const QString& key); +}; + +#endif diff --git a/Tests/QtAutogen/mocPlugin/StyleCommon.hpp b/Tests/QtAutogenRerun/mocPlugin/UtilityMacros.hpp index f1a7ec60d..53a4284ee 100644 --- a/Tests/QtAutogen/mocPlugin/StyleCommon.hpp +++ b/Tests/QtAutogenRerun/mocPlugin/UtilityMacros.hpp @@ -1,5 +1,5 @@ -#ifndef STYLECOMMON_HPP -#define STYLECOMMON_HPP +#ifndef UTILITYMACROS_HPP +#define UTILITYMACROS_HPP // Empty test macro definition #define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations) diff --git a/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB.json new file mode 100644 index 000000000..cd155dc0e --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB.json @@ -0,0 +1 @@ +{ "Keys": [ "Red", "Green" ] } diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB_Custom.json index 129cac41f..129cac41f 100644 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB_Custom.json diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleC.json index 119aaa4b7..119aaa4b7 100644 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleC.json diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleD.json index 732c547ab..732c547ab 100644 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleD.json diff --git a/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleE.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleE.json new file mode 100644 index 000000000..5412c94f6 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleE.json @@ -0,0 +1 @@ +{ "Keys": [ "Floor", "Ceiling" ] } diff --git a/Tests/QtAutogen/mocPlugin/main.cpp b/Tests/QtAutogenRerun/mocPlugin/main.cpp index 3ba2ddc6d..3ba2ddc6d 100644 --- a/Tests/QtAutogen/mocPlugin/main.cpp +++ b/Tests/QtAutogenRerun/mocPlugin/main.cpp diff --git a/Tests/QtAutogenRerun/mocRerun.cmake b/Tests/QtAutogenRerun/mocRerun.cmake new file mode 100644 index 000000000..a92912b3c --- /dev/null +++ b/Tests/QtAutogenRerun/mocRerun.cmake @@ -0,0 +1,60 @@ + +set(timeformat "%Y%j%H%M%S") +set(mocRerunSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun") +set(mocRerunBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocRerun") + +# Initial build +configure_file("${mocRerunSrcDir}/test1a.h.in" "${mocRerunBinDir}/test1.h" COPYONLY) +try_compile(MOC_RERUN + "${mocRerunBinDir}" + "${mocRerunSrcDir}" + mocRerun + CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" + OUTPUT_VARIABLE output +) +if (NOT MOC_RERUN) + message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}") +endif() +# Get name of the output binary +file(STRINGS "${mocRerunBinDir}/mocRerun.txt" mocRerunList ENCODING UTF-8) +list(GET mocRerunList 0 mocRerunBin) + +message("Changing the header content for a MOC rerun") +# - Acquire binary timestamps before the build +file(TIMESTAMP "${mocRerunBin}" timeBefore "${timeformat}") +# - Ensure that the timestamp will change +# - Change header file content and rebuild +# - Rebuild +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +configure_file("${mocRerunSrcDir}/test1b.h.in" "${mocRerunBinDir}/test1.h" COPYONLY) +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocRerunBinDir}" RESULT_VARIABLE result ) +if (result) + message(SEND_ERROR "Second build of mocRerun failed.") +endif() +# - Acquire binary timestamps after the build +file(TIMESTAMP "${mocRerunBin}" timeAfter "${timeformat}") +# - Test if timestamps changed +if (NOT timeAfter GREATER timeBefore) + message(SEND_ERROR "File (${mocRerunBin}) should have changed!") +endif() + + +message("Changing nothing for a MOC rerun") +# - Acquire binary timestamps before the build +file(TIMESTAMP "${mocRerunBin}" 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 "${mocRerunBinDir}" RESULT_VARIABLE result ) +if (result) + message(SEND_ERROR "Third build of mocRerun failed.") +endif() +# - Acquire binary timestamps after the build +file(TIMESTAMP "${mocRerunBin}" timeAfter "${timeformat}") +# - Test if timestamps changed +if (timeAfter GREATER timeBefore) + message(SEND_ERROR "File (${mocRerunBin}) should not have changed!") +endif() diff --git a/Tests/QtAutogen/mocRerun/CMakeLists.txt b/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt index 14b077b38..bafd9cf48 100644 --- a/Tests/QtAutogen/mocRerun/CMakeLists.txt +++ b/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0071 NEW) project(mocRerun CXX) if (QT_TEST_VERSION STREQUAL 4) @@ -18,18 +19,15 @@ set(CMAKE_AUTORCC ON) # Generated source file add_custom_command(OUTPUT main.cpp - COMMAND ${CMAKE_COMMAND} -E sleep 2 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - ) + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) add_executable(mocRerun ${CMAKE_CURRENT_BINARY_DIR}/test1.h ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - res1.qrc - ) -set_property(TARGET mocRerun PROPERTY __UNDOCUMENTED_AUTOGEN_GENERATED_FILES 1) + res1.qrc) target_include_directories(mocRerun PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(mocRerun ${QT_CORE_TARGET}) # Write target name to text file add_custom_command(TARGET mocRerun POST_BUILD COMMAND - ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocRerun>" > target1.txt) + ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocRerun>" > mocRerun.txt) diff --git a/Tests/QtAutogen/mocRerun/input.txt b/Tests/QtAutogenRerun/mocRerun/input.txt index da627624b..da627624b 100644 --- a/Tests/QtAutogen/mocRerun/input.txt +++ b/Tests/QtAutogenRerun/mocRerun/input.txt diff --git a/Tests/QtAutogen/mocRerun/main.cpp.in b/Tests/QtAutogenRerun/mocRerun/main.cpp.in index b37ff61e2..b37ff61e2 100644 --- a/Tests/QtAutogen/mocRerun/main.cpp.in +++ b/Tests/QtAutogenRerun/mocRerun/main.cpp.in diff --git a/Tests/QtAutogen/mocRerun/res1.qrc b/Tests/QtAutogenRerun/mocRerun/res1.qrc index fb804b5ec..fb804b5ec 100644 --- a/Tests/QtAutogen/mocRerun/res1.qrc +++ b/Tests/QtAutogenRerun/mocRerun/res1.qrc diff --git a/Tests/QtAutogen/mocRerun/test1a.h.in b/Tests/QtAutogenRerun/mocRerun/test1a.h.in index a335046ba..a335046ba 100644 --- a/Tests/QtAutogen/mocRerun/test1a.h.in +++ b/Tests/QtAutogenRerun/mocRerun/test1a.h.in diff --git a/Tests/QtAutogen/mocRerun/test1b.h.in b/Tests/QtAutogenRerun/mocRerun/test1b.h.in index 6128eeba1..6128eeba1 100644 --- a/Tests/QtAutogen/mocRerun/test1b.h.in +++ b/Tests/QtAutogenRerun/mocRerun/test1b.h.in diff --git a/Tests/QtAutogenRerun/rccDepends.cmake b/Tests/QtAutogenRerun/rccDepends.cmake new file mode 100644 index 000000000..68e148251 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends.cmake @@ -0,0 +1,131 @@ +# 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}/rccDepends") +set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/rccDepends") + +# Initial build +configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) +configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) +try_compile(RCC_DEPENDS + "${rccDepBD}" + "${rccDepSD}" + rccDepends + CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" + OUTPUT_VARIABLE output +) +if (NOT RCC_DEPENDS) + message(SEND_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}") + + +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) +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/input.txt") +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${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}") +# - 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() + + +message("Changing a 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) +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}") +# - 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() + + +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) +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/inputAdded.txt") +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${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}") +# - 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() + + +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}") +# - 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() diff --git a/Tests/QtAutogenRerun/rccDepends/CMakeLists.txt b/Tests/QtAutogenRerun/rccDepends/CMakeLists.txt new file mode 100644 index 000000000..291592e7d --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.9) +project(rccDepends CXX) + +if (QT_TEST_VERSION STREQUAL 4) + find_package(Qt4 REQUIRED) + set(QT_CORE_TARGET Qt4::QtCore) +else() + if (NOT QT_TEST_VERSION STREQUAL 5) + message(SEND_ERROR "Invalid Qt version specified.") + endif() + + find_package(Qt5Core REQUIRED) + set(QT_CORE_TARGET Qt5::Core) +endif() + +# Enable AUTORCC for all targets +set(CMAKE_AUTORCC ON) + +# Initial resource files setup +configure_file(resPlain/input.txt.in resPlain/input.txt COPYONLY) +configure_file(resPlain/input.txt.in resPlain/inputAdded.txt COPYONLY) +configure_file(resGen/input.txt.in resGen/input.txt COPYONLY) +configure_file(resGen/input.txt.in resGen/inputAdded.txt COPYONLY) + +# Generated qrc file with dependency +add_custom_command(OUTPUT resGen.qrc + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc) + +# Target that uses a plain .qrc file +add_executable(rccDependsPlain main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resPlain.qrc) +target_link_libraries(rccDependsPlain ${QT_CORE_TARGET}) +add_custom_command(TARGET rccDependsPlain POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsPlain>" > targetPlain.txt) + +# Target that uses a GENERATED .qrc file +add_executable(rccDependsGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc ) +target_link_libraries(rccDependsGen ${QT_CORE_TARGET}) +add_custom_command(TARGET rccDependsGen POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsGen>" > targetGen.txt) diff --git a/Tests/QtAutogen/rccDepends/main.cpp b/Tests/QtAutogenRerun/rccDepends/main.cpp index 766b7751b..766b7751b 100644 --- a/Tests/QtAutogen/rccDepends/main.cpp +++ b/Tests/QtAutogenRerun/rccDepends/main.cpp diff --git a/Tests/QtAutogenRerun/rccDepends/resGen/input.txt.in b/Tests/QtAutogenRerun/rccDepends/resGen/input.txt.in new file mode 100644 index 000000000..4f24589b0 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/resGen/input.txt.in @@ -0,0 +1 @@ +Generated resource input. diff --git a/Tests/QtAutogenRerun/rccDepends/resGen/inputAdded.txt.in b/Tests/QtAutogenRerun/rccDepends/resGen/inputAdded.txt.in new file mode 100644 index 000000000..4f24589b0 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/resGen/inputAdded.txt.in @@ -0,0 +1 @@ +Generated resource input. diff --git a/Tests/QtAutogenRerun/rccDepends/resGenA.qrc.in b/Tests/QtAutogenRerun/rccDepends/resGenA.qrc.in new file mode 100644 index 000000000..c131a3460 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/resGenA.qrc.in @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/TextsGenerated"> + <file>resGen/input.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogenRerun/rccDepends/resGenB.qrc.in b/Tests/QtAutogenRerun/rccDepends/resGenB.qrc.in new file mode 100644 index 000000000..8c7e64311 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/resGenB.qrc.in @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/TextsGenerated"> + <file>resGen/input.txt</file> + <file alias="Added">resGen/inputAdded.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogenRerun/rccDepends/resPlain/input.txt.in b/Tests/QtAutogenRerun/rccDepends/resPlain/input.txt.in new file mode 100644 index 000000000..a5e407a17 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/resPlain/input.txt.in @@ -0,0 +1 @@ +Plaint resource input. diff --git a/Tests/QtAutogenRerun/rccDepends/resPlain/inputAdded.txt.in b/Tests/QtAutogenRerun/rccDepends/resPlain/inputAdded.txt.in new file mode 100644 index 000000000..a5e407a17 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/resPlain/inputAdded.txt.in @@ -0,0 +1 @@ +Plaint resource input. diff --git a/Tests/QtAutogenRerun/rccDepends/resPlainA.qrc.in b/Tests/QtAutogenRerun/rccDepends/resPlainA.qrc.in new file mode 100644 index 000000000..c135d85b5 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/resPlainA.qrc.in @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/TextsPlain"> + <file>resPlain/input.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogenRerun/rccDepends/resPlainB.qrc.in b/Tests/QtAutogenRerun/rccDepends/resPlainB.qrc.in new file mode 100644 index 000000000..186b6535a --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/resPlainB.qrc.in @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/TextsPlain"> + <file>resPlain/input.txt</file> + <file alias="Added">resPlain/inputAdded.txt</file> + </qresource> +</RCC> diff --git a/Tests/README b/Tests/README deleted file mode 100644 index 8b2fda845..000000000 --- a/Tests/README +++ /dev/null @@ -1,39 +0,0 @@ -If you think about adding a new testcase then here is a small checklist you -can run through to find a proper place for it. Go through the list from the -beginning and stop once you find something that matches your tests needs, -i.e. if you will test a module and only need the configure mode use the -instructions from section 2, not 3. - -1. Your testcase can run in CMake script mode, i.e. "cmake -P something" - -Put your test in Tests/CMakeTests/ directory as a .cmake.in file. It will be -put into the test binary directory by configure_file(... @ONLY) and run from -there. Use the AddCMakeTest() macro in Tests/CMakeTests/CMakeLists.txt to add -your test to the test runs. - -2. Your test needs CMake to run in configure mode, but will not build anything - -This includes tests that will build something using try_compile() and friends, -but nothing that expects add_executable(), add_library(), or add_test() to run. - -If the test configures the project only once and it must succeed then put it -into the Tests/CMakeOnly/ directory. Create a subdirectory named like your -test and write the CMakeLists.txt you need into that subdirectory. Use the -add_CMakeOnly_test() macro from Tests/CMakeOnly/CMakeLists.txt to add your -test to the test runs. - -If the test configures the project with multiple variations and verifies -success or failure each time then put it into the Tests/RunCMake/ directory. -Read the instructions in Tests/RunCMake/CMakeLists.txt to add a test. - -3. If you are testing something from the Modules directory - -Put your test in the Tests/Modules/ directory. Create a subdirectory there -named after your test. Use the ADD_TEST_MACRO macro from Tests/CMakeLists.txt -to add your test to the test run. If you have put your stuff in -Tests/Modules/Foo then you call it using ADD_TEST_MACRO(Module.Foo Foo). - -4. You are doing other stuff. - -Find a good place ;) In doubt mail to cmake-developers@cmake.org and ask for -advise. diff --git a/Tests/README.rst b/Tests/README.rst new file mode 100644 index 000000000..3e989382b --- /dev/null +++ b/Tests/README.rst @@ -0,0 +1,31 @@ +CMake Tests Directory +********************* + +This directory contains the CMake test suite. +See also the `CMake Source Code Guide`_. + +.. _`CMake Source Code Guide`: ../Help/dev/source.rst + +Many tests exist as immediate subdirectories, but some tests +are organized as follows. + +* ``CMakeLib/``: + Source code, used for tests, that links to the ``CMakeLib`` library + defined over in ``Source/``. + +* ``CMakeOnly/``: + Deprecated. Tests that run CMake to generate a project but not build it. + Superseded by ``Tests/RunCMake/``. + +* ``Find*/``: + Tests for specific find modules that can only be run on machines with + the corresponding packages installed. They are enabled in + ``CMakeLists.txt`` by undocumented options used on CI builds. + +* ``Module/``: + Tests for specific CMake modules. + +* ``RunCMake/``: + Tests that run CMake and/or other tools while precisely checking + their return code and stdout/stderr content. Useful for testing + error cases and diagnostic output. diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake index ef3301216..87b0de010 100644 --- a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake +++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake @@ -11,7 +11,7 @@ endif() ]]) endif() -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " set(check_pairs \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/test.manifest\" ) diff --git a/Tests/RunCMake/BuildDepends/C-Exe.cmake b/Tests/RunCMake/BuildDepends/C-Exe.cmake index 5057ca91d..ad5cd4d47 100644 --- a/Tests/RunCMake/BuildDepends/C-Exe.cmake +++ b/Tests/RunCMake/BuildDepends/C-Exe.cmake @@ -2,7 +2,7 @@ enable_language(C) add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " set(check_pairs \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.c\" ) diff --git a/Tests/RunCMake/BuildDepends/Custom-Always.cmake b/Tests/RunCMake/BuildDepends/Custom-Always.cmake index d412708a1..c7e7fb0bc 100644 --- a/Tests/RunCMake/BuildDepends/Custom-Always.cmake +++ b/Tests/RunCMake/BuildDepends/Custom-Always.cmake @@ -16,7 +16,7 @@ add_custom_command( add_custom_target(drive ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/after-always) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " set(check_pairs \"${CMAKE_CURRENT_BINARY_DIR}/always-updated|${CMAKE_CURRENT_BINARY_DIR}/before-always\" \"${CMAKE_CURRENT_BINARY_DIR}/after-always|${CMAKE_CURRENT_BINARY_DIR}/always-updated\" diff --git a/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake b/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake index 687c8271f..1e1f22ad0 100644 --- a/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake +++ b/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake @@ -16,7 +16,7 @@ add_custom_command( add_custom_target(drive ALL DEPENDS use-byproduct) add_dependencies(drive produce) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " if (check_step EQUAL 1) set(check_pairs \"${CMAKE_CURRENT_BINARY_DIR}/use-byproduct|${CMAKE_CURRENT_BINARY_DIR}/gen-byproduct-stamp\" diff --git a/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake b/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake index 0f92e0edb..8b2ae78cf 100644 --- a/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake +++ b/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake @@ -6,7 +6,7 @@ add_custom_command( add_custom_target(generate ALL DEPENDS output.cxx) set_property(TARGET generate PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " set(check_pairs \"${CMAKE_CURRENT_BINARY_DIR}/output.cxx|${CMAKE_CURRENT_BINARY_DIR}/MakeCustomIncludes.h\" ) diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake index add9aeb69..af6ad86ba 100644 --- a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake @@ -3,7 +3,7 @@ get_filename_component(include_dir "${CMAKE_BINARY_DIR}" PATH) include_directories("${include_dir}") add_executable(MakeInProjectOnly MakeInProjectOnly.c) set(CMAKE_DEPENDS_IN_PROJECT_ONLY 1) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " if (check_step EQUAL 1) set(check_pairs \"$<TARGET_FILE:MakeInProjectOnly>|${include_dir}/MakeInProjectOnly.h\" diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 9941c70df..1bf8fbc49 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -32,7 +32,8 @@ endfunction() run_BuildDepends(C-Exe) if(NOT RunCMake_GENERATOR STREQUAL "Xcode") - if(RunCMake_GENERATOR MATCHES "Visual Studio 10") + if(RunCMake_GENERATOR MATCHES "Visual Studio 10" OR + RunCMake_GENERATOR_TOOLSET MATCHES "^(v80|v90|v100)$") # VS 10 forgets to re-link when a manifest changes set(run_BuildDepends_skip_step_2 1) endif() diff --git a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt index e3e3ff468..70ed05ba1 100644 --- a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt +++ b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt @@ -1,8 +1,8 @@ CMake Warning \(dev\) at CMP0040-WARN-missing-target.cmake:2 \(add_custom_command\): Policy CMP0040 is not set: The target in the TARGET signature of - add_custom_command\(\) must exist. Run "cmake --help-policy CMP0040" for - policy details. Use the cmake_policy command to set the policy and - suppress this warning. + add_custom_command\(\) must exist and must be defined in the current + directory. Run "cmake --help-policy CMP0040" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + No TARGET 'foobar' has been created in this directory. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 79f487d41..29325ff0a 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -141,13 +141,16 @@ add_RunCMake_test(DisallowedCommands) add_RunCMake_test(ExternalData) add_RunCMake_test(FeatureSummary) add_RunCMake_test(FPHSA) +add_RunCMake_test(FindBoost) if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom") add_RunCMake_test(GenerateExportHeader) endif() add_RunCMake_test(GeneratorExpression) add_RunCMake_test(GeneratorPlatform) add_RunCMake_test(GeneratorToolset) +add_RunCMake_test(GetPrerequisites) add_RunCMake_test(GNUInstallDirs -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) @@ -179,10 +182,14 @@ add_RunCMake_test(Syntax) add_RunCMake_test(add_custom_command) add_RunCMake_test(add_custom_target) add_RunCMake_test(add_dependencies) +add_RunCMake_test(add_executable) +add_RunCMake_test(add_library) add_RunCMake_test(add_subdirectory) add_RunCMake_test(build_command) +add_executable(exit_code exit_code.c) +set(execute_process_ARGS -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>) if(NOT CMake_TEST_EXTERNAL_CMAKE) - set(execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>) + list(APPEND execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>) endif() add_RunCMake_test(execute_process) add_RunCMake_test(export) @@ -213,6 +220,7 @@ add_RunCMake_test(get_property) add_RunCMake_test(if) add_RunCMake_test(include) add_RunCMake_test(include_directories) +add_RunCMake_test(include_guard) add_RunCMake_test(list) add_RunCMake_test(message) add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) @@ -220,20 +228,39 @@ add_RunCMake_test(return) add_RunCMake_test(separate_arguments) add_RunCMake_test(set_property) add_RunCMake_test(string) -foreach(var - CMAKE_C_COMPILER_ID - CMAKE_C_COMPILER_VERSION - CMAKE_C_STANDARD_DEFAULT - CMAKE_CXX_COMPILER_ID - CMAKE_CXX_COMPILER_VERSION - CMAKE_CXX_STANDARD_DEFAULT - CMake_TEST_CUDA - ) - if(DEFINED ${var}) - list(APPEND try_compile_ARGS -D${var}=${${var}}) +add_RunCMake_test(test_include_dirs) + +function(add_RunCMake_test_try_compile) + if(CMAKE_VERSION VERSION_LESS 3.9.20170907 AND "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") + # Older CMake versions do not know about MSVC language standards. + # Approximate our logic from MSVC-CXX.cmake. + if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.10.25017) + set(CMAKE_CXX_STANDARD_DEFAULT 14) + elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) + set(CMAKE_CXX_STANDARD_DEFAULT "") + else() + unset(CMAKE_CXX_STANDARD_DEFAULT) + endif() endif() -endforeach() -add_RunCMake_test(try_compile) + foreach(var + CMAKE_C_COMPILER_ID + CMAKE_C_COMPILER_VERSION + CMAKE_C_STANDARD_DEFAULT + CMAKE_CXX_COMPILER_ID + CMAKE_CXX_COMPILER_VERSION + CMAKE_CXX_STANDARD_DEFAULT + CMake_TEST_CUDA + ) + if(DEFINED ${var}) + list(APPEND try_compile_ARGS -D${var}=${${var}}) + endif() + endforeach() + add_RunCMake_test(try_compile) +endfunction() +add_RunCMake_test_try_compile() + add_RunCMake_test(try_run) add_RunCMake_test(set) add_RunCMake_test(variable_watch) @@ -338,10 +365,22 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") add_executable(pseudo_tidy pseudo_tidy.c) add_executable(pseudo_iwyu pseudo_iwyu.c) add_executable(pseudo_cpplint pseudo_cpplint.c) + add_executable(pseudo_cppcheck pseudo_cppcheck.c) add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>) add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>) add_RunCMake_test(Cpplint -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint>) + add_RunCMake_test(Cppcheck -DPSEUDO_CPPCHECK=$<TARGET_FILE:pseudo_cppcheck>) + add_RunCMake_test(MultiLint + -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy> + -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu> + -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint> + -DPSEUDO_CPPCHECK=$<TARGET_FILE:pseudo_cppcheck> + ) + if(DEFINED CMake_TEST_CUDA) + list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + endif() add_RunCMake_test(CompilerLauncher) + add_RunCMake_test(ctest_labels_for_subprojects) endif() add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ") @@ -371,3 +410,7 @@ if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN) endif() set_property(TEST RunCMake.Android PROPERTY TIMEOUT ${CMake_TEST_ANDROID_TIMEOUT}) endif() + +if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])") + add_RunCMake_test(CSharpCustomCommand) +endif() diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index c361af065..1b3dbb228 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -15,3 +15,7 @@ include(tests/${RunCMake_TEST_FILE_PREFIX}/test.cmake) set(CPACK_GENERATOR "${GENERATOR_TYPE}") include(CPack) + +if(COMMAND run_after_include_cpack) + run_after_include_cpack() +endif() diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index ad1b47bdc..6d8e84a52 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -23,7 +23,7 @@ function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_V endif() if(GENERATOR_SPECIFIC_FORMAT) - set(${RESULT_VAR} "${NAME}${COMPONENT}_${VERSION}-${REVISION}_*.deb" PARENT_SCOPE) + set(${RESULT_VAR} "${NAME}${COMPONENT}_${VERSION}_*.deb" PARENT_SCOPE) else() set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.deb" PARENT_SCOPE) endif() diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index 7c98f6972..cf7c02c79 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -91,6 +91,11 @@ If test will be used for multiple generators but some of them require some generator specific commands then those commands should be added to 'test.cmake' script wrapped with 'if(GENERATOR_TYPE STREQUAL <name_of_the_generator>)'. +NOTE: In some cases (for example when testing CPackComponent.cmake functions) +the test has to run some functions after CPack.cmake is included. In such cases +a function run_after_include_cpack can be declared in test.cmake file and that +function will run after the inclusion of CPack.cmake. + build phase (optional and not available for source package tests) ----------------------------------------------------------------- diff --git a/Tests/RunCMake/CPack/RPM/Helpers.cmake b/Tests/RunCMake/CPack/RPM/Helpers.cmake index d8012b11b..88fc23154 100644 --- a/Tests/RunCMake/CPack/RPM/Helpers.cmake +++ b/Tests/RunCMake/CPack/RPM/Helpers.cmake @@ -23,6 +23,9 @@ function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_V endif() if(GENERATOR_SPECIFIC_FORMAT) + if(NOT REVISION) + set(REVISION "1") + endif() set(${RESULT_VAR} "${NAME}${COMPONENT}-${VERSION}-${REVISION}.*.rpm" PARENT_SCOPE) else() set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.rpm" PARENT_SCOPE) diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index faf151a13..aa55c4462 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -10,6 +10,7 @@ run_cpack_test(DEBUGINFO "RPM" true "COMPONENT") run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT") run_cpack_test(DIST "RPM" false "MONOLITHIC") run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true "MONOLITHIC;COMPONENT") +run_cpack_test(VERSION "RPM;DEB" false "MONOLITHIC;COMPONENT") run_cpack_test(EXTRA "DEB" false "COMPONENT") run_cpack_test(GENERATE_SHLIBS "DEB" true "COMPONENT") run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") @@ -27,3 +28,5 @@ run_cpack_test(SUGGESTS "RPM" false "MONOLITHIC") run_cpack_test(SYMLINKS "RPM;TGZ" false "MONOLITHIC;COMPONENT") run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC") run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT") +run_cpack_test(CPACK_INSTALL_SCRIPT "ZIP" false "MONOLITHIC") +run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 470ebf7a8..1f5ab8716 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -8,9 +8,7 @@ function(findExpectedFile FILE_NO RESULT_VAR GLOBING_EXPR_VAR) endif() if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_VERSION) set(EXPECTED_FILE_${FILE_NO}_VERSION "0.1.1") - endif() - if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_REVISION) - set(EXPECTED_FILE_${FILE_NO}_REVISION "1") + set(EXPECTED_FILE_${FILE_NO}_VERSION "0.1.1" PARENT_SCOPE) endif() getPackageNameGlobexpr("${EXPECTED_FILE_${FILE_NO}_NAME}" diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPT/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPT/ExpectedFiles.cmake new file mode 100644 index 000000000..5cb12c3ba --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPT/ExpectedFiles.cmake @@ -0,0 +1,3 @@ +set(EXPECTED_FILES_COUNT "1") + +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/abc.txt") diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPT/test.cmake b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPT/test.cmake new file mode 100644 index 000000000..e3fe0ca47 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPT/test.cmake @@ -0,0 +1,11 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/abc.txt" "test content") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/user-script.cmake" + "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/foo\" + TYPE FILE FILES \"${CMAKE_CURRENT_BINARY_DIR}/abc.txt\")") +set(CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/user-script.cmake") + +function(run_after_include_cpack) + file(READ "${CPACK_OUTPUT_CONFIG_FILE}" conf_file_) + string(REGEX REPLACE "SET\\(CPACK_INSTALL_CMAKE_PROJECTS [^)]*\\)" "" conf_file_ "${conf_file_}") + file(WRITE "${CPACK_OUTPUT_CONFIG_FILE}" "${conf_file_}") +endfunction() diff --git a/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/ExpectedFiles.cmake new file mode 100644 index 000000000..6142eb39a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/VerifyResult.cmake new file mode 100644 index 000000000..771cc1048 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/VerifyResult.cmake @@ -0,0 +1,11 @@ +function(checkPackageInfo_ TYPE FILE REGEX) + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}' ${EXPECTED_FILE_1_VERSION} ${EXPECTED_FILE_1_REVISION}; file info: '${FILE_INFO_}'") + endif() +endfunction() + +set(whitespaces_ "[\t\n\r ]*") + +checkPackageInfo_("version" "${FOUND_FILE_1}" + ".*Version${whitespaces_}:${whitespaces_}5.0.1-71-g884852e") diff --git a/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/test.cmake b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/test.cmake new file mode 100644 index 000000000..403e60dde --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/test.cmake @@ -0,0 +1,7 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +set(CPACK_DEBIAN_PACKAGE_VERSION "5.0.1-71-g884852e") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake index 7375ecc21..1b2eb4877 100644 --- a/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake @@ -5,6 +5,11 @@ execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist} set(whitespaces_ "[\t\n\r ]*") +# since we have no control over dist tag value we should try to escape +# the content for use as a regular expression +string(REPLACE "+" "\\+" DIST_TAG "${DIST_TAG}") +string(REPLACE "." "\\." DIST_TAG "${DIST_TAG}") + getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_") if(NOT FILE_INFO_ MATCHES ".*Release${whitespaces_}:${whitespaces_}1${DIST_TAG}") message(FATAL_ERROR "Unexpected Release in '${FOUND_FILE_1}'; file info: '${FILE_INFO_}'") diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake index e4f9618d3..2bb4d3ff9 100644 --- a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake @@ -1,8 +1,7 @@ if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") - string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} EXTENSION) + string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} CHECKSUM_EXTENSION) file(GLOB PACKAGE RELATIVE ${bin_dir} "*.tar.gz") - file(GLOB CSUMFILE RELATIVE ${bin_dir} "*.${EXTENSION}") - file(STRINGS ${CSUMFILE} CHSUM_VALUE) + file(STRINGS ${PACKAGE}.${CHECKSUM_EXTENSION} CHSUM_VALUE) file(${RunCMake_SUBTEST_SUFFIX} ${PACKAGE} expected_value ) set(expected_value "${expected_value} ${PACKAGE}") diff --git a/Tests/RunCMake/CPack/tests/VERSION/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/VERSION/ExpectedFiles.cmake new file mode 100644 index 000000000..85c571cad --- /dev/null +++ b/Tests/RunCMake/CPack/tests/VERSION/ExpectedFiles.cmake @@ -0,0 +1,3 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_1_REVISION "1") diff --git a/Tests/RunCMake/CPack/tests/VERSION/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/VERSION/VerifyResult.cmake new file mode 100644 index 000000000..eed9696cd --- /dev/null +++ b/Tests/RunCMake/CPack/tests/VERSION/VerifyResult.cmake @@ -0,0 +1,17 @@ +function(checkPackageInfo_ TYPE FILE REGEX) + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}' ${EXPECTED_FILE_1_VERSION} ${EXPECTED_FILE_1_REVISION}; file info: '${FILE_INFO_}'") + endif() +endfunction() + +set(whitespaces_ "[\t\n\r ]*") + +if(GENERATOR_TYPE STREQUAL "RPM") + checkPackageInfo_("package version" "${FOUND_FILE_1}" "Version${whitespaces_}:${whitespaces_}${EXPECTED_FILE_1_VERSION}") + checkPackageInfo_("package revision" "${FOUND_FILE_1}" "Release${whitespaces_}:${whitespaces_}${EXPECTED_FILE_1_REVISION}") + checkPackageInfo_("epoch version" "${FOUND_FILE_1}" "Epoch${whitespaces_}:${whitespaces_}3") +else() # DEB + checkPackageInfo_("version" "${FOUND_FILE_1}" + ".*Version${whitespaces_}:${whitespaces_}3:${EXPECTED_FILE_1_VERSION}-${EXPECTED_FILE_1_REVISION}") +endif() diff --git a/Tests/RunCMake/CPack/tests/VERSION/test.cmake b/Tests/RunCMake/CPack/tests/VERSION/test.cmake new file mode 100644 index 000000000..301ab6126 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/VERSION/test.cmake @@ -0,0 +1,14 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(GENERATOR_TYPE STREQUAL "DEB") + set(package_type_ "DEBIAN") + set(CPACK_DEBIAN_PACKAGE_RELEASE "1") +else() + set(package_type_ "${GENERATOR_TYPE}") +endif() + +set(CPACK_${package_type_}_PACKAGE_EPOCH "3") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake b/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake index 1a373b928..8fc1218f2 100644 --- a/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake +++ b/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake @@ -1,6 +1,6 @@ add_executable(mytest test.cpp) -file(GENERATE OUTPUT runtest_info.cmake CONTENT [[ +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info.cmake CONTENT [[ set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>") ]]) diff --git a/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake b/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake index 77fe8ed5d..b23d3c7df 100644 --- a/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake +++ b/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake @@ -6,7 +6,7 @@ foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES) OUTPUT_NAME_${UPPER_CONFIG} bar_${CONFIG}) endforeach() -file(GENERATE OUTPUT runtest_info_$<CONFIG>.cmake CONTENT [[ +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info_$<CONFIG>.cmake CONTENT [[ set(CPACK_BUILD_CONFIG "$<CONFIG>") set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>") ]]) diff --git a/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake b/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake index 2e1d4656c..2001d9f4c 100644 --- a/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake +++ b/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake @@ -1,6 +1,6 @@ add_executable(mytest test.cpp) -file(GENERATE OUTPUT runtest_info.cmake CONTENT [[ +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info.cmake CONTENT [[ set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>") ]]) diff --git a/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt b/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt new file mode 100644 index 000000000..74b3ff8de --- /dev/null +++ b/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake new file mode 100644 index 000000000..60d77eb60 --- /dev/null +++ b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake @@ -0,0 +1,21 @@ +if(checkLevel EQUAL 0) + message("checking generation (${srcName} does not exist)") + if(EXISTS "${generatedFileName}") + set(RunCMake_TEST_FAILED "file \"${generatedFileName}\" should not exist") + endif() +elseif(checkLevel EQUAL 1) + message("checking build 1 (generate ${srcName})") + if(NOT "${actual_stdout}" MATCHES "${commandComment}") + set(RunCMake_TEST_FAILED "command not executed") + endif() +elseif(checkLevel EQUAL 2) + message("checking build 2 (no change in ${srcName}.in)") + if("${actual_stdout}" MATCHES "${commandComment}") + set(RunCMake_TEST_FAILED "command executed") + endif() +elseif(checkLevel EQUAL 3) + message("checking build 3 (update ${srcName})") + if(NOT "${actual_stdout}" MATCHES "${commandComment}") + set(RunCMake_TEST_FAILED "command not executed") + endif() +endif() diff --git a/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake new file mode 100644 index 000000000..68341fa88 --- /dev/null +++ b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake @@ -0,0 +1,13 @@ +enable_language(CSharp) + +add_executable(CSharpCustomCommand dummy.cs) + +add_custom_command(OUTPUT ${generatedFileName} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${inputFileName} ${generatedFileName} + MAIN_DEPENDENCY ${inputFileName} + COMMENT "${commandComment}") + +target_sources(CSharpCustomCommand PRIVATE + ${inputFileName} + ${generatedFileName}) diff --git a/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake b/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake new file mode 100644 index 000000000..fa5618aab --- /dev/null +++ b/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake @@ -0,0 +1,34 @@ +include(RunCMake) + +# Use a single build tree for a few tests without cleaning. +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CommandWithOutput-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +set(RunCMake-check-file CommandWithOutput-check.cmake) + +set(srcName "test.cs") +set(srcFileName "${CMAKE_CURRENT_LIST_DIR}/${srcName}.in") +set(inputFileName "${RunCMake_TEST_BINARY_DIR}/${srcName}.in") +set(generatedFileName "${RunCMake_TEST_BINARY_DIR}/${srcName}") +set(commandComment "Generating ${srcName}") + +# copy the input file to build dir to avoid changing files in cmake +# source tree. +file(COPY "${srcFileName}" DESTINATION "${RunCMake_TEST_BINARY_DIR}") + +set(RunCMake_TEST_OPTIONS ${RunCMake_TEST_OPTIONS} + "-DinputFileName=${inputFileName}" + "-DgeneratedFileName=${generatedFileName}" + "-DcommandComment=${commandComment}") + +set(checkLevel 0) +run_cmake(CommandWithOutput) +set(checkLevel 1) +run_cmake_command(CommandWithOutput-build1 ${CMAKE_COMMAND} --build . --config Debug) +set(checkLevel 2) +run_cmake_command(CommandWithOutput-build2 ${CMAKE_COMMAND} --build . --config Debug) +# change file content to trigger custom command with next build +file(APPEND ${inputFileName} "\n") +set(checkLevel 3) +run_cmake_command(CommandWithOutput-build3 ${CMAKE_COMMAND} --build . --config Debug) diff --git a/Tests/RunCMake/CSharpCustomCommand/dummy.cs b/Tests/RunCMake/CSharpCustomCommand/dummy.cs new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CSharpCustomCommand/dummy.cs diff --git a/Tests/RunCMake/CSharpCustomCommand/test.cs.in b/Tests/RunCMake/CSharpCustomCommand/test.cs.in new file mode 100644 index 000000000..05a7531e0 --- /dev/null +++ b/Tests/RunCMake/CSharpCustomCommand/test.cs.in @@ -0,0 +1,8 @@ +class TestCs +{ + public static int Main(string[] args) + { + System.Console.WriteLine("Test C#"); + return 0; + } +} diff --git a/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt b/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt index 7fe04eb6a..9cfe41ca3 100644 --- a/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt +++ b/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt @@ -1,7 +1,7 @@ 100% tests passed, 0 tests failed out of 4 + +Label Time Summary: -+'bar' = +[0-9.]+ sec \(3 tests\) -+'foo' = +[0-9.]+ sec \(1 test\) ++'bar' = +[0-9.]+ sec\*proc \(3 tests\) ++'foo' = +[0-9.]+ sec\*proc \(1 test\) + Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt +++ b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-stderr.txt index 338f7c4e6..338f7c4e6 100644 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt +++ b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt +++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt new file mode 100644 index 000000000..f0597d2cf --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt @@ -0,0 +1 @@ +^__run_co_compile given unknown argument: command-does-not-exist$ diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt +++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt new file mode 100644 index 000000000..bba846e41 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt @@ -0,0 +1 @@ +^__run_co_compile missing compile command after --$ diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt +++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt new file mode 100644 index 000000000..a7fbad667 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt @@ -0,0 +1,6 @@ +^__run_co_compile missing command to run. Looking for one or more of the following: +--cppcheck= +--cpplint= +--iwyu= +--lwyu= +--tidy= diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt deleted file mode 100644 index c251adf00..000000000 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^__run_iwyu given unknown argument: command-does-not-exist$ diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt deleted file mode 100644 index 1998abb22..000000000 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^__run_iwyu missing compile command after --$ diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt deleted file mode 100644 index 35f50b76b..000000000 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^__run_iwyu missing --cpplint=, --iwyu=, --lwyu=, and/or --tidy=$ diff --git a/Tests/RunCMake/CommandLine/E_md5sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_md5sum-dir-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_md5sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_md5sum-dir-stderr.txt new file mode 100644 index 000000000..061fd64d7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-dir-stderr.txt @@ -0,0 +1 @@ +Error: . is a directory diff --git a/Tests/RunCMake/CommandLine/E_md5sum-mixed-result.txt b/Tests/RunCMake/CommandLine/E_md5sum-mixed-result.txt new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-mixed-result.txt @@ -0,0 +1 @@ +2 diff --git a/Tests/RunCMake/CommandLine/E_md5sum-mixed-stderr.txt b/Tests/RunCMake/CommandLine/E_md5sum-mixed-stderr.txt new file mode 100644 index 000000000..b6b84c39a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-mixed-stderr.txt @@ -0,0 +1,2 @@ +Error: . is a directory +nonexisting: No such file or directory diff --git a/Tests/RunCMake/CommandLine/E_md5sum-mixed-stdout.txt b/Tests/RunCMake/CommandLine/E_md5sum-mixed-stdout.txt new file mode 100644 index 000000000..18e49bef0 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-mixed-stdout.txt @@ -0,0 +1 @@ +275876e34cf609db118f3d84b799a790 ../dummy diff --git a/Tests/RunCMake/CommandLine/E_md5sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_md5sum-no-file-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-no-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_md5sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_md5sum-no-file-stderr.txt new file mode 100644 index 000000000..732e8c4f6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-no-file-stderr.txt @@ -0,0 +1 @@ +nonexisting: No such file or directory diff --git a/Tests/RunCMake/CommandLine/E_md5sum-result.txt b/Tests/RunCMake/CommandLine/E_md5sum-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_md5sum-stdout.txt b/Tests/RunCMake/CommandLine/E_md5sum-stdout.txt new file mode 100644 index 000000000..18e49bef0 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_md5sum-stdout.txt @@ -0,0 +1 @@ +275876e34cf609db118f3d84b799a790 ../dummy diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha1sum-dir-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha1sum-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha1sum-dir-stderr.txt new file mode 100644 index 000000000..061fd64d7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha1sum-dir-stderr.txt @@ -0,0 +1 @@ +Error: . is a directory diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha1sum-no-file-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha1sum-no-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha1sum-no-file-stderr.txt new file mode 100644 index 000000000..732e8c4f6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha1sum-no-file-stderr.txt @@ -0,0 +1 @@ +nonexisting: No such file or directory diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-result.txt b/Tests/RunCMake/CommandLine/E_sha1sum-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha1sum-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha1sum-stdout.txt new file mode 100644 index 000000000..689b85bc3 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha1sum-stdout.txt @@ -0,0 +1 @@ +829c3804401b0727f70f73d4415e162400cbe57b ../dummy diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha224sum-dir-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha224sum-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha224sum-dir-stderr.txt new file mode 100644 index 000000000..061fd64d7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha224sum-dir-stderr.txt @@ -0,0 +1 @@ +Error: . is a directory diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha224sum-no-file-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha224sum-no-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha224sum-no-file-stderr.txt new file mode 100644 index 000000000..732e8c4f6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha224sum-no-file-stderr.txt @@ -0,0 +1 @@ +nonexisting: No such file or directory diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-result.txt b/Tests/RunCMake/CommandLine/E_sha224sum-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha224sum-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha224sum-stdout.txt new file mode 100644 index 000000000..5b3e2178a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha224sum-stdout.txt @@ -0,0 +1 @@ +37d32c6dbabed711cb1d4620b64090fef0ef63ab16a4a51d668259e6 ../dummy diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha256sum-dir-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha256sum-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha256sum-dir-stderr.txt new file mode 100644 index 000000000..061fd64d7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha256sum-dir-stderr.txt @@ -0,0 +1 @@ +Error: . is a directory diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha256sum-no-file-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha256sum-no-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha256sum-no-file-stderr.txt new file mode 100644 index 000000000..732e8c4f6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha256sum-no-file-stderr.txt @@ -0,0 +1 @@ +nonexisting: No such file or directory diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-result.txt b/Tests/RunCMake/CommandLine/E_sha256sum-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha256sum-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha256sum-stdout.txt new file mode 100644 index 000000000..9a1877082 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha256sum-stdout.txt @@ -0,0 +1 @@ +b5a2c96250612366ea272ffac6d9744aaf4b45aacd96aa7cfcb931ee3b558259 ../dummy diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha384sum-dir-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha384sum-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha384sum-dir-stderr.txt new file mode 100644 index 000000000..061fd64d7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha384sum-dir-stderr.txt @@ -0,0 +1 @@ +Error: . is a directory diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha384sum-no-file-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha384sum-no-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha384sum-no-file-stderr.txt new file mode 100644 index 000000000..732e8c4f6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha384sum-no-file-stderr.txt @@ -0,0 +1 @@ +nonexisting: No such file or directory diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-result.txt b/Tests/RunCMake/CommandLine/E_sha384sum-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha384sum-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha384sum-stdout.txt new file mode 100644 index 000000000..b706ac587 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha384sum-stdout.txt @@ -0,0 +1 @@ +43c1835ceba2e29596f05e3859d4fe2b6d124a181ed670f68e914bd3ed251b02b4be609608a13f23ec3d98da6c4eb8cd ../dummy diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha512sum-dir-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha512sum-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha512sum-dir-stderr.txt new file mode 100644 index 000000000..061fd64d7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha512sum-dir-stderr.txt @@ -0,0 +1 @@ +Error: . is a directory diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha512sum-no-file-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha512sum-no-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha512sum-no-file-stderr.txt new file mode 100644 index 000000000..732e8c4f6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha512sum-no-file-stderr.txt @@ -0,0 +1 @@ +nonexisting: No such file or directory diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-result.txt b/Tests/RunCMake/CommandLine/E_sha512sum-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha512sum-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha512sum-stdout.txt new file mode 100644 index 000000000..4305383bb --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sha512sum-stdout.txt @@ -0,0 +1 @@ +1692526aab84461a8aebcefddcba2b33fb5897ab180c53e8b345ae125484d0aaa35baf60487050be21ed8909a48eace93851bf139087ce1f7a87d97b6120a651 ../dummy diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index f94b10ac5..55eac5ec2 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -21,10 +21,10 @@ run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate) run_cmake_command(E_time ${CMAKE_COMMAND} -E time ${CMAKE_COMMAND} -E echo "hello world") run_cmake_command(E_time-no-arg ${CMAKE_COMMAND} -E time) -run_cmake_command(E___run_iwyu-no-iwyu ${CMAKE_COMMAND} -E __run_iwyu -- command-does-not-exist) -run_cmake_command(E___run_iwyu-bad-iwyu ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist -- command-does-not-exist) -run_cmake_command(E___run_iwyu-no--- ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist command-does-not-exist) -run_cmake_command(E___run_iwyu-no-cc ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist --) +run_cmake_command(E___run_co_compile-no-iwyu ${CMAKE_COMMAND} -E __run_co_compile -- command-does-not-exist) +run_cmake_command(E___run_co_compile-bad-iwyu ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist -- command-does-not-exist) +run_cmake_command(E___run_co_compile-no--- ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist command-does-not-exist) +run_cmake_command(E___run_co_compile-no-cc ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist --) run_cmake_command(G_no-arg ${CMAKE_COMMAND} -G) run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -G NoSuchGenerator) @@ -172,6 +172,30 @@ run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1) run_cmake_command(E_env-set ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-set.cmake) run_cmake_command(E_env-unset ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -E env --unset=TEST_ENV ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-unset.cmake) +run_cmake_command(E_md5sum-dir ${CMAKE_COMMAND} -E md5sum .) +run_cmake_command(E_sha1sum-dir ${CMAKE_COMMAND} -E sha1sum .) +run_cmake_command(E_sha224sum-dir ${CMAKE_COMMAND} -E sha224sum .) +run_cmake_command(E_sha256sum-dir ${CMAKE_COMMAND} -E sha256sum .) +run_cmake_command(E_sha384sum-dir ${CMAKE_COMMAND} -E sha384sum .) +run_cmake_command(E_sha512sum-dir ${CMAKE_COMMAND} -E sha512sum .) + +run_cmake_command(E_md5sum-no-file ${CMAKE_COMMAND} -E md5sum nonexisting) +run_cmake_command(E_sha1sum-no-file ${CMAKE_COMMAND} -E sha1sum nonexisting) +run_cmake_command(E_sha224sum-no-file ${CMAKE_COMMAND} -E sha224sum nonexisting) +run_cmake_command(E_sha256sum-no-file ${CMAKE_COMMAND} -E sha256sum nonexisting) +run_cmake_command(E_sha384sum-no-file ${CMAKE_COMMAND} -E sha384sum nonexisting) +run_cmake_command(E_sha512sum-no-file ${CMAKE_COMMAND} -E sha512sum nonexisting) + +file(WRITE "${RunCMake_BINARY_DIR}/dummy" "dummy") +run_cmake_command(E_md5sum ${CMAKE_COMMAND} -E md5sum ../dummy) +run_cmake_command(E_md5sum-mixed ${CMAKE_COMMAND} -E md5sum . ../dummy nonexisting) +run_cmake_command(E_sha1sum ${CMAKE_COMMAND} -E sha1sum ../dummy) +run_cmake_command(E_sha224sum ${CMAKE_COMMAND} -E sha224sum ../dummy) +run_cmake_command(E_sha256sum ${CMAKE_COMMAND} -E sha256sum ../dummy) +run_cmake_command(E_sha384sum ${CMAKE_COMMAND} -E sha384sum ../dummy) +run_cmake_command(E_sha512sum ${CMAKE_COMMAND} -E sha512sum ../dummy) +file(REMOVE "${RunCMake_BINARY_DIR}/dummy") + set(RunCMake_DEFAULT_stderr ".") run_cmake_command(E_sleep-no-args ${CMAKE_COMMAND} -E sleep) unset(RunCMake_DEFAULT_stderr) diff --git a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes deleted file mode 100644 index 9c22288cd..000000000 --- a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Do not format a source encoded in UTF-16. -test_UTF-16LE.h -format.clang-format diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt new file mode 100644 index 000000000..3313e31f6 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt new file mode 100644 index 000000000..3313e31f6 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake new file mode 100644 index 000000000..6b4b816e9 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CUDA.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA.cmake b/Tests/RunCMake/CompilerLauncher/CUDA.cmake new file mode 100644 index 000000000..fe5560bc7 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA.cmake @@ -0,0 +1,4 @@ +enable_language(CUDA) +set(CMAKE_CUDA_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.cu) diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake index 5884d5c4d..ab2651203 100644 --- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake @@ -15,9 +15,14 @@ function(run_compiler_launcher lang) run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() -run_compiler_launcher(C) -run_compiler_launcher(CXX) -if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") - run_compiler_launcher(C-launch) - run_compiler_launcher(CXX-launch) +set(langs C CXX) +if(CMake_TEST_CUDA) + list(APPEND langs CUDA) endif() + +foreach(lang ${langs}) + run_compiler_launcher(${lang}) + if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_compiler_launcher(${lang}-launch) + endif() +endforeach() diff --git a/Tests/RunCMake/CompilerLauncher/main.cu b/Tests/RunCMake/CompilerLauncher/main.cu new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/main.cu @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/Cppcheck/C-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-Build-stdout.txt new file mode 100644 index 000000000..26eded30e --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-Build-stdout.txt @@ -0,0 +1 @@ +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt new file mode 100644 index 000000000..2370ce1c1 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt @@ -0,0 +1,2 @@ +stdout from bad command line arg '-bad' +stderr from bad command line arg '-bad' diff --git a/Tests/RunCMake/Cppcheck/C-bad.cmake b/Tests/RunCMake/Cppcheck/C-bad.cmake new file mode 100644 index 000000000..920e4b4bc --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-bad.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}" -bad) +add_executable(main main.c) diff --git a/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt new file mode 100644 index 000000000..26eded30e --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/Cppcheck/C-launch.cmake b/Tests/RunCMake/Cppcheck/C-launch.cmake new file mode 100644 index 000000000..e66ca203e --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C.cmake) diff --git a/Tests/RunCMake/Cppcheck/C.cmake b/Tests/RunCMake/Cppcheck/C.cmake new file mode 100644 index 000000000..b1f5bf789 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C.cmake @@ -0,0 +1,4 @@ + +enable_language(C) +set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}") +add_executable(main main.c) diff --git a/Tests/RunCMake/Cppcheck/CMakeLists.txt b/Tests/RunCMake/Cppcheck/CMakeLists.txt new file mode 100644 index 000000000..a640c569e --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.7) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt b/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt new file mode 100644 index 000000000..26eded30e --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt @@ -0,0 +1 @@ +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt b/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt new file mode 100644 index 000000000..26eded30e --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/Cppcheck/CXX-launch.cmake b/Tests/RunCMake/Cppcheck/CXX-launch.cmake new file mode 100644 index 000000000..3002c9d68 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CXX-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX.cmake) diff --git a/Tests/RunCMake/Cppcheck/CXX.cmake b/Tests/RunCMake/Cppcheck/CXX.cmake new file mode 100644 index 000000000..3b7947127 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CXX.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_CXX_CPPCHECK "${PSEUDO_CPPCHECK}") +add_executable(main main.cxx) diff --git a/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake new file mode 100644 index 000000000..5fd4ead13 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake @@ -0,0 +1,23 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}") + +function(run_cppcheck lang) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${lang}) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .) +endfunction() + +run_cppcheck(C) +run_cppcheck(CXX) +run_cppcheck(C-bad) + +if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_cppcheck(C-launch) + run_cppcheck(CXX-launch) +endif() diff --git a/Tests/RunCMake/Cppcheck/main.c b/Tests/RunCMake/Cppcheck/main.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Cppcheck/main.cxx b/Tests/RunCMake/Cppcheck/main.cxx new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/RunCMake/Cppcheck/main.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/ExternalProject/MultiCommand-build-stdout.txt b/Tests/RunCMake/ExternalProject/MultiCommand-build-stdout.txt new file mode 100644 index 000000000..30ebc7dcc --- /dev/null +++ b/Tests/RunCMake/ExternalProject/MultiCommand-build-stdout.txt @@ -0,0 +1,15 @@ +.* *download 1 +.* *download 2 +.* *update 1 +.* *update 2 +.* *patch 1 +.* *patch 2 +.* *configure 1 +.* *configure 2 +.* *build 1 +.* *build 2 +.* *install 1 +.* *install 2 +.* *test 1 +.* *test 2 +.* diff --git a/Tests/RunCMake/ExternalProject/MultiCommand.cmake b/Tests/RunCMake/ExternalProject/MultiCommand.cmake new file mode 100644 index 000000000..a8dbfea5d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/MultiCommand.cmake @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.9) + +include(ExternalProject) + +# Verify COMMAND keyword is recognised after various *_COMMAND options +ExternalProject_Add(multiCommand + DOWNLOAD_COMMAND "${CMAKE_COMMAND}" -E echo "download 1" + COMMAND "${CMAKE_COMMAND}" -E echo "download 2" + UPDATE_COMMAND "${CMAKE_COMMAND}" -E echo "update 1" + COMMAND "${CMAKE_COMMAND}" -E echo "update 2" + PATCH_COMMAND "${CMAKE_COMMAND}" -E echo "patch 1" + COMMAND "${CMAKE_COMMAND}" -E echo "patch 2" + CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E echo "configure 1" + COMMAND "${CMAKE_COMMAND}" -E echo "configure 2" + BUILD_COMMAND "${CMAKE_COMMAND}" -E echo "build 1" + COMMAND "${CMAKE_COMMAND}" -E echo "build 2" + TEST_COMMAND "${CMAKE_COMMAND}" -E echo "test 1" + COMMAND "${CMAKE_COMMAND}" -E echo "test 2" + INSTALL_COMMAND "${CMAKE_COMMAND}" -E echo "install 1" + COMMAND "${CMAKE_COMMAND}" -E echo "install 2" +) + +# Workaround for issue 17229 (missing dependency between update and patch steps) +ExternalProject_Add_StepTargets(multiCommand NO_DEPENDS update) +ExternalProject_Add_StepDependencies(multiCommand patch multiCommand-update) + +# Force all steps to be re-run by removing timestamps from any previous run +ExternalProject_Get_Property(multiCommand STAMP_DIR) +file(REMOVE_RECURSE "${STAMP_DIR}") +file(MAKE_DIRECTORY "${STAMP_DIR}") diff --git a/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt b/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt index 12a76c5d4..2fc7d291b 100644 --- a/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt +++ b/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt @@ -6,12 +6,12 @@ is not an existing non-empty directory. Please specify one of: \* SOURCE_DIR with an existing non-empty directory + \* DOWNLOAD_COMMAND \* URL \* GIT_REPOSITORY + \* SVN_REPOSITORY \* HG_REPOSITORY \* CVS_REPOSITORY and CVS_MODULE - \* SVN_REVISION - \* DOWNLOAD_COMMAND Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\) NoOptions.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 47d612969..994e2aa90 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -12,3 +12,13 @@ run_cmake(Add_StepDependencies_iface) run_cmake(Add_StepDependencies_iface_step) run_cmake(Add_StepDependencies_no_target) run_cmake(UsesTerminal) + +# Run both cmake and build steps. We always do a clean before the +# build to ensure that the download step re-runs each time. +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MultiCommand-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +run_cmake(MultiCommand) +run_cmake_command(MultiCommand-clean ${CMAKE_COMMAND} --build . --target clean) +run_cmake_command(MultiCommand-build ${CMAKE_COMMAND} --build .) diff --git a/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt b/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt index 58a343ccf..07c6e8798 100644 --- a/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt +++ b/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt @@ -6,12 +6,12 @@ is not an existing non-empty directory. Please specify one of: \* SOURCE_DIR with an existing non-empty directory + \* DOWNLOAD_COMMAND \* URL \* GIT_REPOSITORY + \* SVN_REPOSITORY \* HG_REPOSITORY \* CVS_REPOSITORY and CVS_MODULE - \* SVN_REVISION - \* DOWNLOAD_COMMAND Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\) SourceEmpty.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt b/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt index e62f7cf5a..373f6e3aa 100644 --- a/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt +++ b/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt @@ -6,12 +6,12 @@ is not an existing non-empty directory. Please specify one of: \* SOURCE_DIR with an existing non-empty directory + \* DOWNLOAD_COMMAND \* URL \* GIT_REPOSITORY + \* SVN_REPOSITORY \* HG_REPOSITORY \* CVS_REPOSITORY and CVS_MODULE - \* SVN_REVISION - \* DOWNLOAD_COMMAND Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\) SourceMissing.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/FPHSA/FindPseudoNoVersionVar.cmake b/Tests/RunCMake/FPHSA/FindPseudoNoVersionVar.cmake new file mode 100644 index 000000000..d961c6489 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindPseudoNoVersionVar.cmake @@ -0,0 +1,6 @@ +# pseudo find_module without specifying VERSION_VAR + +set(FOOBAR TRUE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PseudoNoVersionVar REQUIRED_VARS FOOBAR) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index e9b2a7a70..dd73cd487 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -4,7 +4,18 @@ run_cmake(BadFoundVar) # The pseudo module will "find" a package with the given version. Check if the # version selection code in FPHSA works correctly. -set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=1.2.3.4.5") + +# Find a package with version 0. +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0") +run_cmake(any_version_find_0) + +# Find a package with more customary version number, without requesting a specific version and in +# the presence of a cache variable VERSION. +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudoNoVersionVar_VERSION=1.2.3.4_SHOULD_BE_IGNORED" "-DVERSION=BAD_VERSION") +run_cmake(any_version_VERSION_cache_variable) + +# Find a package with a more customary version number, without requesting a specific version. +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=1.2.3.4") run_cmake(any_version) # test EXACT mode with every subcomponent diff --git a/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable-stdout.txt b/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable-stdout.txt new file mode 100644 index 000000000..f9acece45 --- /dev/null +++ b/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable-stdout.txt @@ -0,0 +1,2 @@ +Found PseudoNoVersionVar: TRUE * ++ diff --git a/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable.cmake b/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable.cmake new file mode 100644 index 000000000..9f278979b --- /dev/null +++ b/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable.cmake @@ -0,0 +1 @@ +find_package(PseudoNoVersionVar REQUIRED) diff --git a/Tests/RunCMake/FPHSA/any_version_find_0-stdout.txt b/Tests/RunCMake/FPHSA/any_version_find_0-stdout.txt new file mode 100644 index 000000000..861a33987 --- /dev/null +++ b/Tests/RunCMake/FPHSA/any_version_find_0-stdout.txt @@ -0,0 +1,2 @@ +Found Pseudo: [^ +]*\(found version "0\"\) diff --git a/Tests/RunCMake/FPHSA/any_version_find_0.cmake b/Tests/RunCMake/FPHSA/any_version_find_0.cmake new file mode 100644 index 000000000..b34a540c9 --- /dev/null +++ b/Tests/RunCMake/FPHSA/any_version_find_0.cmake @@ -0,0 +1 @@ +find_package(Pseudo REQUIRED) diff --git a/Tests/RunCMake/File_Generate/CMP0070-NEW-check.cmake b/Tests/RunCMake/File_Generate/CMP0070-NEW-check.cmake new file mode 100644 index 000000000..05ec26eed --- /dev/null +++ b/Tests/RunCMake/File_Generate/CMP0070-NEW-check.cmake @@ -0,0 +1,13 @@ +foreach(f + "${RunCMake_TEST_SOURCE_DIR}/relative-input-NEW.txt" + "${RunCMake_TEST_BINARY_DIR}/relative-output-NEW.txt" + ) + if(EXISTS "${f}") + file(READ "${f}" content) + if(NOT content MATCHES "^relative-input-NEW[\r\n]*$") + string(APPEND RunCMake_TEST_FAILED "File\n ${f}\ndoes not have expected content.\n") + endif() + else() + string(APPEND RunCMake_TEST_FAILED "Missing\n ${f}\n") + endif() +endforeach() diff --git a/Tests/RunCMake/File_Generate/CMP0070-NEW.cmake b/Tests/RunCMake/File_Generate/CMP0070-NEW.cmake new file mode 100644 index 000000000..1a0382221 --- /dev/null +++ b/Tests/RunCMake/File_Generate/CMP0070-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT relative-output-NEW.txt INPUT relative-input-NEW.txt) diff --git a/Tests/RunCMake/File_Generate/CMP0070-OLD-check.cmake b/Tests/RunCMake/File_Generate/CMP0070-OLD-check.cmake new file mode 100644 index 000000000..a71d822bb --- /dev/null +++ b/Tests/RunCMake/File_Generate/CMP0070-OLD-check.cmake @@ -0,0 +1,13 @@ +foreach(f + "${RunCMake_TEST_BINARY_DIR}/relative-input-OLD.txt" + "${RunCMake_TEST_BINARY_DIR}/relative-output-OLD.txt" + ) + if(EXISTS "${f}") + file(READ "${f}" content) + if(NOT content MATCHES "^relative-input-OLD[\r\n]*$") + string(APPEND RunCMake_TEST_FAILED "File\n ${f}\ndoes not have expected content.\n") + endif() + else() + string(APPEND RunCMake_TEST_FAILED "Missing\n ${f}\n") + endif() +endforeach() diff --git a/Tests/RunCMake/File_Generate/CMP0070-OLD.cmake b/Tests/RunCMake/File_Generate/CMP0070-OLD.cmake new file mode 100644 index 000000000..0fb47cdfa --- /dev/null +++ b/Tests/RunCMake/File_Generate/CMP0070-OLD.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0070 OLD) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/relative-input-OLD.txt "relative-input-OLD\n") +file(GENERATE OUTPUT relative-output-OLD.txt INPUT relative-input-OLD.txt) diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN-check.cmake b/Tests/RunCMake/File_Generate/CMP0070-WARN-check.cmake new file mode 100644 index 000000000..1488df09d --- /dev/null +++ b/Tests/RunCMake/File_Generate/CMP0070-WARN-check.cmake @@ -0,0 +1,13 @@ +foreach(f + "${RunCMake_TEST_BINARY_DIR}/relative-input-WARN.txt" + "${RunCMake_TEST_BINARY_DIR}/relative-output-WARN.txt" + ) + if(EXISTS "${f}") + file(READ "${f}" content) + if(NOT content MATCHES "^relative-input-WARN[\r\n]*$") + string(APPEND RunCMake_TEST_FAILED "File\n ${f}\ndoes not have expected content.\n") + endif() + else() + string(APPEND RunCMake_TEST_FAILED "Missing\n ${f}\n") + endif() +endforeach() diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt new file mode 100644 index 000000000..dbabaa97b --- /dev/null +++ b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt @@ -0,0 +1,27 @@ +^CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative + paths. Run "cmake --help-policy CMP0070" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + file\(GENERATE\) given relative INPUT path: + + relative-input-WARN.txt + + This is not defined behavior unless CMP0070 is set to NEW. For + compatibility with older versions of CMake, the previous undefined behavior + will be used. +This warning is for project developers. Use -Wno-dev to suppress it.( ++ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative + paths. Run "cmake --help-policy CMP0070" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + file\(GENERATE\) given relative OUTPUT path: + + relative-output-WARN.txt + + This is not defined behavior unless CMP0070 is set to NEW. For + compatibility with older versions of CMake, the previous undefined behavior + will be used. +This warning is for project developers. Use -Wno-dev to suppress it.)+$ diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN.cmake b/Tests/RunCMake/File_Generate/CMP0070-WARN.cmake new file mode 100644 index 000000000..ccb045231 --- /dev/null +++ b/Tests/RunCMake/File_Generate/CMP0070-WARN.cmake @@ -0,0 +1,2 @@ +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/relative-input-WARN.txt "relative-input-WARN\n") +file(GENERATE OUTPUT relative-output-WARN.txt INPUT relative-input-WARN.txt) diff --git a/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake b/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake index e2b081d48..59ccf197d 100644 --- a/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake +++ b/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake @@ -7,6 +7,6 @@ target_compile_options(empty ) file(GENERATE - OUTPUT opts-$<COMPILE_LANGUAGE>.txt + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opts-$<COMPILE_LANGUAGE>.txt CONTENT "$<TARGET_PROPERTY:empty,COMPILE_OPTIONS>\n" ) diff --git a/Tests/RunCMake/File_Generate/ReRunCMake.cmake b/Tests/RunCMake/File_Generate/ReRunCMake.cmake index 109d60e6f..541d86df2 100644 --- a/Tests/RunCMake/File_Generate/ReRunCMake.cmake +++ b/Tests/RunCMake/File_Generate/ReRunCMake.cmake @@ -1,5 +1,5 @@ file(GENERATE - OUTPUT output_file.txt + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output_file.txt" INPUT "${CMAKE_CURRENT_BINARY_DIR}/input_file.txt" ) diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index 82e903d82..b6604636a 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -1,5 +1,9 @@ include(RunCMake) +run_cmake(CMP0070-NEW) +run_cmake(CMP0070-OLD) +run_cmake(CMP0070-WARN) + run_cmake(CommandConflict) if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") run_cmake(OutputConflict) diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake index d1d832a11..bb36a4c48 100644 --- a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake +++ b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake @@ -1,5 +1,5 @@ file(GENERATE - OUTPUT output_file.txt + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/output_file.txt CONTENT "123" ) diff --git a/Tests/RunCMake/File_Generate/relative-input-NEW.txt b/Tests/RunCMake/File_Generate/relative-input-NEW.txt new file mode 100644 index 000000000..7293e904a --- /dev/null +++ b/Tests/RunCMake/File_Generate/relative-input-NEW.txt @@ -0,0 +1 @@ +relative-input-NEW diff --git a/Tests/RunCMake/FindBoost/CMakeLists.txt b/Tests/RunCMake/FindBoost/CMakeLists.txt new file mode 100644 index 000000000..d3137f614 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.9) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt b/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt new file mode 100644 index 000000000..664e4a5f8 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt @@ -0,0 +1,3 @@ +-- Boost 1\.12345 found\. +-- Found Boost components: + date_time diff --git a/Tests/RunCMake/FindBoost/CMakePackage.cmake b/Tests/RunCMake/FindBoost/CMakePackage.cmake new file mode 100644 index 000000000..06aeccb2d --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage.cmake @@ -0,0 +1,2 @@ +set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage) +find_package(Boost 1.12345 COMPONENTS date_time) diff --git a/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake diff --git a/Tests/RunCMake/FindBoost/CMakePackage/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfigVersion.cmake new file mode 100644 index 000000000..8176ced19 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfigVersion.cmake @@ -0,0 +1,7 @@ +set(PACKAGE_VERSION 1.12345) +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1) + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION_MINOR EQUAL 12345) + set(PACKAGE_VERSION_EXACT 1) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/RunCMakeTest.cmake b/Tests/RunCMake/FindBoost/RunCMakeTest.cmake new file mode 100644 index 000000000..a153ae18f --- /dev/null +++ b/Tests/RunCMake/FindBoost/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(CMakePackage) diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat index b03837030..486977cbb 100755 --- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat @@ -1,27 +1,27 @@ -@ECHO OFF - -:LOOP - -IF "%1"=="" ( - EXIT /B 255 -) - -IF "%1"=="--version" ( - ECHO 0.0-cmake-dummy - EXIT /B 0 -) - -IF "%1"=="--exists" ( - SHIFT - ECHO Expected: %* - ECHO Found: %PKG_CONFIG_PATH% - IF NOT "%*"=="%PKG_CONFIG_PATH%" ( - EXIT /B 1 - ) ELSE ( - EXIT /B 0 - ) -) -SHIFT -IF NOT "%~1"=="" GOTO LOOP - -EXIT /B 255 +@ECHO OFF
+
+:LOOP
+
+IF "%1"=="" (
+ EXIT /B 255
+)
+
+IF "%1"=="--version" (
+ ECHO 0.0-cmake-dummy
+ EXIT /B 0
+)
+
+IF "%1"=="--exists" (
+ SHIFT
+ ECHO Expected: %*
+ ECHO Found: %PKG_CONFIG_PATH%
+ IF NOT "%*"=="%PKG_CONFIG_PATH%" (
+ EXIT /B 1
+ ) ELSE (
+ EXIT /B 0
+ )
+)
+SHIFT
+IF NOT "%~1"=="" GOTO LOOP
+
+EXIT /B 255
diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake index 3d62a8af3..4f4245952 100644 --- a/Tests/RunCMake/Framework/FrameworkLayout.cmake +++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake @@ -22,4 +22,4 @@ set_source_files_properties(some.txt PROPERTIES MACOSX_PACKAGE_LOCATION somedir) add_custom_command(TARGET Framework POST_BUILD COMMAND /usr/bin/file $<TARGET_FILE:Framework>) -file(GENERATE OUTPUT FrameworkName.cmake CONTENT "set(framework-dir \"$<TARGET_BUNDLE_DIR:Framework>\")\n") +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkName.cmake CONTENT "set(framework-dir \"$<TARGET_BUNDLE_DIR:Framework>\")\n") diff --git a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt index 532cfedcc..4b5f761af 100644 --- a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt +++ b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt @@ -1,2 +1,2 @@ -.*/Framework:( Mach-O universal binary with [^ -]*)? current ar archive random library.* +/Framework: (Mach-O universal binary with [^ +]*)?current ar archive random library diff --git a/Tests/RunCMake/Framework/ios.cmake b/Tests/RunCMake/Framework/ios.cmake index 209a50d39..446e9146a 100644 --- a/Tests/RunCMake/Framework/ios.cmake +++ b/Tests/RunCMake/Framework/ios.cmake @@ -20,6 +20,16 @@ execute_process( OUTPUT_VARIABLE IOS_SDK_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process( + COMMAND ${XCRUN_EXECUTABLE} --sdk iphoneos --show-sdk-version + OUTPUT_VARIABLE IOS_SDK_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(IOS_SDK_VERSION VERSION_GREATER_EQUAL 11.0) + set(IOS_ARCH arm64) +else() + set(IOS_ARCH armv7) +endif() + set(CMAKE_OSX_SYSROOT ${IOS_SDK_PATH} CACHE PATH "Sysroot used for iOS support") -set(CMAKE_OSX_ARCHITECTURES "armv7" CACHE STRING "Architectures to build for") +set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE STRING "Architectures to build for") set(CMAKE_FIND_ROOT_PATH ${IOS_SDK_PATH} CACHE PATH "Find search path root") diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index e0677a7a3..cfca8fe01 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -45,13 +45,6 @@ include(GenerateExportHeader) set(CMAKE_CXX_STANDARD 98) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes deleted file mode 100644 index 883a7f16d..000000000 --- a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Exclude reference content from formatting. -* -format.clang-format diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt index 789b4d09a..c8b124af3 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt @@ -3,8 +3,8 @@ CMake Error at COMPILE_LANGUAGE-add_custom_command.cmake:6 \(add_custom_command\ \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt index 400fbc035..e8cefc72b 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt @@ -3,8 +3,8 @@ CMake Error at COMPILE_LANGUAGE-add_custom_target.cmake:4 \(add_custom_target\): \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt index e45bb020e..7fa1f2589 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt @@ -3,8 +3,8 @@ CMake Error at COMPILE_LANGUAGE-add_executable.cmake:4 \(add_executable\): \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt index c9ee6fe2a..ee60b5895 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt @@ -3,8 +3,8 @@ CMake Error at COMPILE_LANGUAGE-add_library.cmake:4 \(add_library\): \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt index 9955f5d91..fd8a731f1 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt @@ -3,8 +3,8 @@ CMake Error at COMPILE_LANGUAGE-add_test.cmake:5 \(add_test\): \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt index eca700f4d..bef7f63b9 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt @@ -3,6 +3,6 @@ CMake Error: \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt index 2d324e2ac..687d9b782 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt @@ -3,8 +3,8 @@ CMake Error at COMPILE_LANGUAGE-target_sources.cmake:5 \(target_sources\): \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake index 89993ee09..dee7ead54 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake @@ -1,5 +1,5 @@ +cmake_policy(SET CMP0070 NEW) enable_language(C) add_library(foo empty.c empty2.c) target_sources(foo PRIVATE empty3.c) -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo.txt - CONTENT "$<TARGET_PROPERTY:foo,SOURCES>") +file(GENERATE OUTPUT foo.txt CONTENT "$<TARGET_PROPERTY:foo,SOURCES>") diff --git a/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake b/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake new file mode 100644 index 000000000..3856c54b6 --- /dev/null +++ b/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake_command(TargetMissing ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TargetMissing.cmake) diff --git a/Tests/RunCMake/GetPrerequisites/TargetMissing-stderr.txt b/Tests/RunCMake/GetPrerequisites/TargetMissing-stderr.txt new file mode 100644 index 000000000..cffe5f804 --- /dev/null +++ b/Tests/RunCMake/GetPrerequisites/TargetMissing-stderr.txt @@ -0,0 +1,3 @@ +^warning: target 'does_not_exist' is not absolute\.\.\. +warning: target 'does_not_exist' does not exist\.\.\. +result_var='value;before;call'$ diff --git a/Tests/RunCMake/GetPrerequisites/TargetMissing.cmake b/Tests/RunCMake/GetPrerequisites/TargetMissing.cmake new file mode 100644 index 000000000..84fd32ce1 --- /dev/null +++ b/Tests/RunCMake/GetPrerequisites/TargetMissing.cmake @@ -0,0 +1,4 @@ +include(GetPrerequisites) +set(result_var value before call) +get_prerequisites(does_not_exist result_var 0 0 "" "") +message("result_var='${result_var}'") diff --git a/Tests/RunCMake/GoogleTest/CMakeLists.txt b/Tests/RunCMake/GoogleTest/CMakeLists.txt new file mode 100644 index 000000000..dc9248697 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.6) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test-stdout.txt new file mode 100644 index 000000000..5f7753dba --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test-stdout.txt @@ -0,0 +1,25 @@ +Test project .* + Start 1: TEST:basic\.case_foo!1 +1/8 Test #1: TEST:basic\.case_foo!1 \.+ +Passed +[0-9.]+ sec + Start 2: TEST:basic\.case_bar!1 +2/8 Test #2: TEST:basic\.case_bar!1 \.+ +Passed +[0-9.]+ sec + Start 3: TEST:basic\.disabled_case!1 +3/8 Test #3: TEST:basic\.disabled_case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 4: TEST:disabled\.case!1 +4/8 Test #4: TEST:disabled\.case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 5: TEST:typed/short\.case!1 +5/8 Test #5: TEST:typed/short\.case!1 \.+ +Passed +[0-9.]+ sec + Start 6: TEST:typed/float\.case!1 +6/8 Test #6: TEST:typed/float\.case!1 \.+ +Passed +[0-9.]+ sec + Start 7: TEST:value/test\.case/1!1 +7/8 Test #7: TEST:value/test\.case/1!1 \.+ +Passed +[0-9.]+ sec + Start 8: TEST:value/test\.case/"foo"!1 +8/8 Test #8: TEST:value/test\.case/"foo"!1 \.+ +Passed +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 6 + +Total Test time \(real\) = +[0-9.]+ sec + +The following tests did not run: +.*3 - TEST:basic\.disabled_case!1 \(Disabled\) +.*4 - TEST:disabled\.case!1 \(Disabled\) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake new file mode 100644 index 000000000..9a3677fae --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake @@ -0,0 +1,15 @@ +project(test_include_dirs) +include(CTest) +include(GoogleTest) + +enable_testing() + +add_executable(fake_gtest fake_gtest.cpp) + +gtest_discover_tests( + fake_gtest + TEST_PREFIX TEST: + TEST_SUFFIX !1 + EXTRA_ARGS how now "\"brown\" cow" + PROPERTIES LABELS TEST +) diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake new file mode 100644 index 000000000..aec8568d0 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -0,0 +1,26 @@ +include(RunCMake) + +function(run_GoogleTest) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-build) + set(RunCMake_TEST_NO_CLEAN 1) + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(GoogleTest) + run_cmake_command(GoogleTest-build + ${CMAKE_COMMAND} + --build . + --config Debug + ) + run_cmake_command(GoogleTest-test + ${CMAKE_CTEST_COMMAND} + -C Debug + -L TEST + --no-label-summary + ) +endfunction() + +run_GoogleTest() diff --git a/Tests/RunCMake/GoogleTest/fake_gtest.cpp b/Tests/RunCMake/GoogleTest/fake_gtest.cpp new file mode 100644 index 000000000..f1bd7efc8 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp @@ -0,0 +1,41 @@ +#include <iostream> +#include <string> + +int main(int argc, char** argv) +{ + // Note: GoogleTest.cmake doesn't actually depend on Google Test as such; + // it only requires that we produces output in the expected format when + // invoked with --gtest_list_tests. Thus, we fake that here. This allows us + // to test the module without actually needing Google Test. + if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") { + std::cout << "basic." << std::endl; + std::cout << " case_foo" << std::endl; + std::cout << " case_bar" << std::endl; + std::cout << " DISABLED_disabled_case" << std::endl; + std::cout << "DISABLED_disabled." << std::endl; + std::cout << " case" << std::endl; + std::cout << "typed/0. # TypeParam = short" << std::endl; + std::cout << " case" << std::endl; + std::cout << "typed/1. # TypeParam = float" << std::endl; + std::cout << " case" << std::endl; + std::cout << "value/test." << std::endl; + std::cout << " case/0 # GetParam() = 1" << std::endl; + std::cout << " case/1 # GetParam() = \"foo\"" << std::endl; + return 0; + } + + if (argc > 5) { + // Simple test of EXTRA_ARGS + if (std::string(argv[3]) == "how" && std::string(argv[4]) == "now" && + std::string(argv[5]) == "\"brown\" cow") { + return 0; + } + } + + // Print arguments for debugging, if we didn't get the expected arguments + for (int i = 1; i < argc; ++i) { + std::cerr << "arg[" << i << "]: '" << argv[i] << "'\n"; + } + + return 1; +} diff --git a/Tests/RunCMake/MultiLint/C-Build-stdout.txt b/Tests/RunCMake/MultiLint/C-Build-stdout.txt new file mode 100644 index 000000000..d10427ea6 --- /dev/null +++ b/Tests/RunCMake/MultiLint/C-Build-stdout.txt @@ -0,0 +1,8 @@ +Warning: include-what-you-use reported diagnostics: +should add these lines: +* +#include <\.\.\.> ++ +.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.c:0:0: warning: message \[checker\].* +Total errors found: 0 +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/MultiLint/C-launch-Build-stdout.txt b/Tests/RunCMake/MultiLint/C-launch-Build-stdout.txt new file mode 100644 index 000000000..d10427ea6 --- /dev/null +++ b/Tests/RunCMake/MultiLint/C-launch-Build-stdout.txt @@ -0,0 +1,8 @@ +Warning: include-what-you-use reported diagnostics: +should add these lines: +* +#include <\.\.\.> ++ +.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.c:0:0: warning: message \[checker\].* +Total errors found: 0 +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/MultiLint/C-launch.cmake b/Tests/RunCMake/MultiLint/C-launch.cmake new file mode 100644 index 000000000..e66ca203e --- /dev/null +++ b/Tests/RunCMake/MultiLint/C-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C.cmake) diff --git a/Tests/RunCMake/MultiLint/C.cmake b/Tests/RunCMake/MultiLint/C.cmake new file mode 100644 index 000000000..495d6f042 --- /dev/null +++ b/Tests/RunCMake/MultiLint/C.cmake @@ -0,0 +1,6 @@ +enable_language(C) +set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -some -args) +set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -some -args) +set(CMAKE_C_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80) +set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}") +add_executable(main main.c) diff --git a/Tests/RunCMake/MultiLint/CMakeLists.txt b/Tests/RunCMake/MultiLint/CMakeLists.txt new file mode 100644 index 000000000..bf2ef1506 --- /dev/null +++ b/Tests/RunCMake/MultiLint/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.10) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MultiLint/CXX-Build-stdout.txt b/Tests/RunCMake/MultiLint/CXX-Build-stdout.txt new file mode 100644 index 000000000..aaf5fd738 --- /dev/null +++ b/Tests/RunCMake/MultiLint/CXX-Build-stdout.txt @@ -0,0 +1,8 @@ +Warning: include-what-you-use reported diagnostics: +should add these lines: +* +#include <\.\.\.> ++ +.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.cxx:0:0: warning: message \[checker\].* +Total errors found: 0 +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/MultiLint/CXX-launch-Build-stdout.txt b/Tests/RunCMake/MultiLint/CXX-launch-Build-stdout.txt new file mode 100644 index 000000000..aaf5fd738 --- /dev/null +++ b/Tests/RunCMake/MultiLint/CXX-launch-Build-stdout.txt @@ -0,0 +1,8 @@ +Warning: include-what-you-use reported diagnostics: +should add these lines: +* +#include <\.\.\.> ++ +.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.cxx:0:0: warning: message \[checker\].* +Total errors found: 0 +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/MultiLint/CXX-launch.cmake b/Tests/RunCMake/MultiLint/CXX-launch.cmake new file mode 100644 index 000000000..3002c9d68 --- /dev/null +++ b/Tests/RunCMake/MultiLint/CXX-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX.cmake) diff --git a/Tests/RunCMake/MultiLint/CXX.cmake b/Tests/RunCMake/MultiLint/CXX.cmake new file mode 100644 index 000000000..dc30146a6 --- /dev/null +++ b/Tests/RunCMake/MultiLint/CXX.cmake @@ -0,0 +1,6 @@ +enable_language(CXX) +set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -some -args) +set(CMAKE_CXX_CLANG_TIDY "${PSEUDO_TIDY}" -some -args) +set(CMAKE_CXX_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80) +set(CMAKE_CXX_CPPCHECK "${PSEUDO_CPPCHECK}") +add_executable(main main.cxx) diff --git a/Tests/RunCMake/MultiLint/RunCMakeTest.cmake b/Tests/RunCMake/MultiLint/RunCMakeTest.cmake new file mode 100644 index 000000000..afd98fd08 --- /dev/null +++ b/Tests/RunCMake/MultiLint/RunCMakeTest.cmake @@ -0,0 +1,27 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS + "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}" + "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}" + "-DPSEUDO_IWYU=${PSEUDO_IWYU}" + "-DPSEUDO_TIDY=${PSEUDO_TIDY}" + ) + +function(run_multilint lang) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${lang}) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .) +endfunction() + +run_multilint(C) +run_multilint(CXX) + +if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_multilint(C-launch) + run_multilint(CXX-launch) +endif() diff --git a/Tests/RunCMake/MultiLint/main.c b/Tests/RunCMake/MultiLint/main.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/Tests/RunCMake/MultiLint/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/MultiLint/main.cxx b/Tests/RunCMake/MultiLint/main.cxx new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/RunCMake/MultiLint/main.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/README.rst b/Tests/RunCMake/README.rst index 4aae4aed5..08b51d9c7 100644 --- a/Tests/RunCMake/README.rst +++ b/Tests/RunCMake/README.rst @@ -47,11 +47,11 @@ but do not actually build anything. To add a test: containing expected test results: ``<SubTest>-result.txt`` - Process result expected if not "0" + Regex matching expected process result, if not ``0`` ``<SubTest>-stdout.txt`` Regex matching expected stdout content ``<SubTest>-stderr.txt`` - Regex matching expected stderr content, if not "^$" + Regex matching expected stderr content, if not ``^$`` ``<SubTest>-check.cmake`` Custom result check. diff --git a/Tests/RunCMake/Syntax/.gitattributes b/Tests/RunCMake/Syntax/.gitattributes deleted file mode 100644 index 35a9eaf2b..000000000 --- a/Tests/RunCMake/Syntax/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -CommandTabs.cmake whitespace=-tab-in-indent -StringCRLF.cmake whitespace=cr-at-eol -crlf -BracketCRLF.cmake whitespace=cr-at-eol -crlf diff --git a/Tests/RunCMake/Syntax/NullTerminatedArgument-result.txt b/Tests/RunCMake/Syntax/NullTerminatedArgument-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/Syntax/NullTerminatedArgument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Syntax/NullTerminatedArgument-stderr.txt b/Tests/RunCMake/Syntax/NullTerminatedArgument-stderr.txt new file mode 100644 index 000000000..f26754e69 --- /dev/null +++ b/Tests/RunCMake/Syntax/NullTerminatedArgument-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at NullTerminatedArgument.cmake:1: + Parse error. Function missing ending "\)". Instead found bad character + with text "". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/NullTerminatedArgument.cmake b/Tests/RunCMake/Syntax/NullTerminatedArgument.cmake Binary files differnew file mode 100644 index 000000000..c82aceb53 --- /dev/null +++ b/Tests/RunCMake/Syntax/NullTerminatedArgument.cmake diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake index d1fbb16aa..628df91cf 100644 --- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake +++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake @@ -55,6 +55,7 @@ run_cmake(BracketNoSpace5) run_cmake(Escape1) run_cmake(Escape2) run_cmake(EscapeCharsAllowed) +run_cmake(NullTerminatedArgument) include("${RunCMake_SOURCE_DIR}/EscapeCharsDisallowed.cmake") run_cmake(ParenNoSpace0) run_cmake(ParenNoSpace1) diff --git a/Tests/RunCMake/TargetObjects/NoTarget.cmake b/Tests/RunCMake/TargetObjects/NoTarget.cmake index 5d7e33e79..268577d50 100644 --- a/Tests/RunCMake/TargetObjects/NoTarget.cmake +++ b/Tests/RunCMake/TargetObjects/NoTarget.cmake @@ -1,7 +1,7 @@ add_library(iface INTERFACE) target_sources(iface INTERFACE $<TARGET_OBJECTS:NoTarget>) -file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:NoTarget>) -file(GENERATE OUTPUT test_output2 CONTENT $<TARGET_PROPERTY:iface,INTERFACE_SOURCES>) +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:NoTarget>) +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output2 CONTENT $<TARGET_PROPERTY:iface,INTERFACE_SOURCES>) install(FILES $<TARGET_OBJECTS:NoTarget> DESTINATION objects) diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake index 8e5fdd047..3bb3e374d 100644 --- a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake +++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake @@ -1,3 +1,3 @@ add_library(StaticLib empty.cpp) -file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:StaticLib>) +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:StaticLib>) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 3af877f4f..6e7c2f313 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -4,3 +4,4 @@ run_cmake(VsTargetsFileReferences) run_cmake(VsCustomProps) run_cmake(VsDebuggerWorkingDir) run_cmake(VsCSharpCustomTags) +run_cmake(VsCSharpReferenceProps) diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake index 70ea19326..9eb4619f4 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake @@ -4,20 +4,31 @@ if(NOT EXISTS "${csProjectFile}") return() endif() -set(tagFound FALSE) +# test VS_CSHARP_* for the following extensions +set(fileExtensions + "cs" + "png" + "jpg" + "xml" + "settings") +# set(tagName "MyCustomTag") set(tagValue "MyCustomValue") file(STRINGS "${csProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "^ *<${tagName}>${tagValue}</${tagName}>") - message(STATUS "foo.csproj has tag ${tagName} with value ${tagValue} defined") - set(tagFound TRUE) + +foreach(e ${fileExtensions}) + string(TOUPPER ${e} eUC) + set(tagFound FALSE) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<${tagName}${eUC}>${tagValue}${eUC}</${tagName}${eUC}>") + message(STATUS "foo.csproj has tag ${tagName}${eUC} with value ${tagValue}${eUC} defined") + set(tagFound TRUE) + endif() + endforeach() + if(NOT tagFound) + set(RunCMake_TEST_FAILED "Source file tag ${tagName}${eUC} with value ${tagValue}${eUC} not found.") + return() endif() endforeach() - -if(NOT tagFound) - set(RunCMake_TEST_FAILED "Source file tag ${tagName} with value ${tagValue} not found.") - return() -endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake index c51e9c370..45766a07c 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake @@ -1,11 +1,27 @@ enable_language(CSharp) -add_library(foo foo.cs) -set(props_file "${CMAKE_CURRENT_SOURCE_DIR}/my.props") +# test VS_CSHARP_* for the following extensions +set(fileExtensions + "cs" + "png" + "jpg" + "xml" + "settings") +# set(tagName "MyCustomTag") set(tagValue "MyCustomValue") -set_source_files_properties(foo.cs - PROPERTIES - VS_CSHARP_${tagName} "${tagValue}") +set(fileNames) +foreach(e ${fileExtensions}) + set(currentFile "${CMAKE_CURRENT_BINARY_DIR}/foo.${e}") + list(APPEND fileNames ${currentFile}) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch + "${currentFile}") + string(TOUPPER ${e} eUC) + set_source_files_properties("${currentFile}" + PROPERTIES + VS_CSHARP_${tagName}${eUC} "${tagValue}${eUC}") +endforeach() + +add_library(foo ${fileNames}) diff --git a/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-check.cmake new file mode 100644 index 000000000..8b9bb6731 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-check.cmake @@ -0,0 +1,49 @@ +set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj") +if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() +endif() + +set(test1Reference "System") +set(test1Tag "Hello") +set(test1Value "World") + +set(test2Reference "foo2") +set(test2Tag "Hallo") +set(test2Value "Welt") + +set(tag1Found FALSE) +set(ref1Found FALSE) + +file(STRINGS "${csProjectFile}" lines) + +foreach(i 1 2) + set(testReference "${test${i}Reference}") + set(testTag "${test${i}Tag}") + set(testValue "${test${i}Value}") + foreach(line IN LISTS lines) + if(line MATCHES "^ *<(Project|)Reference .*>$") + set(validTag FALSE) + if(line MATCHES "^ *<(Project|)Reference .*\".*${testReference}.*\".*>$") + set(validTag TRUE) + message(STATUS "foo.csproj is using reference ${testReference}") + set(ref${i}Found TRUE) + endif() + endif() + if(line MATCHES "^ *<${testTag}>${testValue}</${testTag}>$") + if(validTag) + message(STATUS "foo.csproj reference ${testReference} has tag ${testTag}") + set(tag${i}Found TRUE) + else() + message(STATUS "tag ${testTag} found in wrong place!") + set(tag${i}Found FALSE) + endif() + endif() + endforeach() +endforeach() + +if(NOT tag1Found OR NOT ref1Found OR + NOT tag2Found OR NOT ref2Found) + set(RunCMake_TEST_FAILED "Custom reference XML tag not found.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake new file mode 100644 index 000000000..2af17569e --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake @@ -0,0 +1,19 @@ +enable_language(CSharp) +add_library(foo foo.cs) +add_library(foo2 foo.cs) + +set(test1Reference "System") +set(test1Tag "Hello") +set(test1Value "World") + +set(test2Reference "foo2") +set(test2Tag "Hallo") +set(test2Value "Welt") + +target_link_libraries(foo foo2) + +set_target_properties(foo PROPERTIES + VS_DOTNET_REFERENCES "${test1Reference};Blubb" + VS_DOTNET_REFERENCEPROP_${test1Reference}_TAG_${test1Tag} ${test1Value} + VS_DOTNET_REFERENCEPROP_${test2Reference}_TAG_${test2Tag} ${test2Value} + ) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 5f4bdc30d..7d436b619 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -1,5 +1,9 @@ include(RunCMake) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(IOS_DEPLOYMENT_TARGET "-DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=10") +endif() + run_cmake(XcodeFileType) run_cmake(XcodeAttributeLocation) run_cmake(XcodeAttributeGenex) @@ -20,7 +24,9 @@ run_cmake(PerConfigPerSourceFlags) if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeInstallIOS-build) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install") + set(RunCMake_TEST_OPTIONS + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install" + "${IOS_DEPLOYMENT_TARGET}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -53,7 +59,8 @@ if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS "-DTEST_IOS=ON" - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "${IOS_DEPLOYMENT_TARGET}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -117,7 +124,8 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" - "-DCMAKE_IOS_INSTALL_COMBINED=YES") + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "${IOS_DEPLOYMENT_TARGET}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -135,7 +143,8 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" - "-DCMAKE_IOS_INSTALL_COMBINED=YES") + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "${IOS_DEPLOYMENT_TARGET}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -153,7 +162,8 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" - "-DCMAKE_IOS_INSTALL_COMBINED=YES") + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "${IOS_DEPLOYMENT_TARGET}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -170,6 +180,7 @@ endif() if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeMultiplatform-build) set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "${IOS_DEPLOYMENT_TARGET}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") diff --git a/Tests/RunCMake/add_custom_command/RemoveEmptyCommands-check.cmake b/Tests/RunCMake/add_custom_command/RemoveEmptyCommands-check.cmake new file mode 100644 index 000000000..b2970444e --- /dev/null +++ b/Tests/RunCMake/add_custom_command/RemoveEmptyCommands-check.cmake @@ -0,0 +1,63 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/exe.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(inGroup FALSE) +set(inCommand FALSE) + +set(expected_Debug + "cmd_1 cmd_1_arg" + "cmd_1_dbg cmd_1_dbg_arg" + "cmd_2_dbg cmd_2_dbg_arg" + "cmd_3_dbg cmd_3_dbg_arg") + +set(expected_Release + "cmd_1 cmd_1_arg" + "cmd_3_rel cmd_3_rel_arg") + +# extract build events +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<ItemDefinitionGroup Condition=.*Configuration.*Platform.*>$") + set(inGroup TRUE) + string(REGEX MATCH "=='(.*)\\|(.*)'" out ${line}) + set(config ${CMAKE_MATCH_1}) + elseif(line MATCHES "^ *</ItemDefinitionGroup>$") + set(inGroup FALSE) + elseif(inGroup) + if(line MATCHES "^ *<Command>.*$") + set(inCommand TRUE) + string(REGEX MATCH "<Command>(.*)" cmd ${line}) + set(currentCommand ${CMAKE_MATCH_1}) + elseif(line MATCHES "^(.*)</Command>$") + string(REGEX MATCH "(.*)</Command>" cmd ${line}) + list(APPEND currentCommand ${CMAKE_MATCH_1}) + set(command_${config} ${currentCommand}) + set(inCommand FALSE) + elseif(inCommand) + list(APPEND currentCommand ${line}) + endif() + endif() +endforeach() + +foreach(config "Debug" "Release") + set(currentName command_${config}) + set(expectedName expected_${config}) + set(strippedCommand "") + if(DEFINED ${currentName}) + foreach(v ${${currentName}}) + if(${v} MATCHES "cmd_") + list(APPEND strippedCommand ${v}) + endif() + endforeach() + if(NOT "${strippedCommand}" STREQUAL + "${${expectedName}}") + message(" - ${strippedCommand}") + message(" + ${${expectedName}}") + set(RunCMake_TEST_FAILED "build event command does not match") + return() + endif() + endif() +endforeach() diff --git a/Tests/RunCMake/add_custom_command/RemoveEmptyCommands.cmake b/Tests/RunCMake/add_custom_command/RemoveEmptyCommands.cmake new file mode 100644 index 000000000..eb190cc99 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/RemoveEmptyCommands.cmake @@ -0,0 +1,22 @@ +enable_language(CXX) + +# reduce number of configuration types +set(CMAKE_CONFIGURATION_TYPES "Debug" "Release") + +set(main_file "${CMAKE_BINARY_DIR}/main.cpp") +file(WRITE "${main_file}" "test") +add_executable(exe "${main_file}") + +# add one command for all and one for debug only +add_custom_command(TARGET exe + COMMAND "cmd_1" "cmd_1_arg" + COMMAND $<$<CONFIG:Debug>:cmd_1_dbg> $<$<CONFIG:Debug>:cmd_1_dbg_arg>) + +# add command for debug only +add_custom_command(TARGET exe + COMMAND $<$<CONFIG:Debug>:cmd_2_dbg> $<$<CONFIG:Debug>:cmd_2_dbg_arg>) + +# add separate commands for configurations +add_custom_command(TARGET exe + COMMAND $<$<CONFIG:Debug>:cmd_3_dbg> $<$<CONFIG:Debug>:cmd_3_dbg_arg> + COMMAND $<$<CONFIG:Release>:cmd_3_rel> $<$<CONFIG:Release>:cmd_3_rel_arg>) diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 397c63d0a..c12e5aa6e 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -10,3 +10,7 @@ run_cmake(SourceByproducts) run_cmake(SourceUsesTerminal) run_cmake(TargetImported) run_cmake(TargetNotInDir) + +if(${RunCMake_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])") + run_cmake(RemoveEmptyCommands) +endif() diff --git a/Tests/RunCMake/add_executable/CMakeLists.txt b/Tests/RunCMake/add_executable/CMakeLists.txt new file mode 100644 index 000000000..ef2163c29 --- /dev/null +++ b/Tests/RunCMake/add_executable/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_executable/NoSources-result.txt b/Tests/RunCMake/add_executable/NoSources-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_executable/NoSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_executable/NoSources-stderr.txt b/Tests/RunCMake/add_executable/NoSources-stderr.txt new file mode 100644 index 000000000..598590595 --- /dev/null +++ b/Tests/RunCMake/add_executable/NoSources-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at NoSources.cmake:[0-9]+ \(add_executable\): + add_executable called with incorrect number of arguments +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_executable/NoSources.cmake b/Tests/RunCMake/add_executable/NoSources.cmake new file mode 100644 index 000000000..563564ad6 --- /dev/null +++ b/Tests/RunCMake/add_executable/NoSources.cmake @@ -0,0 +1 @@ +add_executable(TestExeWithoutSources) diff --git a/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt new file mode 100644 index 000000000..c8afadb06 --- /dev/null +++ b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at NoSourcesButLinkObjects.cmake:[0-9]+ \(add_executable\): + add_executable called with incorrect number of arguments +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at NoSourcesButLinkObjects.cmake:[0-9]+ \(target_link_libraries\): + Cannot specify link libraries for target \"TestExeWithoutSources\" which is + not built by this project. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_executable/NoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects.cmake new file mode 100644 index 000000000..d0f20934e --- /dev/null +++ b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_executable(TestExeWithoutSources) +target_link_libraries(TestExeWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_executable/OnlyObjectSources-result.txt b/Tests/RunCMake/add_executable/OnlyObjectSources-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_executable/OnlyObjectSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_executable/OnlyObjectSources-stderr.txt b/Tests/RunCMake/add_executable/OnlyObjectSources-stderr.txt new file mode 100644 index 000000000..ea72d5dea --- /dev/null +++ b/Tests/RunCMake/add_executable/OnlyObjectSources-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at OnlyObjectSources.cmake:[0-9]+ \(add_executable\): + add_executable called with incorrect number of arguments +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at OnlyObjectSources.cmake:[0-9]+ \(target_sources\): + Cannot specify sources for target \"TestExeWithoutSources\" which is not + built by this project. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_executable/OnlyObjectSources.cmake b/Tests/RunCMake/add_executable/OnlyObjectSources.cmake new file mode 100644 index 000000000..1c90e9adc --- /dev/null +++ b/Tests/RunCMake/add_executable/OnlyObjectSources.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_executable(TestExeWithoutSources) +target_sources(TestExeWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_executable/RunCMakeTest.cmake b/Tests/RunCMake/add_executable/RunCMakeTest.cmake new file mode 100644 index 000000000..70a68f265 --- /dev/null +++ b/Tests/RunCMake/add_executable/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(NoSources) +run_cmake(OnlyObjectSources) +run_cmake(NoSourcesButLinkObjects) diff --git a/Tests/RunCMake/add_executable/test.cpp b/Tests/RunCMake/add_executable/test.cpp new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/add_executable/test.cpp diff --git a/Tests/RunCMake/add_library/CMakeLists.txt b/Tests/RunCMake/add_library/CMakeLists.txt new file mode 100644 index 000000000..ef2163c29 --- /dev/null +++ b/Tests/RunCMake/add_library/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake b/Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake new file mode 100644 index 000000000..79188f387 --- /dev/null +++ b/Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake @@ -0,0 +1 @@ +add_library(TestInterfaceLibWithoutSources INTERFACE) diff --git a/Tests/RunCMake/add_library/INTERFACEwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/INTERFACEwithNoSourcesButLinkObjects.cmake new file mode 100644 index 000000000..53a48f0bd --- /dev/null +++ b/Tests/RunCMake/add_library/INTERFACEwithNoSourcesButLinkObjects.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestInterfaceLibWithoutSources INTERFACE) +target_link_libraries(TestInterfaceLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/INTERFACEwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/INTERFACEwithOnlyObjectSources.cmake new file mode 100644 index 000000000..86fab1dee --- /dev/null +++ b/Tests/RunCMake/add_library/INTERFACEwithOnlyObjectSources.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestInterfaceLibWithoutSources INTERFACE) +target_sources(TestInterfaceLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/MODULEwithNoSources-result.txt b/Tests/RunCMake/add_library/MODULEwithNoSources-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/MODULEwithNoSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt b/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt new file mode 100644 index 000000000..5cf0b1e8d --- /dev/null +++ b/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt @@ -0,0 +1,3 @@ +^You have called ADD_LIBRARY for library TestModuleLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file( +CMake Error: CMake can not determine linker language for target: TestModuleLibWithoutSources)+( +CMake Error: Cannot determine link language for target \"TestModuleLibWithoutSources\".)?$ diff --git a/Tests/RunCMake/add_library/MODULEwithNoSources.cmake b/Tests/RunCMake/add_library/MODULEwithNoSources.cmake new file mode 100644 index 000000000..5df5033c6 --- /dev/null +++ b/Tests/RunCMake/add_library/MODULEwithNoSources.cmake @@ -0,0 +1 @@ +add_library(TestModuleLibWithoutSources MODULE) diff --git a/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt new file mode 100644 index 000000000..951594a56 --- /dev/null +++ b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt @@ -0,0 +1,3 @@ +^You have called ADD_LIBRARY for library TestModuleLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file( +CMake Error: CMake can not determine linker language for target: TestModuleLibWithoutSources)+( +CMake Error: Cannot determine link language for target \"TestModuleLibWithoutSources\".)*$ diff --git a/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects.cmake new file mode 100644 index 000000000..f9d00dea8 --- /dev/null +++ b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestModuleLibWithoutSources MODULE) +target_link_libraries(TestModuleLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources-stderr.txt b/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources-stderr.txt new file mode 100644 index 000000000..de837554e --- /dev/null +++ b/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources-stderr.txt @@ -0,0 +1 @@ +^You have called ADD_LIBRARY for library TestModuleLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$ diff --git a/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources.cmake new file mode 100644 index 000000000..187481a14 --- /dev/null +++ b/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestModuleLibWithoutSources MODULE) +target_sources(TestModuleLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSources-result.txt b/Tests/RunCMake/add_library/OBJECTwithNoSources-result.txt new file mode 100644 index 000000000..9c558e357 --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithNoSources-result.txt @@ -0,0 +1 @@ +. diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt new file mode 100644 index 000000000..099ec4fad --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt @@ -0,0 +1,2 @@ +^You have called ADD_LIBRARY for library TestObjectLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file( +CMake Error: CMake can not determine linker language for target: TestObjectLibWithoutSources)*$ diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSources.cmake b/Tests/RunCMake/add_library/OBJECTwithNoSources.cmake new file mode 100644 index 000000000..742e8299a --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithNoSources.cmake @@ -0,0 +1 @@ +add_library(TestObjectLibWithoutSources OBJECT) diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt new file mode 100644 index 000000000..8f2009616 --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt @@ -0,0 +1,6 @@ +^You have called ADD_LIBRARY for library TestObjectLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file +CMake Error at OBJECTwithNoSourcesButLinkObjects.cmake:[0-9]+ \(target_link_libraries\): + Object library target \"TestObjectLibWithoutSources\" may not link to + anything. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects.cmake new file mode 100644 index 000000000..6b4b55fda --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestObjectLibWithoutSources OBJECT) +target_link_libraries(TestObjectLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-result.txt b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-stderr.txt new file mode 100644 index 000000000..f9cbf6b7d --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-stderr.txt @@ -0,0 +1,17 @@ +^You have called ADD_LIBRARY for library TestObjectLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file +CMake Error at OBJECTwithOnlyObjectSources.cmake:[0-9]+ \(add_library\): + OBJECT library \"TestObjectLibWithoutSources\" contains: + + [^ +]*test(\.cpp)?\.o(bj)? + + but may contain only sources that compile, header files, and other files + that would not affect linking of a normal library. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at OBJECTwithOnlyObjectSources.cmake:[0-9]+ \(add_library\): + Only executables and non-OBJECT libraries may reference target objects. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources.cmake new file mode 100644 index 000000000..ff75a8cb4 --- /dev/null +++ b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestObjectLibWithoutSources OBJECT) +target_sources(TestObjectLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/RunCMakeTest.cmake b/Tests/RunCMake/add_library/RunCMakeTest.cmake new file mode 100644 index 000000000..0ba621606 --- /dev/null +++ b/Tests/RunCMake/add_library/RunCMakeTest.cmake @@ -0,0 +1,24 @@ +include(RunCMake) + +run_cmake(INTERFACEwithNoSources) +run_cmake(OBJECTwithNoSources) +run_cmake(STATICwithNoSources) +run_cmake(SHAREDwithNoSources) +run_cmake(MODULEwithNoSources) +run_cmake(UNKNOWNwithNoSources) + +run_cmake(INTERFACEwithOnlyObjectSources) +run_cmake(OBJECTwithOnlyObjectSources) +run_cmake(STATICwithOnlyObjectSources) +run_cmake(SHAREDwithOnlyObjectSources) +run_cmake(MODULEwithOnlyObjectSources) +run_cmake(UNKNOWNwithOnlyObjectSources) + +if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]") + run_cmake(INTERFACEwithNoSourcesButLinkObjects) + run_cmake(OBJECTwithNoSourcesButLinkObjects) + run_cmake(STATICwithNoSourcesButLinkObjects) + run_cmake(SHAREDwithNoSourcesButLinkObjects) + run_cmake(MODULEwithNoSourcesButLinkObjects) + run_cmake(UNKNOWNwithNoSourcesButLinkObjects) +endif() diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSources-result.txt b/Tests/RunCMake/add_library/SHAREDwithNoSources-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/SHAREDwithNoSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt b/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt new file mode 100644 index 000000000..228d1cc95 --- /dev/null +++ b/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt @@ -0,0 +1,3 @@ +^You have called ADD_LIBRARY for library TestSharedLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file( +CMake Error: CMake can not determine linker language for target: TestSharedLibWithoutSources)+( +CMake Error: Cannot determine link language for target \"TestSharedLibWithoutSources\".)*$ diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSources.cmake b/Tests/RunCMake/add_library/SHAREDwithNoSources.cmake new file mode 100644 index 000000000..e147b44bc --- /dev/null +++ b/Tests/RunCMake/add_library/SHAREDwithNoSources.cmake @@ -0,0 +1 @@ +add_library(TestSharedLibWithoutSources SHARED) diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt new file mode 100644 index 000000000..228d1cc95 --- /dev/null +++ b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt @@ -0,0 +1,3 @@ +^You have called ADD_LIBRARY for library TestSharedLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file( +CMake Error: CMake can not determine linker language for target: TestSharedLibWithoutSources)+( +CMake Error: Cannot determine link language for target \"TestSharedLibWithoutSources\".)*$ diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects.cmake new file mode 100644 index 000000000..5e3c2709d --- /dev/null +++ b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestSharedLibWithoutSources SHARED) +target_link_libraries(TestSharedLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources-stderr.txt b/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources-stderr.txt new file mode 100644 index 000000000..ec350cd44 --- /dev/null +++ b/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources-stderr.txt @@ -0,0 +1 @@ +^You have called ADD_LIBRARY for library TestSharedLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$ diff --git a/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources.cmake new file mode 100644 index 000000000..09281b00d --- /dev/null +++ b/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestSharedLibWithoutSources SHARED) +target_sources(TestSharedLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/STATICwithNoSources-result.txt b/Tests/RunCMake/add_library/STATICwithNoSources-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/STATICwithNoSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt b/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt new file mode 100644 index 000000000..830eb221f --- /dev/null +++ b/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt @@ -0,0 +1,3 @@ +^You have called ADD_LIBRARY for library TestStaticLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file( +CMake Error: Cannot determine link language for target \"TestStaticLibWithoutSources\".)?( +CMake Error: CMake can not determine linker language for target: TestStaticLibWithoutSources)+$ diff --git a/Tests/RunCMake/add_library/STATICwithNoSources.cmake b/Tests/RunCMake/add_library/STATICwithNoSources.cmake new file mode 100644 index 000000000..94a2d9ab0 --- /dev/null +++ b/Tests/RunCMake/add_library/STATICwithNoSources.cmake @@ -0,0 +1 @@ +add_library(TestStaticLibWithoutSources STATIC) diff --git a/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt new file mode 100644 index 000000000..830eb221f --- /dev/null +++ b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt @@ -0,0 +1,3 @@ +^You have called ADD_LIBRARY for library TestStaticLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file( +CMake Error: Cannot determine link language for target \"TestStaticLibWithoutSources\".)?( +CMake Error: CMake can not determine linker language for target: TestStaticLibWithoutSources)+$ diff --git a/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects.cmake new file mode 100644 index 000000000..b6e137f3a --- /dev/null +++ b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestStaticLibWithoutSources STATIC) +target_link_libraries(TestStaticLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/STATICwithOnlyObjectSources-stderr.txt b/Tests/RunCMake/add_library/STATICwithOnlyObjectSources-stderr.txt new file mode 100644 index 000000000..5cd10d4fc --- /dev/null +++ b/Tests/RunCMake/add_library/STATICwithOnlyObjectSources-stderr.txt @@ -0,0 +1 @@ +^You have called ADD_LIBRARY for library TestStaticLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$ diff --git a/Tests/RunCMake/add_library/STATICwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/STATICwithOnlyObjectSources.cmake new file mode 100644 index 000000000..74a8947f2 --- /dev/null +++ b/Tests/RunCMake/add_library/STATICwithOnlyObjectSources.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestStaticLibWithoutSources STATIC) +target_sources(TestStaticLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake b/Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake new file mode 100644 index 000000000..dc5d7773b --- /dev/null +++ b/Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake @@ -0,0 +1 @@ +add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED) diff --git a/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects-stderr.txt new file mode 100644 index 000000000..adcd3a29e --- /dev/null +++ b/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at UNKNOWNwithNoSourcesButLinkObjects.cmake:[0-9]+ \(target_link_libraries\): + Cannot specify link libraries for target \"TestUnknownLibWithoutSources\" + which is not built by this project. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects.cmake new file mode 100644 index 000000000..8e014c2b2 --- /dev/null +++ b/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED) +target_link_libraries(TestUnknownLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-result.txt b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt new file mode 100644 index 000000000..e332281d2 --- /dev/null +++ b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at UNKNOWNwithOnlyObjectSources.cmake:[0-9]+ \(target_sources\): + target_sources called with non-compilable target type +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources.cmake new file mode 100644 index 000000000..604e339aa --- /dev/null +++ b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(ObjectLibDependency OBJECT test.cpp) + +add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED) +target_sources(TestUnknownLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>) diff --git a/Tests/RunCMake/add_library/test.cpp b/Tests/RunCMake/add_library/test.cpp new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/add_library/test.cpp diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in b/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in new file mode 100644 index 000000000..30dd37e8e --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.9) +@CASE_CMAKELISTS_PREFIX_CODE@ +project(CTestLabelsForSubprojects@CASE_NAME@ NONE) +include(CTest) +@CASE_CMAKELISTS_SUFFIX_CODE@ diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in new file mode 100644 index 000000000..1e1905b1b --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in @@ -0,0 +1,2 @@ +set(CTEST_PROJECT_NAME "CTestLabelsForSubprojects@CASE_NAME@") +@CTEST_EXTRA_CONFIG@ diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake new file mode 100644 index 000000000..ea0585113 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake @@ -0,0 +1,36 @@ +set(EXPERIMENTAL_FEATURE_REGEX "<Subproject name=\"MyExperimentalFeature\">.*<Label>MyExperimentalFeature</Label>.*</Subproject>") +set(PRODUCTION_CODE_REGEX "<Subproject name=\"MyProductionCode\">.*<Label>MyProductionCode</Label>.*</Subproject>") +set(SUBPROJECTS_REGEX "${EXPERIMENTAL_FEATURE_REGEX}.*${PRODUCTION_CODE_REGEX}") + +file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml") +if(configure_xml_file) + file(READ "${configure_xml_file}" configure_xml) + if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>") + set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects") + endif() +else() + set(RunCMake_TEST_FAILED "Configure.xml not found") +endif() + +file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml") +if(build_xml_file) + file(READ "${build_xml_file}" build_xml) + set(BUILD_WARNING_REGEX "<Failure type=\"Warning\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*</Labels>") + if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>") + set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "Build.xml not found") +endif() + +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml) + set(TEST_FAILED_REGEX "<Test Status=\"failed\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*<Label>NotASubproject</Label>.*</Labels>") + set(TEST_PASSED_REGEX "<Test Status=\"passed\">.*<Labels>.*<Label>MyProductionCode</Label>.*</Labels>") + if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>") + set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt new file mode 100644 index 000000000..05b484daa --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt @@ -0,0 +1,10 @@ +17% tests passed, 5 tests failed out of 6 ++ +Subproject Time Summary: +MyExperimentalFeature += +[0-9.]+ sec\*proc \(5 tests\) +MyProductionCode += +[0-9.]+ sec\*proc \(1 test\) ++ +Label Time Summary: +NotASubproject += +[0-9.]+ sec\*proc \(6 tests\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake new file mode 100644 index 000000000..ea0585113 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake @@ -0,0 +1,36 @@ +set(EXPERIMENTAL_FEATURE_REGEX "<Subproject name=\"MyExperimentalFeature\">.*<Label>MyExperimentalFeature</Label>.*</Subproject>") +set(PRODUCTION_CODE_REGEX "<Subproject name=\"MyProductionCode\">.*<Label>MyProductionCode</Label>.*</Subproject>") +set(SUBPROJECTS_REGEX "${EXPERIMENTAL_FEATURE_REGEX}.*${PRODUCTION_CODE_REGEX}") + +file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml") +if(configure_xml_file) + file(READ "${configure_xml_file}" configure_xml) + if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>") + set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects") + endif() +else() + set(RunCMake_TEST_FAILED "Configure.xml not found") +endif() + +file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml") +if(build_xml_file) + file(READ "${build_xml_file}" build_xml) + set(BUILD_WARNING_REGEX "<Failure type=\"Warning\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*</Labels>") + if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>") + set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "Build.xml not found") +endif() + +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml) + set(TEST_FAILED_REGEX "<Test Status=\"failed\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*<Label>NotASubproject</Label>.*</Labels>") + set(TEST_PASSED_REGEX "<Test Status=\"passed\">.*<Labels>.*<Label>MyProductionCode</Label>.*</Labels>") + if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>") + set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt new file mode 100644 index 000000000..05b484daa --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt @@ -0,0 +1,10 @@ +17% tests passed, 5 tests failed out of 6 ++ +Subproject Time Summary: +MyExperimentalFeature += +[0-9.]+ sec\*proc \(5 tests\) +MyProductionCode += +[0-9.]+ sec\*proc \(1 test\) ++ +Label Time Summary: +NotASubproject += +[0-9.]+ sec\*proc \(6 tests\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake new file mode 100644 index 000000000..7beefba2f --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake @@ -0,0 +1,34 @@ +set(THIRD_PARTY_REGEX "<Subproject name=\"MyThirdPartyDependency\">.*<Label>MyThirdPartyDependency</Label>.*</Subproject>") +set(SUBPROJECTS_REGEX "${THIRD_PARTY_REGEX}") + +file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml") +if(configure_xml_file) + file(READ "${configure_xml_file}" configure_xml) + if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>") + set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects") + endif() +else() + set(RunCMake_TEST_FAILED "Configure.xml not found") +endif() + +file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml") +if(build_xml_file) + file(READ "${build_xml_file}" build_xml) + set(BUILD_ERROR_REGEX "<Failure type=\"Error\">.*<Labels>.*<Label>MyThirdPartyDependency</Label>.*<Label>NotASubproject</Label>.*</Labels>") + if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>") + set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "Build.xml not found") +endif() + +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml) + set(TEST_NOTRUN_REGEX "<Test Status=\"notrun\">.*<Labels>.*<Label>MyThirdPartyDependency</Label>.*<Label>NotASubproject</Label>.*</Labels>") + if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>") + set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt new file mode 100644 index 000000000..b57e2deb7 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt new file mode 100644 index 000000000..38566fb2a --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt @@ -0,0 +1 @@ +Unable to find executable:.*MyThirdPartyDependency/src/thirdparty diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt new file mode 100644 index 000000000..c2c1bc7a0 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt @@ -0,0 +1,9 @@ +0% tests passed, 1 tests failed out of 1 ++ +Subproject Time Summary: +MyThirdPartyDependency += +[0-9.]+ sec\*proc \(1 test\) ++ +Label Time Summary: +NotASubproject += +[0-9.]+ sec\*proc \(1 test\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt new file mode 100644 index 000000000..ba4235def --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt new file mode 100644 index 000000000..3567a92b8 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt @@ -0,0 +1,6 @@ +50% tests passed, 1 tests failed out of 2 ++ +Subproject Time Summary: +MySubproject += +[0-9.]+ sec\*proc \(2 tests\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt new file mode 100644 index 000000000..ba4235def --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt new file mode 100644 index 000000000..3a7102247 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt @@ -0,0 +1,9 @@ +67% tests passed, 1 tests failed out of 3 ++ +Subproject Time Summary: +MySubproject += +[0-9.]+ sec\*proc \(2 tests\) ++ +Label Time Summary: +NotASubproject += +[0-9.]+ sec\*proc \(1 test\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt new file mode 100644 index 000000000..ba4235def --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt new file mode 100644 index 000000000..1146bfe39 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt @@ -0,0 +1,6 @@ +67% tests passed, 1 tests failed out of 3 ++ +Label Time Summary: +NotASubproject += +[0-9.]+ sec\*proc \(1 test\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt new file mode 100644 index 000000000..ba4235def --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt new file mode 100644 index 000000000..3567a92b8 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt @@ -0,0 +1,6 @@ +50% tests passed, 1 tests failed out of 2 ++ +Subproject Time Summary: +MySubproject += +[0-9.]+ sec\*proc \(2 tests\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt new file mode 100644 index 000000000..cc07a07f7 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt @@ -0,0 +1,33 @@ +project(MyExperimentalFeature) +cmake_minimum_required(VERSION 3.8) + +include(CTest) + +set(CMAKE_DIRECTORY_LABELS "MyExperimentalFeature;NotASubproject") + +add_executable(testapp experimental.c) + +add_test(experimentalFail1 testapp 5) +set_tests_properties (experimentalFail1 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) + +add_test(experimentalFail2 testapp -5) +set_tests_properties (experimentalFail2 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) + +add_test(experimentalFail3 testapp -5) +set_tests_properties (experimentalFail3 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) + +add_test(experimentalFail4 testapp -5) +set_tests_properties (experimentalFail4 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) + +add_test(experimentalFail5 testapp -5) +set_tests_properties (experimentalFail5 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c new file mode 100644 index 000000000..7cb11ae50 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +int main(void) +{ + int i = 0; + if (i > 0) { + printf("This doesn't happen.\n"); + printf("Neither does this.\n"); + } + i = i + 1; + if (i > 0) { + printf("This does happen.\n"); + } + + return 0; +} diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt new file mode 100644 index 000000000..c2ee673ab --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt @@ -0,0 +1,12 @@ +project(MyProductionCode) +cmake_minimum_required(VERSION 3.8) + +include(CTest) + +add_executable(production production.c) +add_test(NAME production COMMAND production) + +set_property(TARGET production PROPERTY LABELS MyProductionCode) +set_property(TEST production PROPERTY LABELS MyProductionCode) + +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY LABELS "NotASubproject") diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c new file mode 100644 index 000000000..54dc2bec0 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +int main(void) +{ + int j = 0; + if (j > 0) { + printf("This doesn't happen.\n"); + printf("Neither does this.\n"); + } + j = j + 1; + if (j > 0) { + printf("This does happen.\n"); + } + + return 0; +} diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt new file mode 100644 index 000000000..d5b9c2f22 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt @@ -0,0 +1,7 @@ +project(MyThirdPartyDependency) +cmake_minimum_required(VERSION 3.8) + +include(CTest) + +set_directory_properties(PROPERTIES LABELS "NotASubproject;MyThirdPartyDependency") +add_subdirectory(src) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt new file mode 100644 index 000000000..dc6cb2a57 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt @@ -0,0 +1,10 @@ +project(MyThirdPartyDependency) +cmake_minimum_required(VERSION 3.8) + +include(CTest) + +add_executable(thirdparty thirdparty.c) +add_test(NAME thirdparty COMMAND thirdparty) + +set_property(TARGET thirdparty PROPERTY LABELS NotASubproject) +set_property(TEST thirdparty PROPERTY LABELS NotASubproject) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c new file mode 100644 index 000000000..babe82d2d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +int main(void) +{ + printf(This function has an error!\n"); + n = 5; + return 0; +} + +int notcalled() +{ + printf(This function doesn't get called.\n"); + return 0; +} diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake new file mode 100644 index 000000000..dbe7bf826 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake @@ -0,0 +1,185 @@ +include(RunCTest) + + +# 1. Specify subprojects in the CTest script +function(run_CTestScriptVariable) + set(CTEST_EXTRA_CONFIG "set(CTEST_USE_LAUNCHERS 1)") + set(CASE_TEST_PREFIX_CODE [[ +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyProductionCode" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyExperimentalFeature" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) + +set(CTEST_LABELS_FOR_SUBPROJECTS "MyProductionCode;MyExperimentalFeature") + ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_subdirectory(MyExperimentalFeature) +add_subdirectory(MyProductionCode) + ]]) + + run_ctest(CTestScriptVariable) + + unset(CTEST_EXTRA_CONFIG) + unset(CASE_TEST_PREFIX_CODE) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_CTestScriptVariable() + +# 2. Specify subprojects via a CTest script variable on the command line e.g. +# ctest -S test.cmake -DCTEST_LABELS_FOR_SUBPROJECTS:STRING="MySubproject" +# Note: This test includes a failing build +function(run_CTestScriptVariableCommandLine) + set(CTEST_EXTRA_CONFIG "set(CTEST_USE_LAUNCHERS 1)") + set(CASE_TEST_PREFIX_CODE [[ +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyThirdPartyDependency" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) + ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_subdirectory(MyThirdPartyDependency) + ]]) + + run_ctest(CTestScriptVariableCommandLine "-DCTEST_LABELS_FOR_SUBPROJECTS:STRING=MyThirdPartyDependency") + + unset(CTEST_EXTRA_CONFIG) + unset(CASE_TEST_PREFIX_CODE) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_CTestScriptVariableCommandLine() + +# 3. Set subprojects via a CTest module variable on the command line +# (will populate DartConfiguration.tcl) +function(run_ModuleVariableCommandLine) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCommandLine") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCommandLine-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake") +add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject) +add_test(NAME FailingTest + COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx") +set_property(TEST FailingTest PROPERTY LABELS MySubproject) + ]]) + configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in + ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY) + + set(RunCMake_TEST_OPTIONS "-DCTEST_LABELS_FOR_SUBPROJECTS:STRING=MySubproject") + run_cmake(ModuleVariableCommandLine-cmake) + unset(RunCMake_TEST_OPTIONS) + run_cmake_command(ModuleVariableCommandLine ${CMAKE_CTEST_COMMAND} -C Debug -V) + + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_ModuleVariableCommandLine() + +# 4. Set subprojects via a CTest module variable in CMakeLists.txt +# (will populate DartConfiguration.tcl) +function(run_ModuleVariableCMakeLists) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCMakeLists") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCMakeLists-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(CASE_CMAKELISTS_PREFIX_CODE [[ +set(CTEST_LABELS_FOR_SUBPROJECTS MySubproject) +]]) + + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake") +add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject) +add_test(NAME FailingTest + COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx") +set_property(TEST FailingTest PROPERTY LABELS MySubproject) + ]]) + configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in + ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY) + + run_cmake(ModuleVariableCMakeLists-cmake) + run_cmake_command(ModuleVariableCMakeLists ${CMAKE_CTEST_COMMAND} -C Debug -V) + + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(CASE_CMAKELISTS_SUFFIX_CODE) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_ModuleVariableCMakeLists() + +# The remaining tests set subprojects in CTestConfig.cmake. Settings in this +# config file are shared by both the CTest module and the ctest command line +# `Dashboard Client` mode (e.g. ctest -S). + +function(run_ModuleVariableCTestConfig CASE_NAME) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${CASE_NAME}") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${CASE_NAME}-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(CTEST_EXTRA_CONFIG "set(CTEST_LABELS_FOR_SUBPROJECTS \"MySubproject\")") + configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in + ${RunCMake_TEST_SOURCE_DIR}/CTestConfig.cmake @ONLY) + + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake") +add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject) +add_test(NAME FailingTest + COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx") +set_property(TEST FailingTest PROPERTY LABELS MySubproject) +add_test(NAME AnotherSuccessfulTest COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST AnotherSuccessfulTest PROPERTY LABELS NotASubproject) + ]]) + configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in + ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY) + + run_cmake(${CASE_NAME}-cmake) + run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND} -C Debug -V ${ARGN}) + + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(CTEST_EXTRA_CONFIG) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() + +# 5. Check that the Subproject timing Summary is printed +run_ModuleVariableCTestConfig(ModuleVariableCTestConfig) + +# 6. Use --no-subproject-summary to disable the Subproject timing summary. +run_ModuleVariableCTestConfig(ModuleVariableCTestConfigNoSummary --no-subproject-summary) + +# 7. Verify that subprojects are sent to CDash when running a CTest script +function(run_CTestConfigCTestScript) + set(CTEST_EXTRA_CONFIG [[ +set(CTEST_USE_LAUNCHERS 1) +set(CTEST_LABELS_FOR_SUBPROJECTS "MyProductionCode;MyExperimentalFeature") + ]]) + set(CASE_TEST_PREFIX_CODE [[ +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyProductionCode" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyExperimentalFeature" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) + ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_subdirectory(MyExperimentalFeature) +add_subdirectory(MyProductionCode) + ]]) + run_ctest(CTestConfigCTestScript) + + unset(CTEST_EXTRA_CONFIG) + unset(CASE_TEST_PREFIX_CODE) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_CTestConfigCTestScript() diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in b/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in new file mode 100644 index 000000000..8cec08d46 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.7) + +# Settings: + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_RUNCMAKE_SOURCE_DIRECTORY "@RunCMake_SOURCE_DIR@") + +@CASE_TEST_PREFIX_CODE@ + +set(ctest_test_args "@CASE_CTEST_TEST_ARGS@") +ctest_start(Experimental) +ctest_configure() +ctest_build() +ctest_test(${ctest_test_args}) diff --git a/Tests/RunCMake/ctest_skipped_test/skip.bat b/Tests/RunCMake/ctest_skipped_test/skip.bat index 80e1290df..580f46018 100755 --- a/Tests/RunCMake/ctest_skipped_test/skip.bat +++ b/Tests/RunCMake/ctest_skipped_test/skip.bat @@ -1 +1 @@ -EXIT 125 +EXIT 125
diff --git a/Tests/RunCMake/execute_process/ExitValues-stdout.txt b/Tests/RunCMake/execute_process/ExitValues-stdout.txt new file mode 100644 index 000000000..3bcaf46cc --- /dev/null +++ b/Tests/RunCMake/execute_process/ExitValues-stdout.txt @@ -0,0 +1,14 @@ +^-- 1 - 1 RESULT_VARIABLE: 0 +-- 1 - 2 RESULT_VARIABLE: [^0].* +-- 2 - 1 RESULT_VARIABLE: 0 +-- 2 - 1 RESULTS_VARIABLE: 0 +-- 2 - 2 RESULT_VARIABLE: [^0].* +-- 2 - 2 RESULTS_VARIABLE: [^0].* +-- 3 - 1 RESULTS_VARIABLE: 0 +-- 3 - 2 RESULTS_VARIABLE: [^0].* +-- 4 - 1 RESULT_VARIABLE: 0 +-- 4 - 1 RESULTS_VARIABLE: [^0].*;0;[^0].*;0;[^0].*;0 +-- 4 - 1 RESULTS_VARIABLE_LENGTH: 6 +-- 5 - 1 RESULT_VARIABLE: [^0].* +-- 5 - 1 RESULTS_VARIABLE: 0;0;[^0].* +-- 5 - 1 RESULTS_VARIABLE_LENGTH: 3$ diff --git a/Tests/RunCMake/execute_process/ExitValues.cmake b/Tests/RunCMake/execute_process/ExitValues.cmake new file mode 100644 index 000000000..d80a57b2d --- /dev/null +++ b/Tests/RunCMake/execute_process/ExitValues.cmake @@ -0,0 +1,120 @@ +#1st TEST RESULT_VARIABLE ONLY +execute_process(COMMAND ${EXIT_CODE_EXE} "zero_exit" + RESULT_VARIABLE r0 + ) +message(STATUS " 1 - 1 RESULT_VARIABLE: ${r0}") +if(NOT r0 EQUAL 0) + message(FATAL_ERROR "zero exit code expected") +endif() +execute_process(COMMAND ${EXIT_CODE_EXE} "non_zero_exit" + RESULT_VARIABLE r01 + ERROR_QUIET + ) +message(STATUS " 1 - 2 RESULT_VARIABLE: ${r01}") +if(r01 EQUAL 0) + message(FATAL_ERROR "non-zero exit code expected") +endif() +#2nd TEST RESULT_VARIABLE and RESULTS_VARIABLE +execute_process(COMMAND ${EXIT_CODE_EXE} "zero_exit" + RESULT_VARIABLE r1 + RESULTS_VARIABLE r1s + ) +message(STATUS " 2 - 1 RESULT_VARIABLE: ${r1}") +message(STATUS " 2 - 1 RESULTS_VARIABLE: ${r1s}") +if(NOT r1 EQUAL 0 OR NOT r1s EQUAL 0) + message(FATAL_ERROR "zero exit code expected") +endif() +execute_process(COMMAND ${EXIT_CODE_EXE} "non_zero_exit" + RESULT_VARIABLE r11 + RESULTS_VARIABLE r11s + ERROR_QUIET + ) +message(STATUS " 2 - 2 RESULT_VARIABLE: ${r11}") +message(STATUS " 2 - 2 RESULTS_VARIABLE: ${r11s}") +if(r11 EQUAL 0 OR r11s EQUAL 0) + message(FATAL_ERROR "non-zero exit code expected") +endif() +#3rd TEST RESULTS_VARIABLE +execute_process(COMMAND ${EXIT_CODE_EXE} "zero_exit" + RESULTS_VARIABLE r2s + ) +message(STATUS " 3 - 1 RESULTS_VARIABLE: ${r2s}") +if(NOT r2s EQUAL 0) + message(FATAL_ERROR "zero exit code expected") +endif() +execute_process(COMMAND ${EXIT_CODE_EXE} "non_zero_exit" + RESULTS_VARIABLE r21s + ERROR_QUIET + ) +message(STATUS " 3 - 2 RESULTS_VARIABLE: ${r21s}") +if(r21s EQUAL 0) + message(FATAL_ERROR "non-zero exit code expected") +endif() +#4th TEST RESULT_VARIABLE and RESULTS_VARIABLE WITH MULTICOMMAND +execute_process(COMMAND ${EXIT_CODE_EXE} "non_zero_exit" + COMMAND ${EXIT_CODE_EXE} "zero_exit" + COMMAND ${EXIT_CODE_EXE} "non_zero_exit" + COMMAND ${EXIT_CODE_EXE} "zero_exit" + COMMAND ${EXIT_CODE_EXE} "non_zero_exit" + COMMAND ${EXIT_CODE_EXE} "zero_exit" + RESULT_VARIABLE r31 + RESULTS_VARIABLE r31s + OUTPUT_QUIET + ERROR_QUIET + ) +message(STATUS " 4 - 1 RESULT_VARIABLE: ${r31}") +message(STATUS " 4 - 1 RESULTS_VARIABLE: ${r31s}") +if(NOT r31 EQUAL 0) + message(FATAL_ERROR "zero exit code expected for last command") +endif() +list(LENGTH r31s r31sLen) +message(STATUS " 4 - 1 RESULTS_VARIABLE_LENGTH: ${r31sLen}") +if(NOT r31sLen EQUAL 6) + message(FATAL_ERROR "length of RESULTS_VARIABLE is not as expected") +else() + foreach(loop_var RANGE 5) + list(GET r31s ${loop_var} rsLocal) + math(EXPR isOdd "${loop_var} % 2") + if(isOdd) + if(NOT rsLocal EQUAL 0) + message(FATAL_ERROR "zero exit code expected") + endif() + else() + if(rsLocal EQUAL 0) + message(FATAL_ERROR "non-zero exit code expected") + endif() + endif() + endforeach() +endif() +#5th TEST RESULT_VARIABLE and RESULTS_VARIABLE WITH MULTICOMMAND +execute_process(COMMAND ${EXIT_CODE_EXE} "zero_exit" + COMMAND ${EXIT_CODE_EXE} "zero_exit" + COMMAND ${EXIT_CODE_EXE} "non_zero_exit" + RESULT_VARIABLE r41 + RESULTS_VARIABLE r41s + OUTPUT_QUIET + ERROR_QUIET + ) +message(STATUS " 5 - 1 RESULT_VARIABLE: ${r41}") +message(STATUS " 5 - 1 RESULTS_VARIABLE: ${r41s}") +if(r41 EQUAL 0) + message(FATAL_ERROR "non-zero exit code expected for last command") +endif() +list(LENGTH r41s r41sLen) +message(STATUS " 5 - 1 RESULTS_VARIABLE_LENGTH: ${r41sLen}") +if(NOT r31sLen EQUAL 6) + message(FATAL_ERROR "length of RESULTS_VARIABLE is not as expected") +else() + list(GET r41s 0 rsLocal) + if(NOT rsLocal EQUAL 0) + message(FATAL_ERROR "zero exit code expected") + endif() + list(GET r41s 1 rsLocal) + if(NOT rsLocal EQUAL 0) + message(FATAL_ERROR "zero exit code expected") + endif() + list(GET r41s 2 rsLocal) + if(rsLocal EQUAL 0) + message(FATAL_ERROR "non-zero exit code expected") + endif() +endif() diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index 62e18c601..83589bbd0 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -11,3 +11,7 @@ run_cmake(EncodingMissing) if(TEST_ENCODING_EXE) run_cmake_command(EncodingUTF8 ${CMAKE_COMMAND} -DTEST_ENCODING=UTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE} -P ${RunCMake_SOURCE_DIR}/Encoding.cmake) endif() + +if(EXIT_CODE_EXE) + run_cmake_command(ExitValues ${CMAKE_COMMAND} -DEXIT_CODE_EXE=${EXIT_CODE_EXE} -P ${RunCMake_SOURCE_DIR}/ExitValues.cmake) +endif() diff --git a/Tests/RunCMake/exit_code.c b/Tests/RunCMake/exit_code.c new file mode 100644 index 000000000..3eba01941 --- /dev/null +++ b/Tests/RunCMake/exit_code.c @@ -0,0 +1,30 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +// Usage: +// +// /path/to/program arg1 [arg2 [...]] +// +// Return EXIT_SUCCESS if 'zero_exit' +// string was found in <arg1>. +// Return EXIT_FAILURE if 'non_zero_exit' +// string was found in <arg1>. + +int main(int argc, const char* argv[]) +{ + const char* substring_failure = "non_zero_exit"; + const char* substring_success = "zero_exit"; + const char* str = argv[1]; + if (argc < 2) { + return EXIT_FAILURE; + } + if (strcmp(str, substring_success) == 0) { + return EXIT_SUCCESS; + } else if (strcmp(str, substring_failure) == 0) { + return EXIT_FAILURE; + } + fprintf(stderr, "Failed to find string '%s' in '%s'\n", substring_success, + str); + return EXIT_FAILURE; +} diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 7dfb55d79..ac77ac3de 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -80,6 +80,17 @@ get_filename_component(test_program_name "/ arg1 arg2" PROGRAM check("PROGRAM with args output: name" "${test_program_name}" "/") check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2") +get_filename_component(test_program_name " " PROGRAM) +check("PROGRAM with just a space" "${test_program_name}" "") + +get_filename_component(test_program_name "${CMAKE_CURRENT_LIST_FILE}" PROGRAM) +check("PROGRAM specified explicitly without quoting" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}") + +get_filename_component(test_program_name "\"${CMAKE_CURRENT_LIST_FILE}\" arg1 arg2" PROGRAM + PROGRAM_ARGS test_program_args) +check("PROGRAM specified explicitly with arguments: name" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}") +check("PROGRAM specified explicitly with arguments: args" "${test_program_args}" " arg1 arg2") + list(APPEND non_cache_vars test_program_name) list(APPEND non_cache_vars test_program_args) diff --git a/Tests/RunCMake/get_property/source_properties-stderr.txt b/Tests/RunCMake/get_property/source_properties-stderr.txt index 0a46f96a0..00a9b8287 100644 --- a/Tests/RunCMake/get_property/source_properties-stderr.txt +++ b/Tests/RunCMake/get_property/source_properties-stderr.txt @@ -3,4 +3,10 @@ get_property: --><-- get_source_file_property: -->value<-- get_property: -->value<-- get_source_file_property: -->NOTFOUND<-- -get_property: --><--$ +get_property: --><-- +get_source_file_property: -->value<-- +get_property: -->value<-- +get_source_file_property: -->NOTFOUND<-- +get_property: --><-- +get_source_file_property: -->value<-- +get_property: -->value<--$ diff --git a/Tests/RunCMake/get_property/source_properties.cmake b/Tests/RunCMake/get_property/source_properties.cmake index 263ffe123..12d2d0797 100644 --- a/Tests/RunCMake/get_property/source_properties.cmake +++ b/Tests/RunCMake/get_property/source_properties.cmake @@ -13,3 +13,13 @@ set_source_files_properties(file.c PROPERTIES empty "" custom value) check_source_file_property(file.c empty) check_source_file_property(file.c custom) check_source_file_property(file.c noexist) + +# Test strange legacy behavior in which the order in which source files are +# first accessed affects how properties are applied without an extension. +# See also issue #15208. +get_property(lang SOURCE ${CMAKE_CURRENT_BINARY_DIR}/file2.c PROPERTY LANGUAGE) +get_property(lang SOURCE ${CMAKE_CURRENT_BINARY_DIR}/file2.h PROPERTY LANGUAGE) +set_property(SOURCE file2 PROPERTY custom value) # set property without extension +check_source_file_property(file2 custom) # should have property +check_source_file_property(file2.h custom) # should not have property +check_source_file_property(file2.c custom) # should have property diff --git a/Tests/RunCMake/include_guard/CMakeLists.txt b/Tests/RunCMake/include_guard/CMakeLists.txt new file mode 100644 index 000000000..d3137f614 --- /dev/null +++ b/Tests/RunCMake/include_guard/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.9) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_guard/DirectoryScope.cmake b/Tests/RunCMake/include_guard/DirectoryScope.cmake new file mode 100644 index 000000000..d6c5a3ce2 --- /dev/null +++ b/Tests/RunCMake/include_guard/DirectoryScope.cmake @@ -0,0 +1,19 @@ +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts") + +# Test include_guard with DIRECTORY scope + +# Add subdirectory which includes DirScript three times: +# 1. Include at inner function scope +# 2. At directory scope +# 3. At another subdirectory to check that the guard is checked +# against parent directories +add_subdirectory(sub_dir_script1) +# Add another directory which includes DirScript +add_subdirectory(sub_dir_script2) + +# check inclusions count +get_property(dir_count GLOBAL PROPERTY DIR_SCRIPT_COUNT) +if(NOT dir_count EQUAL 2) + message(FATAL_ERROR + "Wrong DIR_SCRIPT_COUNT value: ${dir_count}, expected: 2") +endif() diff --git a/Tests/RunCMake/include_guard/GlobalScope.cmake b/Tests/RunCMake/include_guard/GlobalScope.cmake new file mode 100644 index 000000000..02137fa77 --- /dev/null +++ b/Tests/RunCMake/include_guard/GlobalScope.cmake @@ -0,0 +1,11 @@ +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts") + +# Test GLOBAL include guard +add_subdirectory(global_script_dir) +include(GlobScript) + +get_property(glob_count GLOBAL PROPERTY GLOB_SCRIPT_COUNT) +if(NOT glob_count EQUAL 1) + message(FATAL_ERROR + "Wrong GLOB_SCRIPT_COUNT value: ${glob_count}, expected: 1") +endif() diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt new file mode 100644 index 000000000..cdd33ac0d --- /dev/null +++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at InvalidArgumentsNumber.cmake:1 \(include_guard\): + include_guard given an invalid number of arguments. The command takes at + most 1 argument. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake b/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake new file mode 100644 index 000000000..a63a395c0 --- /dev/null +++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake @@ -0,0 +1 @@ +include_guard(ARG1 ARG2) diff --git a/Tests/RunCMake/include_guard/InvalidScope-result.txt b/Tests/RunCMake/include_guard/InvalidScope-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/include_guard/InvalidScope-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_guard/InvalidScope-stderr.txt b/Tests/RunCMake/include_guard/InvalidScope-stderr.txt new file mode 100644 index 000000000..456709da7 --- /dev/null +++ b/Tests/RunCMake/include_guard/InvalidScope-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at InvalidScope.cmake:1 \(include_guard\): + include_guard given an invalid scope: INVALID +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_guard/InvalidScope.cmake b/Tests/RunCMake/include_guard/InvalidScope.cmake new file mode 100644 index 000000000..f69f9fd64 --- /dev/null +++ b/Tests/RunCMake/include_guard/InvalidScope.cmake @@ -0,0 +1 @@ +include_guard(INVALID) diff --git a/Tests/RunCMake/include_guard/RunCMakeTest.cmake b/Tests/RunCMake/include_guard/RunCMakeTest.cmake new file mode 100644 index 000000000..e87bddd87 --- /dev/null +++ b/Tests/RunCMake/include_guard/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +run_cmake(VariableScope) +run_cmake(DirectoryScope) +run_cmake(GlobalScope) +run_cmake(InvalidScope) +run_cmake(InvalidArgumentsNumber) diff --git a/Tests/RunCMake/include_guard/Scripts/DirScript.cmake b/Tests/RunCMake/include_guard/Scripts/DirScript.cmake new file mode 100644 index 000000000..e61d18051 --- /dev/null +++ b/Tests/RunCMake/include_guard/Scripts/DirScript.cmake @@ -0,0 +1,12 @@ +include_guard(DIRECTORY) + +set(prop_name DIR_SCRIPT_COUNT) +get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET) + +if(NOT count_is_set) + set_property(GLOBAL PROPERTY ${prop_name} 1) +else() + get_property(count GLOBAL PROPERTY ${prop_name}) + math(EXPR count "${count} + 1") + set_property(GLOBAL PROPERTY ${prop_name} ${count}) +endif() diff --git a/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake b/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake new file mode 100644 index 000000000..c26bf40e8 --- /dev/null +++ b/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake @@ -0,0 +1,12 @@ +include_guard(GLOBAL) + +set(prop_name GLOB_SCRIPT_COUNT) +get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET) + +if(NOT count_is_set) + set_property(GLOBAL PROPERTY ${prop_name} 1) +else() + get_property(count GLOBAL PROPERTY ${prop_name}) + math(EXPR count "${count} + 1") + set_property(GLOBAL PROPERTY ${prop_name} ${count}) +endif() diff --git a/Tests/RunCMake/include_guard/Scripts/VarScript.cmake b/Tests/RunCMake/include_guard/Scripts/VarScript.cmake new file mode 100644 index 000000000..3080377cb --- /dev/null +++ b/Tests/RunCMake/include_guard/Scripts/VarScript.cmake @@ -0,0 +1,12 @@ +include_guard() + +set(prop_name VAR_SCRIPT_COUNT) +get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET) + +if(NOT count_is_set) + set_property(GLOBAL PROPERTY ${prop_name} 1) +else() + get_property(count GLOBAL PROPERTY ${prop_name}) + math(EXPR count "${count} + 1") + set_property(GLOBAL PROPERTY ${prop_name} ${count}) +endif() diff --git a/Tests/RunCMake/include_guard/VariableScope.cmake b/Tests/RunCMake/include_guard/VariableScope.cmake new file mode 100644 index 000000000..7f8477db3 --- /dev/null +++ b/Tests/RunCMake/include_guard/VariableScope.cmake @@ -0,0 +1,24 @@ +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts") + +# Test include_guard with VARIABLE scope +function(var_include_func) + # Include twice in the same scope + include(VarScript) + include(VarScript) + get_property(var_count GLOBAL PROPERTY VAR_SCRIPT_COUNT) + if(NOT var_count EQUAL 1) + message(FATAL_ERROR + "Wrong VAR_SCRIPT_COUNT value: ${var_count}, expected: 1") + endif() +endfunction() + +var_include_func() + +# Check again that include_guard has been reset +include(VarScript) + +get_property(var_count GLOBAL PROPERTY VAR_SCRIPT_COUNT) +if(NOT var_count EQUAL 2) + message(FATAL_ERROR + "Wrong VAR_SCRIPT_COUNT value: ${var_count}, expected: 2") +endif() diff --git a/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt b/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt new file mode 100644 index 000000000..ee7ea2ecc --- /dev/null +++ b/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt @@ -0,0 +1 @@ +include(GlobScript) diff --git a/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt new file mode 100644 index 000000000..d3626e5fa --- /dev/null +++ b/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt @@ -0,0 +1,9 @@ +function(dir_check) + include(DirScript) +endfunction() + +dir_check() + +include(DirScript) + +add_subdirectory(sub_dir_script3) diff --git a/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt new file mode 100644 index 000000000..1c3b1b245 --- /dev/null +++ b/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt @@ -0,0 +1 @@ +include(DirScript) diff --git a/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt new file mode 100644 index 000000000..1c3b1b245 --- /dev/null +++ b/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt @@ -0,0 +1 @@ +include(DirScript) diff --git a/Tests/RunCMake/pseudo_cppcheck.c b/Tests/RunCMake/pseudo_cppcheck.c new file mode 100644 index 000000000..8667e5e4a --- /dev/null +++ b/Tests/RunCMake/pseudo_cppcheck.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(int argc, char* argv[]) +{ + int i; + for (i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-bad") == 0) + if (strcmp(argv[i], "-bad") == 0) { + fprintf(stdout, "stdout from bad command line arg '-bad'\n"); + fprintf(stderr, "stderr from bad command line arg '-bad'\n"); + return 1; + } + } + fprintf(stderr, + "[/foo/bar.c:2]: (error) Array 'abc[10]' accessed at index 12," + " which is out of bounds.\n"); + fprintf(stderr, "[/foo/bar.c:2]: (warning) Member variable 'foo::bar' is " + "not initialized in the constructor.\n"); + fprintf(stderr, "[/foo/bar.c:2]: (style) C-style pointer casting.\n"); + fprintf(stderr, "[/foo/bar.c:2]: (performance) Variable 'm_message' is " + "assigned in constructor body. Consider performing " + "initialization in initialization list.\n"); + fprintf(stderr, "[/foo/bar.c:2]: (portability) scanf without field width " + "limits can crash with huge input data on some versions of " + "libc\n"); + fprintf(stderr, "[/foo/bar.c:2]: (information) cannot find all the include " + "files (use --check-config for details)\n"); + // we allow this to return 1 as we ignore it + return 1; +} diff --git a/Tests/RunCMake/string/Prepend.cmake b/Tests/RunCMake/string/Prepend.cmake new file mode 100644 index 000000000..8eaeebb46 --- /dev/null +++ b/Tests/RunCMake/string/Prepend.cmake @@ -0,0 +1,58 @@ +set(out) +string(PREPEND out) +if(DEFINED out) + message(FATAL_ERROR "\"string(PREPEND out)\" set out to \"${out}\"") +endif() + +set(out "") +string(PREPEND out) +if(NOT out STREQUAL "") + message(FATAL_ERROR "\"string(PREPEND out)\" set out to \"${out}\"") +endif() + +set(out x) +string(PREPEND out) +if(NOT out STREQUAL "x") + message(FATAL_ERROR "\"string(PREPEND out)\" set out to \"${out}\"") +endif() + + +set(out) +string(PREPEND out a) +if(NOT out STREQUAL "a") + message(FATAL_ERROR "\"string(PREPEND out a)\" set out to \"${out}\"") +endif() + +set(out "") +string(PREPEND out a) +if(NOT out STREQUAL "a") + message(FATAL_ERROR "\"string(PREPEND out a)\" set out to \"${out}\"") +endif() + +set(out x) +string(PREPEND out a) +if(NOT out STREQUAL "ax") + message(FATAL_ERROR "\"string(PREPEND out a)\" set out to \"${out}\"") +endif() + + +set(out x) +string(PREPEND out a "b") +if(NOT out STREQUAL "abx") + message(FATAL_ERROR "\"string(PREPEND out a \"b\")\" set out to \"${out}\"") +endif() + +set(b) +set(out x) +string(PREPEND out ${b}) +if(NOT out STREQUAL "x") + message(FATAL_ERROR "\"string(PREPEND out \${b})\" set out to \"${out}\"") +endif() + +set(b b) +set(out x) +string(PREPEND out a "${b}" [[ +${c}]]) +if(NOT out STREQUAL "ab\${c}x") + message(FATAL_ERROR "\"string(PREPEND out a \"\${b}\" [[\${c}]])\" set out to \"${out}\"") +endif() diff --git a/Tests/RunCMake/string/PrependNoArgs-result.txt b/Tests/RunCMake/string/PrependNoArgs-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/string/PrependNoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/PrependNoArgs-stderr.txt b/Tests/RunCMake/string/PrependNoArgs-stderr.txt new file mode 100644 index 000000000..8d433f93a --- /dev/null +++ b/Tests/RunCMake/string/PrependNoArgs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at PrependNoArgs.cmake:1 \(string\): + string sub-command PREPEND requires at least one argument. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/string/PrependNoArgs.cmake b/Tests/RunCMake/string/PrependNoArgs.cmake new file mode 100644 index 000000000..f324f2854 --- /dev/null +++ b/Tests/RunCMake/string/PrependNoArgs.cmake @@ -0,0 +1 @@ +string(PREPEND) diff --git a/Tests/RunCMake/string/RegexMultiMatchClear-stderr.txt b/Tests/RunCMake/string/RegexMultiMatchClear-stderr.txt new file mode 100644 index 000000000..4360d79c1 --- /dev/null +++ b/Tests/RunCMake/string/RegexMultiMatchClear-stderr.txt @@ -0,0 +1,12 @@ +^matches: Some::;Scope +results from: string\(REGEX MATCHALL\) +CMAKE_MATCH_0: -->Scope<-- +CMAKE_MATCH_1: -->Scope<-- +CMAKE_MATCH_2: --><-- +CMAKE_MATCH_COUNT: -->1<-- +replace: \[Some\]\[Scope\] +results from: string\(REGEX REPLACE\) +CMAKE_MATCH_0: -->Scope<-- +CMAKE_MATCH_1: -->Scope<-- +CMAKE_MATCH_2: --><-- +CMAKE_MATCH_COUNT: -->1<--$ diff --git a/Tests/RunCMake/string/RegexMultiMatchClear.cmake b/Tests/RunCMake/string/RegexMultiMatchClear.cmake new file mode 100644 index 000000000..80b6b3c7b --- /dev/null +++ b/Tests/RunCMake/string/RegexMultiMatchClear.cmake @@ -0,0 +1,20 @@ +cmake_minimum_required (VERSION 3.0) +project (RegexClear NONE) + +function (output_results msg) + message("results from: ${msg}") + message("CMAKE_MATCH_0: -->${CMAKE_MATCH_0}<--") + message("CMAKE_MATCH_1: -->${CMAKE_MATCH_1}<--") + message("CMAKE_MATCH_2: -->${CMAKE_MATCH_2}<--") + message("CMAKE_MATCH_COUNT: -->${CMAKE_MATCH_COUNT}<--") +endfunction () + +set(haystack "Some::Scope") + +string(REGEX MATCHALL "^([^:]+)(::)?" matches "${haystack}") +message("matches: ${matches}") +output_results("string(REGEX MATCHALL)") + +string(REGEX REPLACE "^([^:]+)(::)?" "[\\1]" replace "${haystack}") +message("replace: ${replace}") +output_results("string(REGEX REPLACE)") diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index 38a77b0d1..513d1e3ae 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -3,6 +3,9 @@ include(RunCMake) run_cmake(Append) run_cmake(AppendNoArgs) +run_cmake(Prepend) +run_cmake(PrependNoArgs) + run_cmake(Concat) run_cmake(ConcatNoArgs) @@ -20,6 +23,7 @@ run_cmake(UuidMissingTypeValue) run_cmake(UuidBadType) run_cmake(RegexClear) +run_cmake(RegexMultiMatchClear) run_cmake(UTF-16BE) run_cmake(UTF-16LE) diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt index 653974c62..cd4dcb37e 100644 --- a/Tests/RunCMake/string/Timestamp-stderr.txt +++ b/Tests/RunCMake/string/Timestamp-stderr.txt @@ -1 +1 @@ -RESULT=2005-08-07 23:19:49 Sun Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789 +RESULT=2005-08-07 23:19:49 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789 diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake index d24203942..cba258d12 100644 --- a/Tests/RunCMake/string/Timestamp.cmake +++ b/Tests/RunCMake/string/Timestamp.cmake @@ -1,3 +1,3 @@ set(ENV{SOURCE_DATE_EPOCH} "1123456789") -string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %a %b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC) +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %A=%a %B=%b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC) message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 1466fbf61..b1c943505 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -10,3 +10,4 @@ run_cmake(SubDirTarget) run_cmake(SharedDepNotTarget) run_cmake(StaticPrivateDepNotExported) run_cmake(StaticPrivateDepNotTarget) +run_cmake(UNKNOWN-IMPORTED-GLOBAL) diff --git a/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake new file mode 100644 index 000000000..f52fa30bc --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake @@ -0,0 +1,4 @@ +enable_language(C) +add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL) +add_library(mylib empty.c) +target_link_libraries(mylib UnknownImportedGlobal) diff --git a/Tests/RunCMake/test_include_dirs/CMakeLists.txt b/Tests/RunCMake/test_include_dirs/CMakeLists.txt new file mode 100644 index 000000000..dc9248697 --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.6) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake b/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake new file mode 100644 index 000000000..d1633e445 --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake @@ -0,0 +1,17 @@ +include(RunCMake) + +function(run_TID) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TID-build) + set(RunCMake_TEST_NO_CLEAN 1) + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(TID) + run_cmake_command(TID-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(TID-test ${CMAKE_CTEST_COMMAND} -C Debug) +endfunction() + +run_TID() diff --git a/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt b/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt new file mode 100644 index 000000000..19bf051fa --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt @@ -0,0 +1,17 @@ +Test project .* + Start 1: house\.dog +1/6 Test #1: house\.dog \.+ +Passed +[0-9.]+ sec + Start 2: house\.cat +2/6 Test #2: house\.cat \.+ +Passed +[0-9.]+ sec + Start 3: farm\.cow +3/6 Test #3: farm\.cow \.+ +Passed +[0-9.]+ sec + Start 4: farm\.pig +4/6 Test #4: farm\.pig \.+ +Passed +[0-9.]+ sec + Start 5: zoo\.fox +5/6 Test #5: zoo\.fox \.+ +Passed +[0-9.]+ sec + Start 6: zoo\.emu +6/6 Test #6: zoo\.emu \.+ +Passed +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 6 + +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/test_include_dirs/TID.cmake b/Tests/RunCMake/test_include_dirs/TID.cmake new file mode 100644 index 000000000..1e74f90fe --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/TID.cmake @@ -0,0 +1,29 @@ +project(test_include_dirs) +include(CTest) + +enable_testing() + +add_executable(dummy dummy.cpp) + +function(generate_tests NAME) + set(ctest_file "${CMAKE_CURRENT_BINARY_DIR}/${NAME}_tests.cmake") + add_custom_command( + OUTPUT "${ctest_file}" + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EXECUTABLE=$<TARGET_FILE:dummy>" + -D "TEST_SUITE=${NAME}" + -D "TEST_NAMES=${ARGN}" + -D "CTEST_FILE=${ctest_file}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/add-tests.cmake" + VERBATIM + ) + add_custom_target(${NAME}_tests ALL DEPENDS "${ctest_file}") +endfunction() + +generate_tests(house dog cat) +generate_tests(farm cow pig) +generate_tests(zoo fox emu) + +set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE "house_tests.cmake") +set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "farm_tests.cmake") +set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "zoo_tests.cmake") diff --git a/Tests/RunCMake/test_include_dirs/add-tests.cmake b/Tests/RunCMake/test_include_dirs/add-tests.cmake new file mode 100644 index 000000000..e74665acc --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/add-tests.cmake @@ -0,0 +1,8 @@ +set(script) + +foreach(TEST_NAME ${TEST_NAMES}) + set(script "${script}add_test(\"${TEST_SUITE}.${TEST_NAME}\"") + set(script "${script} \"${TEST_EXECUTABLE}\")\n") +endforeach() + +file(WRITE "${CTEST_FILE}" "${script}") diff --git a/Tests/RunCMake/test_include_dirs/dummy.cpp b/Tests/RunCMake/test_include_dirs/dummy.cpp new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/dummy.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake b/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake new file mode 100644 index 000000000..1dee8375a --- /dev/null +++ b/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake @@ -0,0 +1,17 @@ +function (watch2) + +endfunction () + +function (watch1) + variable_watch(watched watch2) + variable_watch(watched watch2) + variable_watch(watched watch2) + variable_watch(watched watch2) + variable_watch(watched watch2) + variable_watch(watched watch2) +endfunction () + +variable_watch(watched watch1) +variable_watch(watched watch2) + +set(access "${watched}") diff --git a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake index 9becb4cd7..2fa62755d 100644 --- a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake +++ b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake @@ -3,3 +3,4 @@ include(RunCMake) run_cmake(ModifiedAccess) run_cmake(NoWatcher) run_cmake(WatchTwice) +run_cmake(ModifyWatchInCallback) diff --git a/Tests/SameName/CMakeLists.txt b/Tests/SameName/CMakeLists.txt deleted file mode 100644 index d78879dd9..000000000 --- a/Tests/SameName/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project(SameName C) - -add_subdirectory(Lib1) - -include_directories(${PROJECT_SOURCE_DIR}/Lib1) -add_subdirectory(Exe1) diff --git a/Tests/SameName/Exe1/CMakeLists.txt b/Tests/SameName/Exe1/CMakeLists.txt deleted file mode 100644 index b9182f209..000000000 --- a/Tests/SameName/Exe1/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# a target with the same name as a target in a different dir -add_executable(mytest_exe conly.c) -set_target_properties(mytest_exe PROPERTIES OUTPUT_NAME mytest) -target_link_libraries(mytest_exe mytest) - -# and two targets in the same dir with the same name -add_library(mytest2 ../Lib1/libc1.c) - -add_executable(mytest2_exe conly.c) -set_target_properties(mytest2_exe PROPERTIES OUTPUT_NAME mytest2) -target_link_libraries(mytest2_exe mytest2) diff --git a/Tests/SameName/Exe1/conly.c b/Tests/SameName/Exe1/conly.c deleted file mode 100644 index 8f2ce05f7..000000000 --- a/Tests/SameName/Exe1/conly.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "libc1.h" -#include <stdio.h> - -int main() -{ - if (LibC1Func() != 2.0) { - printf("Problem with libc1\n"); - return 1; - } - return 0; -} diff --git a/Tests/SameName/Lib1/CMakeLists.txt b/Tests/SameName/Lib1/CMakeLists.txt deleted file mode 100644 index 40fa15422..000000000 --- a/Tests/SameName/Lib1/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library(mytest libc1.c) diff --git a/Tests/SameName/Lib1/libc1.c b/Tests/SameName/Lib1/libc1.c deleted file mode 100644 index b01e1e1b5..000000000 --- a/Tests/SameName/Lib1/libc1.c +++ /dev/null @@ -1,4 +0,0 @@ -float LibC1Func() -{ - return 2.0; -} diff --git a/Tests/SameName/Lib1/libc1.h b/Tests/SameName/Lib1/libc1.h deleted file mode 100644 index 84c94a9cb..000000000 --- a/Tests/SameName/Lib1/libc1.h +++ /dev/null @@ -1 +0,0 @@ -extern float LibC1Func(); diff --git a/Tests/Server/CMakeLists.txt b/Tests/Server/CMakeLists.txt index e7eaa8d72..08bef0c44 100644 --- a/Tests/Server/CMakeLists.txt +++ b/Tests/Server/CMakeLists.txt @@ -16,10 +16,11 @@ macro(do_test bsname file) ) if (NOT test_result EQUAL 0) - message(SEND_ERROR "TEST FAILED") + message(SEND_ERROR "TEST FAILED: ${test_result}") endif() endmacro() +do_test("test_cache" "tc_cache.json") do_test("test_handshake" "tc_handshake.json") do_test("test_globalSettings" "tc_globalSettings.json") do_test("test_buildsystem1" "tc_buildsystem1.json") diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py index 78450d5bf..2218e02d2 100644 --- a/Tests/Server/cmakelib.py +++ b/Tests/Server/cmakelib.py @@ -95,6 +95,21 @@ def initProc(cmakeCommand): return cmakeCommand +def exitProc(cmakeCommand): + # Tell the server to exit. + cmakeCommand.stdin.close() + cmakeCommand.stdout.close() + + # Wait for the server to exit. + # If this version of python supports it, terminate the server after a timeout. + try: + cmakeCommand.wait(timeout=5) + except TypeError: + cmakeCommand.wait() + except: + cmakeCommand.terminate() + raise + def waitForMessage(cmakeCommand, expected): data = ordered(expected) packet = ordered(waitForRawMessage(cmakeCommand)) @@ -197,3 +212,27 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): print("Validating", i) if (packet[i] != data[i]): sys.exit(1) + +def validateCache(cmakeCommand, data): + packet = waitForReply(cmakeCommand, 'cache', '', False) + + cache = packet['cache'] + + if (data['isEmpty']): + if (cache != []): + print('Expected empty cache, but got data.\n') + sys.exit(1) + return; + + if (cache == []): + print('Expected cache contents, but got none.\n') + sys.exit(1) + + hadHomeDir = False + for value in cache: + if (value['key'] == 'CMAKE_HOME_DIRECTORY'): + hadHomeDir = True + + if (not hadHomeDir): + print('No CMAKE_HOME_DIRECTORY found in cache.') + sys.exit(1) diff --git a/Tests/Server/server-test.py b/Tests/Server/server-test.py index 62d9008b2..938091065 100644 --- a/Tests/Server/server-test.py +++ b/Tests/Server/server-test.py @@ -84,7 +84,7 @@ for obj in testData: if 'extraGenerator' in data: extraGenerator = data['extraGenerator'] if not os.path.isabs(buildDirectory): buildDirectory = buildDir + "/" + buildDirectory - if not os.path.isabs(sourceDirectory): + if sourceDirectory != '' and not os.path.isabs(sourceDirectory): sourceDirectory = sourceDir + "/" + sourceDirectory cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory, generator, extraGenerator) @@ -95,26 +95,21 @@ for obj in testData: if not 'generator' in data: data['generator'] = cmakeGenerator if not 'extraGenerator' in data: data['extraGenerator'] = '' cmakelib.validateGlobalSettings(proc, cmakeCommand, data) + elif 'validateCache' in obj: + data = obj['validateCache'] + if not 'isEmpty' in data: data['isEmpty'] = false + cmakelib.validateCache(proc, data) elif 'message' in obj: print("MESSAGE:", obj["message"]) + elif 'reconnect' in obj: + cmakelib.exitProc(proc) + proc = cmakelib.initProc(cmakeCommand) else: print("Unknown command:", json.dumps(obj)) sys.exit(2) print("Completed") -# Tell the server to exit. -proc.stdin.close() -proc.stdout.close() - -# Wait for the server to exit. -# If this version of python supports it, terminate the server after a timeout. -try: - proc.wait(timeout=5) -except TypeError: - proc.wait() -except: - proc.terminate() - raise - -sys.exit(0) +cmakelib.exitProc(proc) +print('cmake-server exited: %d' % proc.returncode) +sys.exit(proc.returncode) diff --git a/Tests/Server/tc_cache.json b/Tests/Server/tc_cache.json new file mode 100644 index 000000000..74af6d93c --- /dev/null +++ b/Tests/Server/tc_cache.json @@ -0,0 +1,24 @@ +[ +{ "message": "Testing cache" }, + +{ "message": "Cache after first handshake is empty:" }, +{ "handshake": {"major": 1, "sourceDirectory": "buildsystem1", "buildDirectory": "buildsystem1"} }, +{ "send": { "type": "cache" } }, +{ "validateCache": { "isEmpty": true } }, + +{ "message": "Cache after configure is populated:" }, +{ "send": { "type": "configure" } }, +{ "reply": { "type": "configure", "skipProgress":true } }, +{ "send": { "type": "cache" } }, +{ "validateCache": { "isEmpty": false } }, + +{ "message": "Handshake for existing cache requires buildDirectory only:" }, +{ "reconnect": {} }, +{ "handshake": {"major": 1, "sourceDirectory": "", "buildDirectory": "buildsystem1"} }, + +{ "message": "Cache after reconnect is again populated:" }, +{ "send": { "type": "cache" } }, +{ "validateCache": { "isEmpty": false } }, + +{ "message": "Everything ok." } +] diff --git a/Tests/Server/tc_handshake.json b/Tests/Server/tc_handshake.json index 975bb3d32..4bb7fa7ac 100644 --- a/Tests/Server/tc_handshake.json +++ b/Tests/Server/tc_handshake.json @@ -11,6 +11,10 @@ { "send": {"test": "sometext","cookie":"monster"} }, { "recv": {"cookie":"monster","errorMessage":"No type given in request.","inReplyTo":"","type":"error"} }, +{ "message": "Testing commands before handshake" }, +{ "send": {"type": "cache","cookie":"monster"} }, +{ "recv": {"cookie":"monster","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"cache","type":"error"} }, + { "message": "Testing handshake" }, { "send": {"type": "sometype","cookie":"monster2"} }, { "recv": {"cookie":"monster2","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"sometype","type":"error"} }, diff --git a/Tests/SimpleExclude/CMakeLists.txt b/Tests/SimpleExclude/CMakeLists.txt deleted file mode 100644 index baca23e39..000000000 --- a/Tests/SimpleExclude/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project(SimpleExclude C) - -set(EXECUTABLE_OUTPUT_PATH "${SimpleExclude_BINARY_DIR}" CACHE INTERNAL "" FORCE) -set(LIBRARY_OUTPUT_PATH "${SimpleExclude_BINARY_DIR}" CACHE INTERNAL "" FORCE) - -add_subdirectory(dirC EXCLUDE_FROM_ALL) -add_subdirectory(dirD) - -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/run.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/run.cmake" @ONLY) diff --git a/Tests/SimpleExclude/dirC/CMakeLists.txt b/Tests/SimpleExclude/dirC/CMakeLists.txt deleted file mode 100644 index 9b59fdaff..000000000 --- a/Tests/SimpleExclude/dirC/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory(dirA EXCLUDE_FROM_ALL) -add_subdirectory(dirB) - diff --git a/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt b/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt deleted file mode 100644 index 52fac8183..000000000 --- a/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -add_library(t1 STATIC t1.c) - -add_library(t2 STATIC t2.c) - -add_executable(t3 t3.c) - -add_executable(t4 t4.c) - -add_executable(t5 t5.c) -target_link_libraries(t5 t1) diff --git a/Tests/SimpleExclude/dirC/dirA/t1.c b/Tests/SimpleExclude/dirC/dirA/t1.c deleted file mode 100644 index 67fe06fee..000000000 --- a/Tests/SimpleExclude/dirC/dirA/t1.c +++ /dev/null @@ -1,8 +0,0 @@ -#include <stdio.h> - -int tlib1func() -{ - Should not be build unless target directory A, B, or C are build; - printf("This is T1\n"); - return 5; -} diff --git a/Tests/SimpleExclude/dirC/dirA/t2.c b/Tests/SimpleExclude/dirC/dirA/t2.c deleted file mode 100644 index 6aaf40675..000000000 --- a/Tests/SimpleExclude/dirC/dirA/t2.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <stdio.h> - -int tlib2func() -{ - printf("This is T2\n"); - return 2; -} diff --git a/Tests/SimpleExclude/dirC/dirA/t3.c b/Tests/SimpleExclude/dirC/dirA/t3.c deleted file mode 100644 index 1366dc0a6..000000000 --- a/Tests/SimpleExclude/dirC/dirA/t3.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <stdio.h> - -int main(int argc, char* argv[]) -{ - Should not be build unless target directory A, B, or C are build; - return 0; -} diff --git a/Tests/SimpleExclude/dirC/dirA/t4.c b/Tests/SimpleExclude/dirC/dirA/t4.c deleted file mode 100644 index b0e400014..000000000 --- a/Tests/SimpleExclude/dirC/dirA/t4.c +++ /dev/null @@ -1,17 +0,0 @@ -#include <stdio.h> - -#ifdef __CLASSIC_C__ -int main() -{ - int ac; - char* av[]; -#else -int main(int ac, char* av[]) -{ -#endif - if (ac > 1000) { - return *av[0]; - } - printf("This is T4. This one should work.\n"); - return 0; -} diff --git a/Tests/SimpleExclude/dirC/dirA/t5.c b/Tests/SimpleExclude/dirC/dirA/t5.c deleted file mode 100644 index 1fba2127c..000000000 --- a/Tests/SimpleExclude/dirC/dirA/t5.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <stdio.h> - -int main(int argc, char* argv[]) -{ - Should not be build unless target directory A, B, or C are build; - return 5; -} diff --git a/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt b/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt deleted file mode 100644 index ea4650c4a..000000000 --- a/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_library(t6 STATIC t6.c) - -add_library(t7 STATIC t7.c) -target_link_libraries(t7 t2) - diff --git a/Tests/SimpleExclude/dirC/dirB/t6.c b/Tests/SimpleExclude/dirC/dirB/t6.c deleted file mode 100644 index e8877df60..000000000 --- a/Tests/SimpleExclude/dirC/dirB/t6.c +++ /dev/null @@ -1,8 +0,0 @@ -#include <stdio.h> - -int tlib6func() -{ - Should not be build unless target directory B, or C are build; - printf("This is T6\n"); - return 6; -} diff --git a/Tests/SimpleExclude/dirC/dirB/t7.c b/Tests/SimpleExclude/dirC/dirB/t7.c deleted file mode 100644 index b613e9175..000000000 --- a/Tests/SimpleExclude/dirC/dirB/t7.c +++ /dev/null @@ -1,15 +0,0 @@ -#include <stdio.h> - -extern int tlib2func(); - -int tlib7func() -{ - printf("This is T7\n"); - - if (tlib2func() != 2) { - fprintf(stderr, "Something wrong with T2\n"); - return 1; - } - - return 7; -} diff --git a/Tests/SimpleExclude/dirD/CMakeLists.txt b/Tests/SimpleExclude/dirD/CMakeLists.txt deleted file mode 100644 index 44b8c27b6..000000000 --- a/Tests/SimpleExclude/dirD/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_library(t8 STATIC t8.c) - -add_executable(t9 t9.c) -target_link_libraries(t9 t7) - -add_custom_target(t4_custom ALL) -add_dependencies(t4_custom t4) diff --git a/Tests/SimpleExclude/dirD/t8.c b/Tests/SimpleExclude/dirD/t8.c deleted file mode 100644 index bddec6f7e..000000000 --- a/Tests/SimpleExclude/dirD/t8.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <stdio.h> - -int tlib8func() -{ - printf("This is T8\n"); - return 8; -} diff --git a/Tests/SimpleExclude/dirD/t9.c b/Tests/SimpleExclude/dirD/t9.c deleted file mode 100644 index 9954ea567..000000000 --- a/Tests/SimpleExclude/dirD/t9.c +++ /dev/null @@ -1,24 +0,0 @@ -#include <stdio.h> - -extern int tlib7func(); - -#ifdef __CLASSIC_C__ -int main() -{ - int ac; - char* av[]; -#else -int main(int ac, char* av[]) -{ -#endif - if (ac > 1000) { - return *av[0]; - } - printf("This is T9. This one should work.\n"); - - if (tlib7func() != 7) { - fprintf(stderr, "Something wrong with T7\n"); - return 1; - } - return 0; -} diff --git a/Tests/SimpleExclude/run.cmake.in b/Tests/SimpleExclude/run.cmake.in deleted file mode 100644 index d31d2e51b..000000000 --- a/Tests/SimpleExclude/run.cmake.in +++ /dev/null @@ -1,13 +0,0 @@ -set(t4_name "\"@CMAKE_CURRENT_BINARY_DIR@${CFG_DIR}/t4\"") -exec_program("${t4_name}" RETURN_VALUE "t4_var") -message("T4 ${t4_name} resulted ${t4_var}") - -set(t9_name "\"@CMAKE_CURRENT_BINARY_DIR@${CFG_DIR}/t9\"") -exec_program("${t9_name}" RETURN_VALUE "t9_var") -message("T9 ${t9_name} resulted ${t9_var}") - -if ( "${t4_var}" EQUAL "0" AND "${t9_var}" EQUAL "0" ) - message("Everything is good, Yoshimi won...") -else () - message(FATAL_ERROR "Yoshimi lost... The evil pink robots will take over the world") -endif () diff --git a/Tests/SimpleInstall/scripts/.gitattributes b/Tests/SimpleInstall/scripts/.gitattributes deleted file mode 100644 index 5e3db2fb3..000000000 --- a/Tests/SimpleInstall/scripts/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -sample_script crlf=input diff --git a/Tests/SimpleInstallS2/scripts/.gitattributes b/Tests/SimpleInstallS2/scripts/.gitattributes deleted file mode 100644 index 5e3db2fb3..000000000 --- a/Tests/SimpleInstallS2/scripts/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -sample_script crlf=input diff --git a/Tests/TargetName/scripts/.gitattributes b/Tests/TargetName/scripts/.gitattributes deleted file mode 100644 index 51b8ce901..000000000 --- a/Tests/TargetName/scripts/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -hello_world crlf=input diff --git a/Tests/VSGNUFortran/runtest.cmake.in b/Tests/VSGNUFortran/runtest.cmake.in index 987207bc4..fc05715d3 100644 --- a/Tests/VSGNUFortran/runtest.cmake.in +++ b/Tests/VSGNUFortran/runtest.cmake.in @@ -14,7 +14,7 @@ file(TO_NATIVE_PATH "${MINGW_PATH}" MINGW_PATH) string(REPLACE "\\" "\\\\" MINGW_PATH "${MINGW_PATH}") message("${MINGW_PATH}") set(test_exe "@VSGNUFortran_BINARY_DIR@/bin/c_using_fortran.exe") -set(ENV{PATH} "${MINGW_PATH}";$ENV{PATH}) +set(ENV{PATH} "${MINGW_PATH};$ENV{PATH}") message("run ${test_exe}") execute_process(COMMAND "${test_exe}" RESULT_VARIABLE res) diff --git a/Tests/VSResource/CMakeLists.txt b/Tests/VSResource/CMakeLists.txt index 718e62441..fb47c7e13 100644 --- a/Tests/VSResource/CMakeLists.txt +++ b/Tests/VSResource/CMakeLists.txt @@ -56,3 +56,10 @@ endif() set_property(TARGET VSResource PROPERTY VS_GLOBAL_CMakeTestVsGlobalVariable "test val") + +if(CMAKE_GENERATOR MATCHES "Ninja|Visual Studio") + cmake_policy(PUSH) + cmake_policy(SET CMP0037 OLD) + add_library("My ResourceLib" lib.cpp lib.rc) + cmake_policy(POP) +endif() diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt index 2b0c47806..acda11735 100644 --- a/Tests/VSWinStorePhone/CMakeLists.txt +++ b/Tests/VSWinStorePhone/CMakeLists.txt @@ -116,12 +116,14 @@ set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) -set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"") +set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED") +set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h") set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) -set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"") +set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED") +set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h") source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt index d40c40e2a..d0b07ea1c 100644 --- a/Tests/XCTest/CMakeLists.txt +++ b/Tests/XCTest/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(XCTest) +project(XCTest C) enable_testing() find_package(XCTest REQUIRED) diff --git a/Tests/bootstrap.bat.in b/Tests/bootstrap.bat.in index aeb24b1ca..85e79ef00 100644 --- a/Tests/bootstrap.bat.in +++ b/Tests/bootstrap.bat.in @@ -1,2 +1,2 @@ -@echo off -sh "@CMake_SOURCE_DIR@/bootstrap" %* +@echo off
+sh "@CMake_SOURCE_DIR@/bootstrap" %*
|