summaryrefslogtreecommitdiffstats
path: root/Tests/CTestCoverageCollectGCOV/TestProject/CMakeLists.txt
blob: ce6fac4352ad6a9d04adfb6afd8ca5ab03a0e951 (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
cmake_minimum_required(VERSION 3.2)

project(TestProject CXX)

include(CTest)

set(SOURCES
  main.cpp
  3rdparty/foo.cpp
  extra/extra.cpp
)

add_executable(myexecutable ${SOURCES})

set_property(SOURCE main.cpp APPEND PROPERTY LABELS SourceLabel)
set_property(TARGET myexecutable APPEND PROPERTY LABELS TargetLabel)

set(MYEXECUTABLE_INFO_FILE "${CMAKE_CURRENT_BINARY_DIR}/myexecutable_info.cmake")

file(WRITE "${MYEXECUTABLE_INFO_FILE}" "
  set(TARGET myexecutable)
  set(SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")
  set(SOURCES \"${SOURCES}\")
")

add_custom_command(TARGET myexecutable
  POST_BUILD
  COMMAND ${CMAKE_COMMAND}
    "-DINFO_FILE=${MYEXECUTABLE_INFO_FILE}"
    -P "${CMAKE_CURRENT_SOURCE_DIR}/fake_compile_time_gcno.cmake"
  VERBATIM
)

add_test(NAME mytest
  COMMAND ${CMAKE_COMMAND}
    "-DMYEXECUTABLE=$<TARGET_FILE:myexecutable>"
    "-DTARGETDIR=${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/myexecutable.dir"
    -P "${CMAKE_CURRENT_SOURCE_DIR}/fake_run_time_gcda.cmake"
)

set_property(TEST mytest APPEND PROPERTY LABELS TestLabel)