summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen/mocRerun/CMakeLists.txt
blob: 6689f504526b0bef7008ca6679a91b389bb01c35 (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
cmake_minimum_required(VERSION 3.7)
project(mocRerun 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()

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

configure_file(test1a.h.in test1.h COPYONLY)
# Generated source file
add_custom_command(OUTPUT main.cpp
                   COMMAND ${CMAKE_COMMAND} -E sleep 3
                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
                   )

add_executable(mocRerun
  ${CMAKE_CURRENT_BINARY_DIR}/test1.h
  ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
  res1.qrc
  )
target_include_directories(mocRerun PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(mocRerun ${QT_CORE_TARGET})
# Write target name to text file
add_custom_command(TARGET mocRerun POST_BUILD COMMAND
  ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocRerun>" > target1.txt)