This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
361 lines (293 loc) · 11.9 KB
/
CMakeLists.txt
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# ----------------------------------------------------------------------------
# prepare
cmake_minimum_required(VERSION 2.8.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# ============================================================================
# ----------------------------------------------------------------------------
# configure the project
project(april)
set(april_MAJOR_VERSION 1)
set(april_MINOR_VERSION 0)
set(april_PATCH_VERSION 0)
set(april_VERSION
${april_MAJOR_VERSION}.${april_MINOR_VERSION}.${april_PATCH_VERSION})
include_directories(
"${PROJECT_SOURCE_DIR}"
"${PROJECT_BINARY_DIR}")
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/april/april_config.h.in ${PROJECT_BINARY_DIR}/april/april_config.h )
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/april/april_version.h.in ${PROJECT_BINARY_DIR}/april/april_version.h )
set(CMAKE_DEBUG_POSTFIX "_debug")
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# ============================================================================
# ----------------------------------------------------------------------------
# external libraries
find_package(LibBBB REQUIRED)
include_directories(${LIBBBB_INCLUDE_DIRS})
set(LIBS ${LIBS} ${LIBBBB_LIBRARIES})
find_package(ArgTable REQUIRED)
include_directories(${ARGTABLE_INCLUDE_DIRS})
set(LIBS ${LIBS} ${ARGTABLE_LIBRARIES})
add_subdirectory(googletest)
include_directories(googletest/include)
find_package(CmdTest)
# ============================================================================
# ----------------------------------------------------------------------------
# Qt related packages
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
# ============================================================================
# ----------------------------------------------------------------------------
# core library
add_library(april-core SHARED
april/aprillibrary.cc
april/april_debug.cc
april/logic/world.cc
april/logic/uniqueid.cc
april/logic/actor.cc
april/logic/factory.cc
april/logic/component.cc
april/logic/dna.cc
april/logic/dnaview.cc
april/logic/sensorfactory.cc
april/logic/eventfactory.cc
april/logic/actuatorfactory.cc
april/logic/actorfactory.cc
april/logic/sensor.cc
april/logic/reflex.cc
april/logic/brain.cc
april/logic/actuator.cc
april/logic/brainfactory.cc
april/logic/reflexfactory.cc
april/logic/actorcomp.cc
april/logic/eventline.cc
april/logic/eventdata.cc
april/logic/director.cc
april/logic/eventsource.cc
april/plugins/aprilplugininterf.cc
april/logic/worldfactory.cc
april/logic/genericactorfactory.cc
april/logic/aoutput.cc
)
qt5_use_modules(april-core Core)
set_target_properties(april-core PROPERTIES COMPILE_DEFINITIONS APRIL_LIBRARY )
target_link_libraries(april-core ${LIBS})
# ============================================================================
# ----------------------------------------------------------------------------
# command library
add_library(april-cmd SHARED
april/cmd/commandmap.cc
april/cmd/aprilmodule.cc
april/cmd/apriltokenizer.cc
april/cmd/modules/amodapril.cc
april/cmd/modules/amoddna.cc
april/cmd/modules/amodplugins.cc
april/cmd/modules/amodworld.cc
april/cmd/modules/amodid.cc
april/cmd/modules/amodactor.cc
april/cmd/modules/amodsensor.cc
april/cmd/modules/amodreflex.cc
april/cmd/modules/amodbrain.cc
april/cmd/modules/amodactuator.cc
april/cmd/modules/amodevents.cc
)
qt5_use_modules(april-cmd Core)
set_target_properties(april-cmd PROPERTIES COMPILE_DEFINITIONS APRIL_LIBRARY )
target_link_libraries(april-cmd april-core ${LIBS})
# ============================================================================
# ----------------------------------------------------------------------------
# graphical library library
add_library(april-gui SHARED
april/gui/worlds/worldqscene.cc
april/gui/worlds/wqstauto.cc
april/gui/actors/agui.cc
april/gui/actors/agui3d.cc
april/gui/actors/agui2d.cc
april/gui/geometry/p3d.cc
april/gui/geometry/p2d.cc
april/gui/geometry/abox3d.cc
april/gui/geometry/abox2d.cc
april/gui/actors/aqscene.cc
)
qt5_use_modules(april-gui Core Widgets)
set_target_properties(april-gui PROPERTIES COMPILE_DEFINITIONS APRIL_LIBRARY,APRIL_GUI_LIBRARY )
target_link_libraries(april-gui april-cmd april-core ${LIBS})
# ============================================================================
# ----------------------------------------------------------------------------
# abstracta utility
qt5_add_resources(abstracta_res april/abstracta/abstracta.qrc)
add_executable(abstracta
april/abstracta/abstracta-main.cc
april/abstracta/abstractapril.cc
${abstracta_res}
)
target_link_libraries(abstracta ${LIBS} april-core april-cmd)
qt5_use_modules(abstracta Core Widgets)
# ============================================================================
# ----------------------------------------------------------------------------
# AprilDream GUI application
qt5_wrap_ui(AprilDream_UIS
april/AprilDream/gui/mw.ui
april/AprilDream/gui/newworlddlg.ui
april/AprilDream/gui/pluginsdlg.ui
april/AprilDream/gui/dnaeditordlg.ui
april/AprilDream/gui/newactordlg.ui
april/AprilDream/gui/cmdlog.ui
)
qt5_add_resources(AprilDream_res april/AprilDream/aprildream.qrc)
add_executable(AprilDream
april/AprilDream/gui/mw.cc
april/AprilDream/aprildream-main.cc
april/AprilDream/propertybrowser/qtvariantproperty.cpp
april/AprilDream/propertybrowser/qttreepropertybrowser.cpp
april/AprilDream/propertybrowser/qtpropertymanager.cpp
april/AprilDream/propertybrowser/qtpropertybrowserutils.cpp
april/AprilDream/propertybrowser/qtpropertybrowser.cpp
april/AprilDream/propertybrowser/qtgroupboxpropertybrowser.cpp
april/AprilDream/propertybrowser/qteditorfactory.cpp
april/AprilDream/propertybrowser/qtbuttonpropertybrowser.cpp
april/AprilDream/gui/dock.cc
april/AprilDream/gui/dockworld.cc
april/AprilDream/gui/docktree.cc
april/AprilDream/gui/dockids.cc
april/AprilDream/gui/dockcrtsel.cc
april/AprilDream/gui/sceneviewer.cc
april/AprilDream/gui/newworlddlg.cc
april/AprilDream/gui/pluginsdlg.cc
april/AprilDream/gui/dnaeditordlg.cc
april/AprilDream/gui/newactordlg.cc
april/AprilDream/gui/cmdlog.cc
april/AprilDream/gui/dockcmdlog.cc
${AprilDream_res}
${AprilDream_UIS}
)
target_link_libraries(AprilDream ${LIBS} april-gui april-cmd april-core )
qt5_use_modules(AprilDream Core Widgets)
set_target_properties(AprilDream PROPERTIES COMPILE_DEFINITIONS QT_DISABLE_DEPRECATED_BEFORE=0 )
# ============================================================================
# ----------------------------------------------------------------------------
# internal tests
add_executable(internal-test
april/tests/aprillibrary.cc
april/tests/world.cc
april/tests/dna.cc
april/tests/actor.cc
april/tests/actuator.cc
april/tests/sensor.cc
april/tests/reflex.cc
april/tests/event.cc
april/tests/brain.cc
april/tests/simplerun.cpp
april/tests/eventline.cc
april/tests/plugins.cc
april/tests/saveload.cc
april/tests/saveload2.cc
april/tests/apriltokenizer.cc
)
target_link_libraries(internal-test ${LIBS} april-cmd april-core gtest_main gtest )
qt5_use_modules(internal-test Core Widgets)
set_target_properties(internal-test PROPERTIES COMPILE_DEFINITIONS APRIL_INTERNAL_TESTS=1 )
# ============================================================================
# ----------------------------------------------------------------------------
# install
install(TARGETS abstracta AprilDream april-core april-cmd april-gui
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
IF (WIN32)
function(installQt func_list)
STRING(REGEX REPLACE "/lib/cmake/Qt5Core" "/bin/THELIB.dll"
QtBin "${Qt5Core_DIR}")
FOREACH (binfile ${func_list})
STRING(REGEX REPLACE "THELIB" ${binfile}
QtBin_File "${QtBin}")
INSTALL(FILES "${QtBin_File}" DESTINATION bin)
ENDFOREACH(binfile)
endfunction(installQt)
set(QtInstallList
"Qt5Core"
"Qt5Widgets"
"Qt5Gui"
"libgcc_s_sjlj-1"
"libstdc++-6"
"libwinpthread-1"
"icudt49"
"icuin49"
"icuuc49"
"libGLESv2"
"D3DCompiler_43"
)
installQt( "${QtInstallList}" )
INSTALL(FILES "${LIBBBB_LIBRARIES}" DESTINATION bin)
ENDIF (WIN32)
# ============================================================================
# ----------------------------------------------------------------------------
# Packing
set(CPACK_PACKAGE_VERSION_MAJOR "${april_MAJOR_VERSION}" )
set(CPACK_PACKAGE_VERSION_MINOR "${april_MINOR_VERSION}" )
set(CPACK_PACKAGE_VERSION_PATCH "${april_PATCH_VERSION}" )
set(CPACK_PACKAGE_DESCRIPTION "Package to run worlds")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package to run worlds")
set(CPACK_PACKAGE_CONTACT "Nicu Tofan [email protected]")
SET(CPACK_PACKAGE_VENDOR "Nicu Tofan")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "April-${april_MAJOR_VERSION}.${april_MINOR_VERSION}")
SET(CPACK_PACKAGE_EXECUTABLES "AprilDream" "AprilDream")
IF (APPLE)
SET(CPACK_BINARY_DRAGNDROP ON)
ENDIF (APPLE)
IF (WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
# SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\AprilDream.exe")
SET(CPACK_NSIS_DISPLAY_NAME "April")
# SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.my-project-home-page.org")
# SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com")
SET(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX)
SET(CPACK_STRIP_FILES "bin/AprilDream")
SET(CPACK_SOURCE_STRIP_FILES "")
ENDIF(WIN32 AND NOT UNIX)
IF (UNIX)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqtgui5")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst")
ENDIF (UNIX)
include(CPack)
# ============================================================================
# ----------------------------------------------------------------------------
# Testing
IF (WIN32)
function(copyQt func_list)
STRING(REGEX REPLACE "/lib/cmake/Qt5Core" "/bin/THELIB.dll"
QtBin "${Qt5Core_DIR}")
FOREACH (binfile ${func_list})
STRING(REGEX REPLACE "THELIB" ${binfile}
QtBin_File "${QtBin}")
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${QtBin_File}" "${PROJECT_BINARY_DIR}/${binfile}.dll"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
ENDFOREACH(binfile)
endfunction(copyQt)
copyQt( "${QtInstallList}" )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LIBBBB_LIBRARIES}" "${PROJECT_BINARY_DIR}/libbbb.dll")
ENDIF (WIN32)
enable_testing()
add_test( NAME Internal
COMMAND internal-test )
IF (CMDTEST_FOUND)
execute_process(COMMAND ${CMDTEST_PROGRAM} "${CMAKE_SOURCE_DIR}/april/tests/cmd-test-abstracta/all-tests.txt"
WORKIND_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_test( NAME CmdTest
COMMAND ${CMDTEST_PROGRAM} "${CMAKE_SOURCE_DIR}/april/tests/cmd-test-abstracta/all-tests.txt"
)
ENDIF (CMDTEST_FOUND)
# ============================================================================