diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-09-14 18:34:32 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-09-21 07:58:24 (GMT) |
commit | 51fd7b714ba518e70f4aa192b1d39e32eea79aef (patch) | |
tree | 2167927b7afc852fd216e6ed15b3a55b14976621 /Tests | |
parent | c8f92db72cedb4aa970be3c29b0fa1e3beff96f9 (diff) | |
download | CMake-51fd7b714ba518e70f4aa192b1d39e32eea79aef.zip CMake-51fd7b714ba518e70f4aa192b1d39e32eea79aef.tar.gz CMake-51fd7b714ba518e70f4aa192b1d39e32eea79aef.tar.bz2 |
Autogen: Tests: Add a change-not test to the mocRerun test
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/QtAutogenRerun/mocRerun.cmake | 43 | ||||
-rw-r--r-- | Tests/QtAutogenRerun/mocRerun/CMakeLists.txt | 10 |
2 files changed, 36 insertions, 17 deletions
diff --git a/Tests/QtAutogenRerun/mocRerun.cmake b/Tests/QtAutogenRerun/mocRerun.cmake index eb7a07c..a92912b 100644 --- a/Tests/QtAutogenRerun/mocRerun.cmake +++ b/Tests/QtAutogenRerun/mocRerun.cmake @@ -4,7 +4,7 @@ set(mocRerunSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun") set(mocRerunBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocRerun") # Initial build -configure_file(mocRerun/test1a.h.in mocRerun/test1.h COPYONLY) +configure_file("${mocRerunSrcDir}/test1a.h.in" "${mocRerunBinDir}/test1.h" COPYONLY) try_compile(MOC_RERUN "${mocRerunBinDir}" "${mocRerunSrcDir}" @@ -17,23 +17,44 @@ try_compile(MOC_RERUN if (NOT MOC_RERUN) message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}") endif() - # Get name of the output binary -file(STRINGS "${mocRerunBinDir}/target1.txt" target1List ENCODING UTF-8) -list(GET target1List 0 binFile) - -file(TIMESTAMP "${binFile}" timeBegin "${timeformat}") +file(STRINGS "${mocRerunBinDir}/mocRerun.txt" mocRerunList ENCODING UTF-8) +list(GET mocRerunList 0 mocRerunBin) -# Change header file content and rebuild +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(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY) +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() -file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}") -if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "File (${binFile}) should have changed in the first step!") +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 index 7380bdd..bafd9cf 100644 --- a/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt +++ b/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt @@ -19,17 +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 - ) + 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) |