diff options
Diffstat (limited to 'Tests/Qt4Targets/CMakeLists.txt')
-rw-r--r-- | Tests/Qt4Targets/CMakeLists.txt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt index af9fc3f..7430084 100644 --- a/Tests/Qt4Targets/CMakeLists.txt +++ b/Tests/Qt4Targets/CMakeLists.txt @@ -36,3 +36,30 @@ add_executable(Qt4WrapMacroTest WIN32 main_wrap_test.cpp ${moc_file}) set_property(TARGET Qt4WrapMacroTest PROPERTY AUTOMOC OFF) target_include_directories(Qt4WrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface") target_link_libraries(Qt4WrapMacroTest Qt4::QtGui) + +set(timeformat "%Y%j%H%M%S") +try_compile(RESULT + "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild" + "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc" + IncrementalMoc + CMAKE_FLAGS -DADD_DEF=0 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}") +file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_before "${timeformat}") +if (NOT tsvar_before) + message(SEND_ERROR "Unable to read timestamp from moc file from first build!") +endif() + +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2) # Ensure that the timestamp will change. + +try_compile(RESULT + "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild" + "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc" + IncrementalMoc + CMAKE_FLAGS -DADD_DEF=1 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}") +file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_after "${timeformat}") +if (NOT tsvar_after) + message(SEND_ERROR "Unable to read timestamp from moc file from second build!") +endif() + +if (NOT tsvar_after GREATER tsvar_before) + message(SEND_ERROR "Rebuild did not re-create moc file. Before: ${tsvar_before}. After: ${tsvar_after}") +endif() |