Merge topic 'export-refactor-more-for-cps'
[kiteware-cmake.git] / Tests / QtAutogen / AutogenTargetDepends / CMakeLists.txt
blobcf3f155679ed819edec952441066b94968f8cba8
1 cmake_minimum_required(VERSION 3.16)
2 project(AutogenTargetDepends)
3 include("../AutogenCoreTest.cmake")
5 include_directories(${CMAKE_CURRENT_BINARY_DIR})
6 set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
7 set(CBD ${CMAKE_CURRENT_BINARY_DIR})
9 # -- Test AUTOGEN_TARGET_DEPENDS with GENERATED file dependency
11 # This tests the dependency of the mocDepATDFile_autogen target of
12 # mocDepATDTarget to the utility target mocDepATDFileUtil.
13 # If mocDepATDFile_autogen gets built *before* or in *parallel* to
14 # mocDepATDFileUtil, the build will fail. That's
15 # because ATDFile.hpp, which is required by mocDepATDFile_autogen,
16 # is only valid after the mocDepATDFileUtil build has been completed.
18 # The sleep seconds artificially increase the build time of
19 # mocDepATDFileUtil to simulate a slow utility target build that takes
20 # longer to run than the build of the mocDepATDFile_autogen target.
21 add_custom_command(
22   OUTPUT ${CBD}/ATDFile.hpp
23   COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDFile.hpp
24   COMMAND ${CMAKE_COMMAND} -E sleep 3
25   COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDFile.hpp)
27 add_executable(mocDepATDFile testATDFile.cpp)
28 target_link_libraries(mocDepATDFile ${QT_QTCORE_TARGET})
29 set_target_properties(mocDepATDFile PROPERTIES AUTOMOC TRUE)
30 set_target_properties(mocDepATDFile PROPERTIES AUTOGEN_TARGET_DEPENDS ${CBD}/ATDFile.hpp)
33 # -- Test AUTOGEN_TARGET_DEPENDS with target dependency
35 # This tests the dependency of the mocDepATDTarget_autogen target of
36 # mocDepATDTarget to the utility target mocDepATDTargetUtil.
37 # If mocDepATDTarget_autogen gets built *before* or in *parallel* to
38 # mocDepATDTargetUtil, the build will fail. That's
39 # because ATDTarget.hpp, which is required by mocDepATDTarget_autogen,
40 # is only valid after the mocDepATDTargetUtil build has been completed.
42 # The sleep seconds artificially increase the build time of
43 # mocDepATDTargetUtil to simulate a slow utility target build that takes
44 # longer to run than the build of the mocDepATDTarget_autogen target.
45 add_custom_target(mocDepATDTargetUtil
46   BYPRODUCTS ${CBD}/ATDTarget.hpp
47   COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDTarget.hpp
48   COMMAND ${CMAKE_COMMAND} -E sleep 3
49   COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDTarget.hpp)
51 add_executable(mocDepATDTarget testATDTarget.cpp)
52 target_link_libraries(mocDepATDTarget ${QT_QTCORE_TARGET})
53 set_target_properties(mocDepATDTarget PROPERTIES AUTOMOC TRUE)
54 set_target_properties(mocDepATDTarget PROPERTIES AUTOGEN_TARGET_DEPENDS mocDepATDTargetUtil)