aboutsummaryrefslogtreecommitdiff
path: root/tests/ECMAddTests/single_tests/CMakeLists.txt
blob: ebbd63b87956feb71c3bbb4c99ddf9de148abf00 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
project(ECMAddTests)
cmake_minimum_required(VERSION 3.5)

set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
set(CMAKE_MODULE_PATH "${ECM_MODULE_DIR}")

add_library(testhelper STATIC ../testhelper.cpp)
target_include_directories(testhelper PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")

# Link to QtCore for WinMain on Windows
include(QtVersionOption)
find_package(Qt${QT_MAJOR_VERSION}Core REQUIRED)
target_link_libraries(testhelper PUBLIC Qt${QT_MAJOR_VERSION}::Core)

enable_testing()

include(ECMAddTests)

# clean up to avoid false-positives from check_files.cmake
file(REMOVE
    "${CMAKE_CURRENT_BINARY_DIR}/test1.txt"
    "${CMAKE_CURRENT_BINARY_DIR}/test2.txt"
    "${CMAKE_CURRENT_BINARY_DIR}/test3.txt"
    "${CMAKE_CURRENT_BINARY_DIR}/test4.txt"
    "${CMAKE_CURRENT_BINARY_DIR}/test5.txt"
    "${CMAKE_CURRENT_BINARY_DIR}/test6.txt"
    )

ecm_add_test(test1.cpp
    LINK_LIBRARIES testhelper
    )
# check target exists
get_property(_dummy TARGET test1 PROPERTY TYPE)
# check test exists
get_property(_dummy TEST test1 PROPERTY TIMEOUT)
get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE)
if (_is_win32)
    message(FATAL_ERROR "test1 is a WIN32 executable when it should not be")
endif()
get_property(_is_bundle TARGET test1 PROPERTY MACOSX_BUNDLE)
if (_is_bundle)
    message(FATAL_ERROR "test1 is an OS/X bundle when it should not be")
endif()


ecm_add_test(test2.cpp
    LINK_LIBRARIES testhelper
    TEST_NAME named_test
    )
get_property(_dummy TARGET named_test PROPERTY TYPE)
get_property(_dummy TEST named_test PROPERTY TIMEOUT)
get_property(_is_win32 TARGET named_test PROPERTY WIN32_EXECUTABLE)
if (_is_win32)
    message(FATAL_ERROR "named_test is a WIN32 executable when it should not be")
endif()
get_property(_is_bundle TARGET named_test PROPERTY MACOSX_BUNDLE)
if (_is_bundle)
    message(FATAL_ERROR "named_test is an OS/X bundle when it should not be")
endif()


ecm_add_test(test3.cpp
    LINK_LIBRARIES testhelper
    NAME_PREFIX prefix_
    )
get_property(_dummy TARGET test3 PROPERTY TYPE)
get_property(_dummy TEST prefix_test3 PROPERTY TIMEOUT)
get_property(_is_win32 TARGET test3 PROPERTY WIN32_EXECUTABLE)
if (_is_win32)
    message(FATAL_ERROR "test3 is a WIN32 executable when it should not be")
endif()
get_property(_is_bundle TARGET test3 PROPERTY MACOSX_BUNDLE)
if (_is_bundle)
    message(FATAL_ERROR "test3 is an OS/X bundle when it should not be")
endif()


ecm_add_test(test4.cpp
    LINK_LIBRARIES testhelper
    GUI
    )
get_property(_dummy TARGET test4 PROPERTY TYPE)
get_property(_dummy TEST test4 PROPERTY TIMEOUT)
get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE)
if (NOT _is_win32)
    message(FATAL_ERROR "test4 is not a WIN32 executable when it should be")
endif()
get_property(_is_bundle TARGET test4 PROPERTY MACOSX_BUNDLE)
if (NOT _is_bundle)
    message(FATAL_ERROR "test4 is not an OS/X bundle when it should be")
endif()


ecm_add_test(test5.cpp
    LINK_LIBRARIES testhelper
    TEST_NAME combined_test
    NAME_PREFIX another_prefix_
    GUI
    )
get_property(_dummy TARGET combined_test PROPERTY TYPE)
get_property(_dummy TEST another_prefix_combined_test PROPERTY TIMEOUT)
get_property(_is_win32 TARGET combined_test PROPERTY WIN32_EXECUTABLE)
if (NOT _is_win32)
    message(FATAL_ERROR "combined_test is not a WIN32 executable when it should be")
endif()
get_property(_is_bundle TARGET combined_test PROPERTY MACOSX_BUNDLE)
if (NOT _is_bundle)
    message(FATAL_ERROR "combined_test is not an OS/X bundle when it should be")
endif()


ecm_add_test(test6.cpp test6body.cpp
    LINK_LIBRARIES testhelper
    TEST_NAME multifile_test
    )
get_property(_dummy TARGET multifile_test PROPERTY TYPE)
get_property(_dummy TEST multifile_test PROPERTY TIMEOUT)
get_property(_is_win32 TARGET multifile_test PROPERTY WIN32_EXECUTABLE)
if (_is_win32)
    message(FATAL_ERROR "multifile_test is a WIN32 executable when it should not be")
endif()
get_property(_is_bundle TARGET multifile_test PROPERTY MACOSX_BUNDLE)
if (_is_bundle)
    message(FATAL_ERROR "multifile_test is an OS/X bundle when it should not be")
endif()