summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-05-06 17:48:40 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-05-06 17:48:40 (GMT)
commit58557486db5343f7d63f709177be980ad8ced590 (patch)
tree56eb68ad32ab52605fa183b9aeb67b19fb3c1887 /Tests
parent4345cf36ac9d0f8586839a390ee7cba9be88e74b (diff)
parent17c31b8bd4aa56d924b94cf41b9c4a6a90d23264 (diff)
downloadCMake-58557486db5343f7d63f709177be980ad8ced590.zip
CMake-58557486db5343f7d63f709177be980ad8ced590.tar.gz
CMake-58557486db5343f7d63f709177be980ad8ced590.tar.bz2
Merge topic 'dont-rewrite-moc-parameter-file'
17c31b8b Qt4: Extend the Qt4Targets test to cover dir and target moc parameters. 6a5bd7f0 Qt4: write moc parameter file only when content has changed
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Qt4Targets/CMakeLists.txt61
-rw-r--r--Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt12
2 files changed, 48 insertions, 25 deletions
diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt
index 7430084..ae0a02b 100644
--- a/Tests/Qt4Targets/CMakeLists.txt
+++ b/Tests/Qt4Targets/CMakeLists.txt
@@ -37,29 +37,44 @@ 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()
+macro(test_incremental def)
+ set(timeformat "%Y%j%H%M%S")
+ try_compile(RESULT
+ "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild_${def}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc"
+ IncrementalMoc
+ CMAKE_FLAGS -D${def}=0 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+ )
+ file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild_${def}/moc_foo.cpp" tsvar_before "${timeformat}")
+ if (NOT tsvar_before)
+ message(SEND_ERROR
+ "Unable to read timestamp from moc file from first build with -D${def}!\n"
+ "try_compile output:\n${output}"
+ )
+ endif()
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2) # Ensure that the timestamp will change.
+ 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()
+ try_compile(RESULT
+ "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild_${def}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc"
+ IncrementalMoc
+ CMAKE_FLAGS -D${def}=1 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+ )
+ file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild_${def}/moc_foo.cpp" tsvar_after "${timeformat}")
+ if (NOT tsvar_after)
+ message(SEND_ERROR
+ "Unable to read timestamp from moc file from second build!\n"
+ "try_compile output:\n${output}"
+ )
+ 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()
+ if (NOT tsvar_after GREATER tsvar_before)
+ message(SEND_ERROR "Rebuild did not re-create moc file with -D${def}. Before: ${tsvar_before}. After: ${tsvar_after}")
+ endif()
+endmacro()
+
+test_incremental(ADD_TARGET_DEF)
+test_incremental(ADD_DIR_DEF)
diff --git a/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
index 4ba0ced..65e2b64 100644
--- a/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
+++ b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
@@ -4,10 +4,18 @@ project(IncrementalMoc)
find_package(Qt4 REQUIRED)
-qt4_generate_moc(foo.h moc_foo.cpp)
+if (ADD_TARGET_DEF)
+ set(target_args TARGET testlib)
+endif()
+
+if (ADD_DIR_DEF)
+ add_definitions(-DNEW_DEF)
+endif()
+
+qt4_generate_moc(foo.h moc_foo.cpp ${target_args})
add_library(testlib foo.cpp moc_foo.cpp)
target_link_libraries(testlib Qt4::QtCore)
-if (ADD_DEF)
+if (ADD_TARGET_DEF)
target_compile_definitions(testlib PRIVATE NEW_DEF)
endif()