summaryrefslogtreecommitdiffstats
path: root/test/unit/CMakeLists.txt
blob: 994777fc4bb2c98bfe9fede63257cd0b5b3e876c (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
set(SRC_DIR ${colobot_SOURCE_DIR}/src)

# Additional libraries per platform
if (${MXE}) # MXE requires special treatment
    set(PLATFORM_LIBS ${MXE_LIBS})
elseif (${PLATFORM_WINDOWS})
    # because it isn't included in standard linking libraries
    set(PLATFORM_LIBS "-lintl")
elseif(${PLATFORM_LINUX})
    # for clock_gettime
    set(PLATFORM_LIBS "-lrt -lX11")
endif()


# Configure file
configure_file(${SRC_DIR}/common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)

# Platform-dependent implementation of system.h
if (${PLATFORM_WINDOWS})
    set(SYSTEM_CPP_MODULE "system_windows.cpp")
elseif(${PLATFORM_LINUX})
    set(SYSTEM_CPP_MODULE "system_linux.cpp")
else()
    set(SYSTEM_CPP_MODULE "system_other.cpp")
endif()

# Code sources
set(COLOBOT_SOURCES
${SRC_DIR}/app/app.cpp
${SRC_DIR}/app/system.cpp
${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
${SRC_DIR}/common/event.cpp
${SRC_DIR}/common/image.cpp
${SRC_DIR}/common/iman.cpp
${SRC_DIR}/common/logger.cpp
${SRC_DIR}/common/misc.cpp
${SRC_DIR}/common/profile.cpp
${SRC_DIR}/common/restext.cpp
${SRC_DIR}/common/stringutils.cpp
${SRC_DIR}/graphics/core/color.cpp
${SRC_DIR}/graphics/engine/camera.cpp
${SRC_DIR}/graphics/engine/cloud.cpp
${SRC_DIR}/graphics/engine/engine.cpp
${SRC_DIR}/graphics/engine/lightman.cpp
${SRC_DIR}/graphics/engine/lightning.cpp
${SRC_DIR}/graphics/engine/modelfile.cpp
${SRC_DIR}/graphics/engine/modelmanager.cpp
${SRC_DIR}/graphics/engine/particle.cpp
${SRC_DIR}/graphics/engine/planet.cpp
${SRC_DIR}/graphics/engine/pyro.cpp
${SRC_DIR}/graphics/engine/terrain.cpp
${SRC_DIR}/graphics/engine/text.cpp
${SRC_DIR}/graphics/engine/water.cpp
${SRC_DIR}/graphics/opengl/gldevice.cpp
${SRC_DIR}/object/auto/auto.cpp
${SRC_DIR}/object/auto/autobase.cpp
${SRC_DIR}/object/auto/autoconvert.cpp
${SRC_DIR}/object/auto/autoderrick.cpp
${SRC_DIR}/object/auto/autodestroyer.cpp
${SRC_DIR}/object/auto/autoegg.cpp
${SRC_DIR}/object/auto/autoenergy.cpp
${SRC_DIR}/object/auto/autofactory.cpp
${SRC_DIR}/object/auto/autoflag.cpp
${SRC_DIR}/object/auto/autohuston.cpp
${SRC_DIR}/object/auto/autoinfo.cpp
${SRC_DIR}/object/auto/autojostle.cpp
${SRC_DIR}/object/auto/autokid.cpp
${SRC_DIR}/object/auto/autolabo.cpp
${SRC_DIR}/object/auto/automush.cpp
${SRC_DIR}/object/auto/autonest.cpp
${SRC_DIR}/object/auto/autonuclear.cpp
${SRC_DIR}/object/auto/autopara.cpp
${SRC_DIR}/object/auto/autoportico.cpp
${SRC_DIR}/object/auto/autoradar.cpp
${SRC_DIR}/object/auto/autorepair.cpp
${SRC_DIR}/object/auto/autoresearch.cpp
${SRC_DIR}/object/auto/autoroot.cpp
${SRC_DIR}/object/auto/autosafe.cpp
${SRC_DIR}/object/auto/autostation.cpp
${SRC_DIR}/object/auto/autotower.cpp
${SRC_DIR}/object/brain.cpp
${SRC_DIR}/object/mainmovie.cpp
${SRC_DIR}/object/motion/motion.cpp
${SRC_DIR}/object/motion/motionant.cpp
${SRC_DIR}/object/motion/motionbee.cpp
${SRC_DIR}/object/motion/motionhuman.cpp
${SRC_DIR}/object/motion/motionmother.cpp
${SRC_DIR}/object/motion/motionspider.cpp
${SRC_DIR}/object/motion/motiontoto.cpp
${SRC_DIR}/object/motion/motionvehicle.cpp
${SRC_DIR}/object/motion/motionworm.cpp
${SRC_DIR}/object/motion/motiondummy.cpp
${SRC_DIR}/object/object.cpp
${SRC_DIR}/object/objman.cpp
${SRC_DIR}/object/robotmain.cpp
${SRC_DIR}/object/task/task.cpp
${SRC_DIR}/object/task/taskadvance.cpp
${SRC_DIR}/object/task/taskbuild.cpp
${SRC_DIR}/object/task/taskfire.cpp
${SRC_DIR}/object/task/taskfireant.cpp
${SRC_DIR}/object/task/taskflag.cpp
${SRC_DIR}/object/task/taskgoto.cpp
${SRC_DIR}/object/task/taskgungoal.cpp
${SRC_DIR}/object/task/taskinfo.cpp
${SRC_DIR}/object/task/taskmanager.cpp
${SRC_DIR}/object/task/taskmanip.cpp
${SRC_DIR}/object/task/taskpen.cpp
${SRC_DIR}/object/task/taskrecover.cpp
${SRC_DIR}/object/task/taskreset.cpp
${SRC_DIR}/object/task/tasksearch.cpp
${SRC_DIR}/object/task/taskshield.cpp
${SRC_DIR}/object/task/taskspiderexplo.cpp
${SRC_DIR}/object/task/tasktake.cpp
${SRC_DIR}/object/task/taskterraform.cpp
${SRC_DIR}/object/task/taskturn.cpp
${SRC_DIR}/object/task/taskwait.cpp
${SRC_DIR}/physics/physics.cpp
${SRC_DIR}/script/cbottoken.cpp
${SRC_DIR}/script/cmdtoken.cpp
${SRC_DIR}/script/script.cpp
${SRC_DIR}/sound/sound.cpp
${SRC_DIR}/ui/button.cpp
${SRC_DIR}/ui/check.cpp
${SRC_DIR}/ui/color.cpp
${SRC_DIR}/ui/compass.cpp
${SRC_DIR}/ui/control.cpp
${SRC_DIR}/ui/displayinfo.cpp
${SRC_DIR}/ui/displaytext.cpp
${SRC_DIR}/ui/edit.cpp
${SRC_DIR}/ui/editvalue.cpp
${SRC_DIR}/ui/gauge.cpp
${SRC_DIR}/ui/group.cpp
${SRC_DIR}/ui/image.cpp
${SRC_DIR}/ui/interface.cpp
${SRC_DIR}/ui/key.cpp
${SRC_DIR}/ui/label.cpp
${SRC_DIR}/ui/list.cpp
${SRC_DIR}/ui/maindialog.cpp
${SRC_DIR}/ui/mainmap.cpp
${SRC_DIR}/ui/mainshort.cpp
${SRC_DIR}/ui/map.cpp
${SRC_DIR}/ui/scroll.cpp
${SRC_DIR}/ui/shortcut.cpp
${SRC_DIR}/ui/slider.cpp
${SRC_DIR}/ui/studio.cpp
${SRC_DIR}/ui/target.cpp
${SRC_DIR}/ui/window.cpp
)

set(OPENAL_SOURCES "")

if (${OPENAL_SOUND})
    set(OPENAL_SOURCES
        ${SRC_DIR}/sound/oalsound/alsound.cpp
        ${SRC_DIR}/sound/oalsound/buffer.cpp
        ${SRC_DIR}/sound/oalsound/channel.cpp
    )
endif()

# Optional libraries
set(OPTIONAL_LIBS "")

if (${OPENAL_SOUND})
    set(OPTIONAL_LIBS ${OPENAL_LIBRARY})
    set(OPTIONAL_INCLUDES ${OPENAL_INCLUDE_DIR})
endif()


# Platform-dependent tests
if (${PLATFORM_WINDOWS})
    set(PLATFORM_TESTS app/system_windows_test.cpp)
elseif(${PLATFORM_LINUX})
    set(PLATFORM_TESTS app/system_linux_test.cpp)
endif()

# Tests
set(UT_SOURCES
main.cpp
app/app_test.cpp
graphics/engine/lightman_test.cpp
math/func_test.cpp
math/geometry_test.cpp
math/matrix_test.cpp
math/vector_test.cpp
${PLATFORM_TESTS}
)

# Local
include_directories(
.
common
math
${SRC_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)

# System
include_directories(
SYSTEM
${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR}
${SDL_INCLUDE_DIR}
${SDLIMAGE_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR}
${PNG_INCLUDE_DIRS}
${GLEW_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
${OPTIONAL_INCLUDE_DIRS}
${LIBSNDFILE_INCLUDE_DIR}
${CLIPBOARD_INCLUDE_DIR}
)

set(LIBS
gtest
gmock
CBot
clipboard
${SDL_LIBRARY}
${SDLIMAGE_LIBRARY}
${SDLTTF_LIBRARY}
${OPENGL_LIBRARY}
${PNG_LIBRARIES}
${GLEW_LIBRARY}
${Boost_LIBRARIES}
${OPTIONAL_LIBS}
${PLATFORM_LIBS}
${LIBSNDFILE_LIBRARY}
)

add_executable(colobot_ut ${COLOBOT_SOURCES} ${UT_SOURCES} ${OPENAL_SOURCES})
target_link_libraries(colobot_ut ${LIBS})

add_test(colobot_ut ./colobot_ut)

# TODO: change the unit cases to independent automated tests to be included in colobot_ut
add_subdirectory(common)
add_subdirectory(ui)