From 2be0acb71e25cd425de71b047a0c77087e51c607 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 6 Sep 2017 13:18:47 +0200 Subject: [PATCH] Autogen: Tests: Add AUTOGEN_TARGET_DEPENDS test to mocDepends tests --- Tests/QtAutogen/mocDepends/CMakeLists.txt | 140 ++++++++++++------ .../{invalid.hpp.in => object_invalid.hpp.in} | 0 .../{object.hpp.in => object_valid.hpp.in} | 0 Tests/QtAutogen/mocDepends/test2.cpp | 9 -- Tests/QtAutogen/mocDepends/testATDFile.cpp | 9 ++ Tests/QtAutogen/mocDepends/testATDTarget.cpp | 9 ++ .../mocDepends/{test1.cpp => testGenFile.cpp} | 2 +- .../mocDepends/{test3.cpp => testGenLib.cpp} | 4 +- .../mocDepends/{test3.hpp => testGenLib.hpp} | 0 Tests/QtAutogen/mocDepends/testGenTarget.cpp | 9 ++ 10 files changed, 128 insertions(+), 54 deletions(-) rename Tests/QtAutogen/mocDepends/{invalid.hpp.in => object_invalid.hpp.in} (100%) rename Tests/QtAutogen/mocDepends/{object.hpp.in => object_valid.hpp.in} (100%) delete mode 100644 Tests/QtAutogen/mocDepends/test2.cpp create mode 100644 Tests/QtAutogen/mocDepends/testATDFile.cpp create mode 100644 Tests/QtAutogen/mocDepends/testATDTarget.cpp rename Tests/QtAutogen/mocDepends/{test1.cpp => testGenFile.cpp} (60%) rename Tests/QtAutogen/mocDepends/{test3.cpp => testGenLib.cpp} (54%) rename Tests/QtAutogen/mocDepends/{test3.hpp => testGenLib.hpp} (100%) create mode 100644 Tests/QtAutogen/mocDepends/testGenTarget.cpp diff --git a/Tests/QtAutogen/mocDepends/CMakeLists.txt b/Tests/QtAutogen/mocDepends/CMakeLists.txt index d71d740a4f..8217b8dbfd 100644 --- a/Tests/QtAutogen/mocDepends/CMakeLists.txt +++ b/Tests/QtAutogen/mocDepends/CMakeLists.txt @@ -15,81 +15,137 @@ else() endif() include_directories(${CMAKE_CURRENT_BINARY_DIR}) +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) -# -- Test 1: Depend on generated header +# -- Test dependency on header generated by a custom command +# # The ORIGIN_autogen target must depend on the same *GENERATED* source files as # the ORIGIN target. This is a requirement to ensure that all files for the # ORIGIN target are generated before the ORIGIN_autogen target is built. # -# This tests the dependency of the mocDepends1_autogen target of mocDepends1 -# to the source file test1_object.hpp, which is *GENERATED* by a custom command. -# If mocDepends1_autogen gets built *before* or in *parallel* to the -# custom command, the build will fail. That's because test1_object.hpp, -# which is required by mocDepends1_autogen, is only valid after the +# This tests the dependency of the mocDepGenFile_autogen target of +# mocDepGenFile to the source file GenFile.hpp, which is *GENERATED* +# by a custom command. +# If mocDepGenFile_autogen gets built *before* or in *parallel* to the +# custom command, the build will fail. That's because GenFile.hpp, +# which is required by mocDepGenFile_autogen, is only valid after the # custom command has been completed. # # The sleep seconds artificially increase the build time of the custom command # to simulate a slow file generation process that takes longer to run than -# the build of the mocDepends1_autogen target. +# the build of the mocDepGenFile_autogen target. add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test1_object.hpp - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/invalid.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/test1_object.hpp + OUTPUT ${CBD}/GenFile.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/GenFile.hpp COMMAND ${CMAKE_COMMAND} -E sleep 3 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/object.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/test1_object.hpp) + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/GenFile.hpp) -add_executable(mocDepends1 test1.cpp ${CMAKE_CURRENT_BINARY_DIR}/test1_object.hpp) -target_link_libraries(mocDepends1 ${QT_CORE_TARGET}) -set_target_properties(mocDepends1 PROPERTIES AUTOMOC TRUE) +add_executable(mocDepGenFile testGenFile.cpp ${CBD}/GenFile.hpp) +target_link_libraries(mocDepGenFile ${QT_CORE_TARGET}) +set_target_properties(mocDepGenFile PROPERTIES AUTOMOC TRUE) -# -- Test 2: Depend on header generating target + +# -- Test dependency on header generating custom target +# # The ORIGIN_autogen target must depend on the same user defined targets # as the ORIGIN target. This is a requirement to ensure that all files for the # ORIGIN target are generated before the ORIGIN_autogen target is built. # -# This tests the dependency of the mocDepends2_autogen target of mocDepends2 -# to the utility target mocDepends2Object. If mocDepends2_autogen gets built -# *before* or in *parallel* to mocDepends2Object, the build will fail. That's -# because test2_object.hpp, which is required by mocDepends2_autogen, -# is only valid after the mocDepends2Object build has been completed. +# This tests the dependency of the mocDepTarget_autogen target of +# mocDepTarget to the utility target mocDepTargetUtil. +# If mocDepTarget_autogen gets built *before* or in *parallel* to +# mocDepTargetUtil, the build will fail. That's +# because GenTarget.hpp, which is required by mocDepTarget_autogen, +# is only valid after the mocDepTargetUtil build has been completed. # -# The sleep seconds artificially increase the build time of mocDepends2Object +# The sleep seconds artificially increase the build time of mocDepTargetUtil # to simulate a slow utility target build that takes longer to run than -# the build of the mocDepends2_autogen target. -add_custom_target(mocDepends2Object - BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/test2_object.hpp - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/invalid.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/test2_object.hpp +# the build of the mocDepTarget_autogen target. +add_custom_target(mocDepTargetUtil + BYPRODUCTS ${CBD}/GenTarget.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/GenTarget.hpp COMMAND ${CMAKE_COMMAND} -E sleep 3 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/object.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/test2_object.hpp) + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/GenTarget.hpp) + +add_executable(mocDepTarget testGenTarget.cpp) +target_link_libraries(mocDepTarget ${QT_CORE_TARGET}) +set_target_properties(mocDepTarget PROPERTIES AUTOMOC TRUE) +add_dependencies(mocDepTarget mocDepTargetUtil) -add_executable(mocDepends2 test2.cpp) -target_link_libraries(mocDepends2 ${QT_CORE_TARGET}) -set_target_properties(mocDepends2 PROPERTIES AUTOMOC TRUE) -add_dependencies(mocDepends2 mocDepends2Object) # -- Test 3: Depend on generated linked library # The ORIGIN_autogen target must depend on the same linked libraries # as the ORIGIN target. This is a requirement to ensure that all files for the # ORIGIN target are generated before the ORIGIN_autogen target is built. # -# This tests the dependency of the mocDepends3_autogen target of mocDepends3 -# to the user generated library SimpleLib, which mocDepends3 links to. -# If mocDepends3_autogen gets built *before* or in *parallel* to SimpleLib, +# This tests the dependency of the mocDepGenLib_autogen target of mocDepGenLib +# to the user generated library SimpleLib, which mocDepGenLib links to. +# If mocDepGenLib_autogen gets built *before* or in *parallel* to SimpleLib, # the build will fail. That's because simpleLib.hpp, which is required by -# mocDepends3_autogen, is only valid after the SimpleLib build has been +# mocDepGenLib_autogen, is only valid after the SimpleLib build has been # completed. # # The sleep seconds artificially increase the build time of SimpleLib # to simulate a slow utility library build that takes longer to run than -# the build of the mocDepends3_autogen target. +# the build of the mocDepGenLib_autogen target. add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.hpp ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.cpp - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/invalid.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.hpp + OUTPUT ${CBD}/simpleLib.hpp ${CBD}/simpleLib.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/simpleLib.hpp COMMAND ${CMAKE_COMMAND} -E sleep 3 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/simpleLib.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.hpp - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/simpleLib.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.cpp) -add_library(SimpleLib STATIC ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.hpp ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.cpp) + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/simpleLib.hpp.in ${CBD}/simpleLib.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/simpleLib.cpp.in ${CBD}/simpleLib.cpp) +add_library(SimpleLib STATIC ${CBD}/simpleLib.hpp ${CBD}/simpleLib.cpp) target_link_libraries(SimpleLib ${QT_CORE_TARGET}) -add_executable(mocDepends3 test3.cpp) -target_link_libraries(mocDepends3 SimpleLib ${QT_CORE_TARGET}) -set_target_properties(mocDepends3 PROPERTIES AUTOMOC TRUE) +add_executable(mocDepGenLib testGenLib.cpp) +target_link_libraries(mocDepGenLib SimpleLib ${QT_CORE_TARGET}) +set_target_properties(mocDepGenLib PROPERTIES AUTOMOC TRUE) + + +# -- Test AUTOGEN_TARGET_DEPENDS with GENERATED file dependency +# +# This tests the dependency of the mocDepATDFile_autogen target of +# mocDepATDTarget to the utility target mocDepATDFileUtil. +# If mocDepATDFile_autogen gets built *before* or in *parallel* to +# mocDepATDFileUtil, the build will fail. That's +# because ATDFile.hpp, which is required by mocDepATDFile_autogen, +# is only valid after the mocDepATDFileUtil build has been completed. +# +# The sleep seconds artificially increase the build time of +# mocDepATDFileUtil to simulate a slow utility target build that takes +# longer to run than the build of the mocDepATDFile_autogen target. +add_custom_command( + OUTPUT ${CBD}/ATDFile.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDFile.hpp + COMMAND ${CMAKE_COMMAND} -E sleep 3 + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDFile.hpp) + +add_executable(mocDepATDFile testATDFile.cpp) +target_link_libraries(mocDepATDFile ${QT_CORE_TARGET}) +set_target_properties(mocDepATDFile PROPERTIES AUTOMOC TRUE) +set_target_properties(mocDepATDFile PROPERTIES AUTOGEN_TARGET_DEPENDS ${CBD}/ATDFile.hpp) + + +# -- Test AUTOGEN_TARGET_DEPENDS with target dependency +# +# This tests the dependency of the mocDepATDTarget_autogen target of +# mocDepATDTarget to the utility target mocDepATDTargetUtil. +# If mocDepATDTarget_autogen gets built *before* or in *parallel* to +# mocDepATDTargetUtil, the build will fail. That's +# because ATDTarget.hpp, which is required by mocDepATDTarget_autogen, +# is only valid after the mocDepATDTargetUtil build has been completed. +# +# The sleep seconds artificially increase the build time of +# mocDepATDTargetUtil to simulate a slow utility target build that takes +# longer to run than the build of the mocDepATDTarget_autogen target. +add_custom_target(mocDepATDTargetUtil + BYPRODUCTS ${CBD}/ATDTarget.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDTarget.hpp + COMMAND ${CMAKE_COMMAND} -E sleep 3 + COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDTarget.hpp) + +add_executable(mocDepATDTarget testATDTarget.cpp) +target_link_libraries(mocDepATDTarget ${QT_CORE_TARGET}) +set_target_properties(mocDepATDTarget PROPERTIES AUTOMOC TRUE) +set_target_properties(mocDepATDTarget PROPERTIES AUTOGEN_TARGET_DEPENDS mocDepATDTargetUtil) diff --git a/Tests/QtAutogen/mocDepends/invalid.hpp.in b/Tests/QtAutogen/mocDepends/object_invalid.hpp.in similarity index 100% rename from Tests/QtAutogen/mocDepends/invalid.hpp.in rename to Tests/QtAutogen/mocDepends/object_invalid.hpp.in diff --git a/Tests/QtAutogen/mocDepends/object.hpp.in b/Tests/QtAutogen/mocDepends/object_valid.hpp.in similarity index 100% rename from Tests/QtAutogen/mocDepends/object.hpp.in rename to Tests/QtAutogen/mocDepends/object_valid.hpp.in diff --git a/Tests/QtAutogen/mocDepends/test2.cpp b/Tests/QtAutogen/mocDepends/test2.cpp deleted file mode 100644 index 3fd845e5c4..0000000000 --- a/Tests/QtAutogen/mocDepends/test2.cpp +++ /dev/null @@ -1,9 +0,0 @@ - -#include "moc_test2_object.cpp" -#include "test2_object.hpp" - -int main() -{ - Object obj; - return 0; -} diff --git a/Tests/QtAutogen/mocDepends/testATDFile.cpp b/Tests/QtAutogen/mocDepends/testATDFile.cpp new file mode 100644 index 0000000000..6bddfcd390 --- /dev/null +++ b/Tests/QtAutogen/mocDepends/testATDFile.cpp @@ -0,0 +1,9 @@ + +#include "ATDFile.hpp" +#include "moc_ATDFile.cpp" + +int main() +{ + Object obj; + return 0; +} diff --git a/Tests/QtAutogen/mocDepends/testATDTarget.cpp b/Tests/QtAutogen/mocDepends/testATDTarget.cpp new file mode 100644 index 0000000000..831fc26914 --- /dev/null +++ b/Tests/QtAutogen/mocDepends/testATDTarget.cpp @@ -0,0 +1,9 @@ + +#include "ATDTarget.hpp" +#include "moc_ATDTarget.cpp" + +int main() +{ + Object obj; + return 0; +} diff --git a/Tests/QtAutogen/mocDepends/test1.cpp b/Tests/QtAutogen/mocDepends/testGenFile.cpp similarity index 60% rename from Tests/QtAutogen/mocDepends/test1.cpp rename to Tests/QtAutogen/mocDepends/testGenFile.cpp index 002dfd80b0..7df6e137c1 100644 --- a/Tests/QtAutogen/mocDepends/test1.cpp +++ b/Tests/QtAutogen/mocDepends/testGenFile.cpp @@ -1,5 +1,5 @@ -#include "test1_object.hpp" +#include "GenFile.hpp" int main() { diff --git a/Tests/QtAutogen/mocDepends/test3.cpp b/Tests/QtAutogen/mocDepends/testGenLib.cpp similarity index 54% rename from Tests/QtAutogen/mocDepends/test3.cpp rename to Tests/QtAutogen/mocDepends/testGenLib.cpp index a0095982c4..c14e159586 100644 --- a/Tests/QtAutogen/mocDepends/test3.cpp +++ b/Tests/QtAutogen/mocDepends/testGenLib.cpp @@ -1,5 +1,5 @@ -#include "test3.hpp" +#include "testGenLib.hpp" int main() { @@ -8,5 +8,5 @@ int main() return 0; } -// AUTOMOC the SimpleLib header simpleLib.hpp +// Depend on and AUTOMOC the SimpleLib header simpleLib.hpp #include "moc_simpleLib.cpp" diff --git a/Tests/QtAutogen/mocDepends/test3.hpp b/Tests/QtAutogen/mocDepends/testGenLib.hpp similarity index 100% rename from Tests/QtAutogen/mocDepends/test3.hpp rename to Tests/QtAutogen/mocDepends/testGenLib.hpp diff --git a/Tests/QtAutogen/mocDepends/testGenTarget.cpp b/Tests/QtAutogen/mocDepends/testGenTarget.cpp new file mode 100644 index 0000000000..911076efd9 --- /dev/null +++ b/Tests/QtAutogen/mocDepends/testGenTarget.cpp @@ -0,0 +1,9 @@ + +#include "GenTarget.hpp" +#include "moc_GenTarget.cpp" + +int main() +{ + Object obj; + return 0; +}