summaryrefslogtreecommitdiffstats
path: root/Tests/Qt4Targets/CMakeLists.txt
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-03-04 10:03:37 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-03-21 10:14:41 (GMT)
commit734df96f5ad3d47b3c7825715f0b524292aa6ede (patch)
tree8112056a1aa1461ee85c1952d3f04efa7927a90a /Tests/Qt4Targets/CMakeLists.txt
parent0f79dab48bf17e867fe19a7b7140fa7513f4b72d (diff)
downloadCMake-734df96f5ad3d47b3c7825715f0b524292aa6ede.zip
CMake-734df96f5ad3d47b3c7825715f0b524292aa6ede.tar.gz
CMake-734df96f5ad3d47b3c7825715f0b524292aa6ede.tar.bz2
Qt4: Fix moc command dependencies for incremental build.
Since commit v2.8.12~327^2 (Qt4Macros: Allow specifying a TARGET in invokations of macros., 2013-02-26), a parameters file is populated with moc arguments at generate-time. When the compile definitions or include directories change, the parameters file is updated but moc is not re-run in response. Fix that by making the moc invocation depend on the parameters file. Reported-At: https://bugreports.qt-project.org/browse/QTBUG-36970
Diffstat (limited to 'Tests/Qt4Targets/CMakeLists.txt')
-rw-r--r--Tests/Qt4Targets/CMakeLists.txt27
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()