diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-12-09 12:06:58 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-12-13 12:50:18 (GMT) |
commit | 54b4ff2aee015768a990cb3fccb79f8e87b38a19 (patch) | |
tree | 49982f8d34ef12cc27858b2130785ca4639fd9d2 /Tests | |
parent | 4988746e76703269d76c3fb633bafc0767fafbe4 (diff) | |
download | CMake-54b4ff2aee015768a990cb3fccb79f8e87b38a19.zip CMake-54b4ff2aee015768a990cb3fccb79f8e87b38a19.tar.gz CMake-54b4ff2aee015768a990cb3fccb79f8e87b38a19.tar.bz2 |
Autogen: Tests: Separate RerunMocBasic test
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/QtAutogen/CommonTests.cmake | 2 | ||||
-rw-r--r-- | Tests/QtAutogen/RerunMocBasic/CMakeLists.txt | 65 | ||||
-rw-r--r-- | Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt | 24 | ||||
-rw-r--r-- | Tests/QtAutogen/RerunMocBasic/MocBasic/input.txt (renamed from Tests/QtAutogenRerun/mocRerun/input.txt) | 0 | ||||
-rw-r--r-- | Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in (renamed from Tests/QtAutogenRerun/mocRerun/main.cpp.in) | 5 | ||||
-rw-r--r-- | Tests/QtAutogen/RerunMocBasic/MocBasic/res1.qrc (renamed from Tests/QtAutogenRerun/mocRerun/res1.qrc) | 0 | ||||
-rw-r--r-- | Tests/QtAutogen/RerunMocBasic/MocBasic/test1a.h.in (renamed from Tests/QtAutogenRerun/mocRerun/test1a.h.in) | 0 | ||||
-rw-r--r-- | Tests/QtAutogen/RerunMocBasic/MocBasic/test1b.h.in (renamed from Tests/QtAutogenRerun/mocRerun/test1b.h.in) | 0 | ||||
-rw-r--r-- | Tests/QtAutogen/RerunMocBasic/dummy.cpp | 5 | ||||
-rw-r--r-- | Tests/QtAutogenRerun/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/QtAutogenRerun/mocRerun.cmake | 60 | ||||
-rw-r--r-- | Tests/QtAutogenRerun/mocRerun/CMakeLists.txt | 33 |
12 files changed, 102 insertions, 97 deletions
diff --git a/Tests/QtAutogen/CommonTests.cmake b/Tests/QtAutogen/CommonTests.cmake index 6921495..94413a3 100644 --- a/Tests/QtAutogen/CommonTests.cmake +++ b/Tests/QtAutogen/CommonTests.cmake @@ -31,3 +31,5 @@ endif() ADD_AUTOGEN_TEST(SameName sameName) ADD_AUTOGEN_TEST(StaticLibraryCycle slc) ADD_AUTOGEN_TEST(Complex QtAutogen) +# Rerun tests +ADD_AUTOGEN_TEST(RerunMocBasic) diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt new file mode 100644 index 0000000..0bb0339 --- /dev/null +++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt @@ -0,0 +1,65 @@ +cmake_minimum_required(VERSION 3.10) +project(RerunMocBasic) +include("../AutogenTest.cmake") + +# Dummy executable to generate a clean target +add_executable(dummy dummy.cpp) + +set(timeformat "%Y%j%H%M%S") +set(mocBasicSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocBasic") +set(mocBasicBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocBasic") + +# Initial build +configure_file("${mocBasicSrcDir}/test1a.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) +try_compile(MOC_RERUN + "${mocBasicBinDir}" + "${mocBasicSrcDir}" + MocBasic + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output +) +if (NOT MOC_RERUN) + message(SEND_ERROR "Initial build of mocBasic failed. Output: ${output}") +endif() +# Get name of the output binary +file(STRINGS "${mocBasicBinDir}/mocBasic.txt" mocBasicList ENCODING UTF-8) +list(GET mocBasicList 0 mocBasicBin) + +message("Changing the header content for a MOC rerun") +# - Acquire binary timestamps before the build +file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}") +# - Ensure that the timestamp will change +# - Change header file content and rebuild +# - Rebuild +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +configure_file("${mocBasicSrcDir}/test1b.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result ) +if (result) + message(SEND_ERROR "Second build of mocBasic failed.") +endif() +# - Acquire binary timestamps after the build +file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}") +# - Test if timestamps changed +if (NOT timeAfter GREATER timeBefore) + message(SEND_ERROR "File (${mocBasicBin}) should have changed!") +endif() + + +message("Changing nothing for a MOC rerun") +# - Acquire binary timestamps before the build +file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}") +# - Ensure that the timestamp would change +# - Change nothing +# - Rebuild +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result ) +if (result) + message(SEND_ERROR "Third build of mocBasic failed.") +endif() +# - Acquire binary timestamps after the build +file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}") +# - Test if timestamps changed +if (timeAfter GREATER timeBefore) + message(SEND_ERROR "File (${mocBasicBin}) should not have changed!") +endif() diff --git a/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt new file mode 100644 index 0000000..cec60a4 --- /dev/null +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.10) +project(MocBasic) +include("../../AutogenTest.cmake") + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +# Generated source file +add_custom_command(OUTPUT ${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(mocBasic + ${CMAKE_CURRENT_BINARY_DIR}/test1.h + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + res1.qrc +) +target_include_directories(mocBasic PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(mocBasic ${QT_QTCORE_TARGET}) +# Write target name to text file +add_custom_command(TARGET mocBasic POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocBasic>" > mocBasic.txt +) diff --git a/Tests/QtAutogenRerun/mocRerun/input.txt b/Tests/QtAutogen/RerunMocBasic/MocBasic/input.txt index da62762..da62762 100644 --- a/Tests/QtAutogenRerun/mocRerun/input.txt +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/input.txt diff --git a/Tests/QtAutogenRerun/mocRerun/main.cpp.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in index b37ff61..9d7ea37 100644 --- a/Tests/QtAutogenRerun/mocRerun/main.cpp.in +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in @@ -1,5 +1,7 @@ #include "test1.h" +extern int qInitResources_res1(); + class Test2 : public QObject { Q_OBJECT @@ -9,6 +11,9 @@ public slots: int main() { + // Fails to link if the rcc generated symbol is not present. + qInitResources_res1(); + Test1 test1; Test2 test2; diff --git a/Tests/QtAutogenRerun/mocRerun/res1.qrc b/Tests/QtAutogen/RerunMocBasic/MocBasic/res1.qrc index fb804b5..fb804b5 100644 --- a/Tests/QtAutogenRerun/mocRerun/res1.qrc +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/res1.qrc diff --git a/Tests/QtAutogenRerun/mocRerun/test1a.h.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1a.h.in index a335046..a335046 100644 --- a/Tests/QtAutogenRerun/mocRerun/test1a.h.in +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1a.h.in diff --git a/Tests/QtAutogenRerun/mocRerun/test1b.h.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1b.h.in index 6128eeb..6128eeb 100644 --- a/Tests/QtAutogenRerun/mocRerun/test1b.h.in +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1b.h.in diff --git a/Tests/QtAutogen/RerunMocBasic/dummy.cpp b/Tests/QtAutogen/RerunMocBasic/dummy.cpp new file mode 100644 index 0000000..4837a76 --- /dev/null +++ b/Tests/QtAutogen/RerunMocBasic/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int argv, char** args) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/CMakeLists.txt b/Tests/QtAutogenRerun/CMakeLists.txt index e72c191..746ba4a 100644 --- a/Tests/QtAutogenRerun/CMakeLists.txt +++ b/Tests/QtAutogenRerun/CMakeLists.txt @@ -6,7 +6,7 @@ project(QtAutogenRerun) 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}) + list(APPEND CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) endif() if (QT_TEST_VERSION STREQUAL 4) @@ -40,9 +40,6 @@ endif() 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") diff --git a/Tests/QtAutogenRerun/mocRerun.cmake b/Tests/QtAutogenRerun/mocRerun.cmake deleted file mode 100644 index a92912b..0000000 --- a/Tests/QtAutogenRerun/mocRerun.cmake +++ /dev/null @@ -1,60 +0,0 @@ - -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/QtAutogenRerun/mocRerun/CMakeLists.txt b/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt deleted file mode 100644 index bafd9cf..0000000 --- a/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -cmake_minimum_required(VERSION 3.9) -cmake_policy(SET CMP0071 NEW) -project(mocRerun 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() - -set(CMAKE_AUTOMOC ON) -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) - -add_executable(mocRerun - ${CMAKE_CURRENT_BINARY_DIR}/test1.h - ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - 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>" > mocRerun.txt) |