summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen/CMakeLists.txt
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-02-17 12:50:33 (GMT)
committerBrad King <brad.king@kitware.com>2017-02-21 15:38:49 (GMT)
commitcd74daf06f3b12f78bf7aed95ed06ff221a28da3 (patch)
treed670659848ac0d36699e13dc50200bc7dfe7c5b8 /Tests/QtAutogen/CMakeLists.txt
parent39c4819eaa4f680411a63701b1303d79a088aece (diff)
downloadCMake-cd74daf06f3b12f78bf7aed95ed06ff221a28da3.zip
CMake-cd74daf06f3b12f78bf7aed95ed06ff221a28da3.tar.gz
CMake-cd74daf06f3b12f78bf7aed95ed06ff221a28da3.tar.bz2
Autogen: Tests: Add Q_PLUGIN_METADATA test
Diffstat (limited to 'Tests/QtAutogen/CMakeLists.txt')
-rw-r--r--Tests/QtAutogen/CMakeLists.txt61
1 files changed, 59 insertions, 2 deletions
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 40c23fa..260331b 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -86,7 +86,8 @@ try_compile(RCC_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/autorcc_depends"
"${CMAKE_CURRENT_SOURCE_DIR}/autorcc_depends"
autorcc_depends
- CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
OUTPUT_VARIABLE output
)
@@ -121,7 +122,8 @@ try_compile(MOC_RERUN
"${CMAKE_CURRENT_BINARY_DIR}/automoc_rerun"
"${CMAKE_CURRENT_SOURCE_DIR}/automoc_rerun"
automoc_rerun
- CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
OUTPUT_VARIABLE output
)
@@ -215,5 +217,60 @@ add_subdirectory(mocIncludeStrict)
add_subdirectory(mocIncludeRelaxed)
# -- Test
+# Tests Q_PLUGIN_METADATA json file change detection
+if (NOT QT_TEST_VERSION STREQUAL 4)
+ try_compile(MOC_PLUGIN
+ "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin"
+ "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin"
+ mocPlugin
+ CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
+ OUTPUT_VARIABLE output
+ )
+ if (NOT MOC_PLUGIN)
+ message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}")
+ endif()
+
+ set(timeformat "%Y%j%H%M%S")
+ set(mocPluginBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin")
+ find_library(style_a_file "PluginStyleA" "${mocPluginBinDir}")
+ find_library(style_b_file "PluginStyleB" "${mocPluginBinDir}")
+ find_library(style_c_file "PluginStyleC" "${mocPluginBinDir}")
+ find_library(style_d_file "PluginStyleD" "${mocPluginBinDir}")
+
+ file(TIMESTAMP "${style_a_file}" style_a_before "${timeformat}")
+ file(TIMESTAMP "${style_b_file}" style_b_before "${timeformat}")
+ file(TIMESTAMP "${style_c_file}" style_c_before "${timeformat}")
+ file(TIMESTAMP "${style_d_file}" style_d_before "${timeformat}")
+
+ # Ensure that the timestamp will change and touch the json files
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${mocPluginBinDir}/jsonFiles/StyleC.json")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${mocPluginBinDir}/jsonFiles/sub/StyleD.json")
+
+ execute_process(COMMAND "${CMAKE_COMMAND}" --build .
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin"
+ )
+
+ file(TIMESTAMP "${style_a_file}" style_a_after "${timeformat}")
+ file(TIMESTAMP "${style_b_file}" style_b_after "${timeformat}")
+ file(TIMESTAMP "${style_c_file}" style_c_after "${timeformat}")
+ file(TIMESTAMP "${style_d_file}" style_d_after "${timeformat}")
+
+ if (style_a_after GREATER style_a_before)
+ message(SEND_ERROR "file (${style_a_file}) should not have changed!")
+ endif()
+ if (style_b_after GREATER style_b_before)
+ message(SEND_ERROR "file (${style_b_file}) should not have changed!")
+ endif()
+ if (NOT style_c_after GREATER style_c_before)
+ message(SEND_ERROR "file (${style_c_file}) should have changed!")
+ endif()
+ if (NOT style_d_after GREATER style_d_before)
+ message(SEND_ERROR "file (${style_d_file}) should have changed!")
+ endif()
+endif()
+
+# -- Test
# Complex test case
add_subdirectory(complex)