blob: cd5adf55dec91d5e3a2b1a8646669aeb1f0c4710 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0071 NEW)
project(mocDepends CXX)
if (QT_TEST_VERSION STREQUAL 4)
find_package(Qt4 REQUIRED)
set(QT_CORE_TARGET Qt4::QtCore)
else()
if (NOT QT_TEST_VERSION STREQUAL 5)
message(SEND_ERROR "Invalid Qt version specified.")
endif()
find_package(Qt5Core REQUIRED)
set(QT_CORE_TARGET Qt5::Core)
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# -- Test 1 using generated header
# This tests the dependency of AUTOMOC of mocDepends1 to the generated object.hpp
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/object.hpp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/invalid.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/object.hpp
COMMAND ${CMAKE_COMMAND} -E sleep 3
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/object.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/object.hpp
)
add_executable(mocDepends1 test1.cpp
${CMAKE_CURRENT_BINARY_DIR}/object.hpp
)
target_link_libraries(mocDepends1 ${QT_CORE_TARGET})
set_target_properties(mocDepends1 PROPERTIES AUTOMOC TRUE)
# -- Test 2 using generated library
# This tests the dependency of AUTOMOC of mocDepends2 to the
# generated simpleLib.hpp which belongs to a linked library of mocDepends2
add_custom_command(OUTPUT simpleLib.hpp simpleLib.cpp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/invalid.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/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 simpleLib.hpp simpleLib.cpp)
add_executable(mocDepends2 test2.cpp )
target_link_libraries(mocDepends2 SimpleLib ${QT_CORE_TARGET})
set_target_properties(mocDepends2 PROPERTIES AUTOMOC TRUE)
|