summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen/MocInclude/shared.cmake
blob: 2ca28414d3a3134774c47049a200c95b88d03e54 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Test moc include patterns
include_directories("../MocInclude")
include_directories(${CMAKE_CURRENT_BINARY_DIR})

# Generate .moc file externally and enabled SKIP_AUTOMOC on the file
qtx_generate_moc(
  ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjA.hpp
  ${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc)
set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjA.cpp PROPERTY SKIP_AUTOMOC ON)

# Generate .moc file externally from generated source file
# and enabled SKIP_AUTOMOC on the source file
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp
  COMMAND ${CMAKE_COMMAND} -E copy
    ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjB.hpp.in
    ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp)
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp
  COMMAND ${CMAKE_COMMAND} -E copy
    ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjB.cpp.in
    ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp)
qtx_generate_moc(
  ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp
  ${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp PROPERTY SKIP_AUTOMOC ON)

# Generate moc file externally and enabled SKIP_AUTOMOC on the header
qtx_generate_moc(
  ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.hpp
  ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp)
set_property(
  SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.hpp
  PROPERTY SKIP_AUTOMOC ON)
# Custom target to depend on
set(SOBJC_MOC ${CMAKE_CURRENT_BINARY_DIR}/moc_SObjCExtra.cpp)
add_custom_target("${MOC_INCLUDE_NAME}_SOBJC"
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp
  BYPRODUCTS ${SOBJC_MOC}
  COMMAND ${CMAKE_COMMAND} -E copy
    ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.moc.in
    ${SOBJC_MOC})

# MOC_INCLUDE_NAME must be defined by the includer
add_executable(${MOC_INCLUDE_NAME}
  # Common sources
  ../MocInclude/ObjA.cpp
  ../MocInclude/ObjB.cpp

  ../MocInclude/LObjA.cpp
  ../MocInclude/LObjB.cpp

  ../MocInclude/EObjA.cpp
  ../MocInclude/EObjAExtra.cpp
  ../MocInclude/EObjB.cpp
  ../MocInclude/subExtra/EObjBExtra.cpp

  ../MocInclude/SObjA.cpp
  ${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc
  ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp
  ${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc
  ../MocInclude/SObjC.cpp
  ../MocInclude/SObjCExtra.hpp
  ../MocInclude/SObjCExtra.cpp

  ../MocInclude/subGlobal/GObj.cpp
  main.cpp
)
add_dependencies(${MOC_INCLUDE_NAME} "${MOC_INCLUDE_NAME}_SOBJC")
target_link_libraries(${MOC_INCLUDE_NAME} ${QT_LIBRARIES})
set_target_properties(${MOC_INCLUDE_NAME} PROPERTIES AUTOMOC ON)