forked from RoboCup-SSL/grSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
249 lines (220 loc) · 6.95 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
cmake_minimum_required(VERSION 2.8)
## Project branding, version and package mantainer
project(grSim)
set(VERSION "1.0.0a2")
#set(VENDOR "Parsian")
set(MAINTAINER "Mani Monajjemi <[email protected]>")
# some utils and helper vars
string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_LOWER)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
include(${PROJECT_SOURCE_DIR}/cmake/Utils.cmake)
standard_config()
standard_paths(${PROJECT_SOURCE_DIR} bin lib)
# definitions for knowing the OS from the code
if(MSVC)
add_definitions(-DHAVE_MSVC)
endif()
if(WIN32)
add_definitions(-DHAVE_WINDOWS)
endif()
if(UNIX)
add_definitions(-DHAVE_UNIX)
if(APPLE)
add_definitions(-DHAVE_MACOSX)
else()
#TODO: fix this, say we have FreeBSD, that's not linux
add_definitions(-DHAVE_LINUX)
endif()
endif()
# set explicitly the c++ standard to use
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# add src dir to included directories
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/include/net)
include_directories(${PROJECT_SOURCE_DIR}/include/physics)
## Handling depenendcies
# we will append all libs to this var
set(libs)
# OpenGL
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
list(APPEND libs ${OPENGL_LIBRARIES})
#find_package(GLUT REQUIRED)
#include_directories(${GLUT_INCLUDE_DIR})
# Qt
set(QT_USE_QTNETWORK true)
set(QT_USE_QTOPENGL true)
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
list(APPEND libs ${QT_LIBRARIES})
# ODE
find_package(ODE REQUIRED)
include_directories(${ODE_INCLUDE_DIRS})
list(APPEND libs ${ODE_LIBRARIES})
#TODO: make this an option
option(DOUBLE_PRECISION "Use double precision? If not single precision will be used." ON)
if(DOUBLE_PRECISION)
if(APPLE)
add_definitions(-DdIDEDOUBLE)
else()
add_definitions(-DdDOUBLE)
endif()
else()
if(APPLE)
add_definitions(-DdIDESINGLE)
else()
add_definitions(-DdSINGLE)
endif()
endif()
# VarTypes
find_package(VarTypes REQUIRED)
include_directories(${VARTYPES_INCLUDE_DIRS})
list(APPEND libs ${VARTYPES_LIBRARIES})
# Protobuf
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
list(APPEND libs ${PROTOBUF_LIBRARIES})
protobuf_generate_cpp(PROTO_CPP PROTO_H
src/proto/messages_robocup_ssl_detection.proto
src/proto/messages_robocup_ssl_geometry.proto
src/proto/messages_robocup_ssl_wrapper.proto
src/proto/messages_robocup_ssl_refbox_log.proto
src/proto/grSim_Replacement.proto
src/proto/grSim_Commands.proto
src/proto/grSim_Packet.proto
)
qt4_add_resources(RESOURCES
resources/textures.qrc
)
set(RESOURCES
${RESOURCES}
resources/grsim.rc
)
set(SOURCES
src/main.cpp
src/mainwindow.cpp
src/glwidget.cpp
src/graphics.cpp
src/physics/pworld.cpp
src/physics/pobject.cpp
src/physics/pball.cpp
src/physics/pground.cpp
src/physics/pfixedbox.cpp
src/physics/pcylinder.cpp
src/physics/pbox.cpp
src/physics/pray.cpp
src/net/robocup_ssl_server.cpp
src/net/robocup_ssl_client.cpp
src/sslworld.cpp
src/robot.cpp
src/configwidget.cpp
src/statuswidget.cpp
src/logger.cpp
src/robotwidget.cpp
src/getpositionwidget.cpp
)
set(HEADERS
include/mainwindow.h
include/glwidget.h
include/graphics.h
include/physics/pworld.h
include/physics/pobject.h
include/physics/pball.h
include/physics/pground.h
include/physics/pfixedbox.h
include/physics/pcylinder.h
include/physics/pbox.h
include/physics/pray.h
include/net/robocup_ssl_server.h
include/net/robocup_ssl_client.h
include/sslworld.h
include/robot.h
include/configwidget.h
include/statuswidget.h
include/logger.h
include/robotwidget.h
include/getpositionwidget.h
include/common.h
include/config.h
)
# files to be compiled
set(srcs
${CONFIG_FILES}
${PROTO_CPP}
${PROTO_H}
${RESOURCES}
${HEADERS}
${SOURCES}
)
file(GLOB CONFIG_FILES "config/*.ini")
set_source_files_properties(${CONFIG_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "config")
if(APPLE)
set(app ${CMAKE_PROJECT_NAME})
add_executable(${app} MACOSX_BUNDLE ${srcs})
target_link_libraries(${app} ${libs})
install(TARGETS ${app} DESTINATION .)
set(MACOSX_BUNDLE_ICON_FILE "${PROJECT_SOURCE_DIR}/resources/icons/grsim.icns")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION})
set(MACOSX_BUNDLE_VERSION ${VERSION})
set(MACOSX_BUNDLE_LONG_VERSION_STRING "Version ${VERSION}")
set(BUNDLE_APP ${PROJECT_SOURCE_DIR}/bin/${app}.app)
install(
CODE "
include(BundleUtilities)
fixup_bundle(\"${BUNDLE_APP}\" \"\" \"/opt/local/lib;/usr/local/lib\")"
COMPONENT Runtime)
set(CPACK_GENERATOR "DragNDrop" "TGZ")
elseif(WIN32)
set(app ${CMAKE_PROJECT_NAME})
add_executable(${app} WIN32 ${srcs})
target_link_libraries(${app} ${libs})
install(TARGETS ${app} DESTINATION bin)
install(DIRECTORY config DESTINATION .)
install(DIRECTORY bin DESTINATION .
FILES_MATCHING PATTERN "*.dll")
set(CPACK_PACKAGE_EXECUTABLES ${app} ${app})
else()
set(app ${CMAKE_PROJECT_NAME_LOWER})
add_executable(${app} ${srcs})
target_link_libraries(${app} ${libs})
install(TARGETS ${app} DESTINATION bin)
install(DIRECTORY config DESTINATION share/${app})
install(FILES resources/grsim.desktop DESTINATION share/applications)
install(FILES resources/icons/grsim.svg DESTINATION share/icons/hicolor/scalable/apps)
endif()
option(BUILD_CLIENTS "Choose this option if you want to build the example Qt client." ON)
if(BUILD_CLIENTS)
add_subdirectory(clients/qt)
endif()
file(COPY README.md LICENSE.md DESTINATION ${CMAKE_BINARY_DIR})
file(RENAME ${CMAKE_BINARY_DIR}/README.md ${CMAKE_BINARY_DIR}/README.txt)
file(RENAME ${CMAKE_BINARY_DIR}/LICENSE.md ${CMAKE_BINARY_DIR}/LICENSE.txt)
## Packaging
if(UNIX)
execute_process(COMMAND uname -p OUTPUT_VARIABLE ARCH)
string(STRIP ${ARCH} ARCH)
if(APPLE)
set(ARCH "osx-universal")
endif()
elseif(WIN32)
set(ARCH "win32")
set(CPACK_GENERATOR ZIP NSIS)
endif()
set(CPACK_OUTPUT_FILE_PREFIX ${PROJECT_SOURCE_DIR}/dist)
set(CPACK_PACKAGE_CONTACT ${MAINTAINER})
if(VENDOR)
set(CPACK_PACKAGE_VENDOR ${VENDOR})
string(TOLOWER ${CPACK_PACKAGE_VENDOR} FLAVOR)
endif()
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README.txt")
#set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/WELCOME.txt")
set(CPACK_PACKAGE_VERSION ${VERSION})
# Debian based specific
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libode1 (>=0.11), vartypes (>=0.7.0), libqt4-network (>=4.8.0), libqt4-core, libqt4-gui, libqt4-opengl")
if(FLAVOR)
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME_LOWER}_${CPACK_PACKAGE_VERSION}-${FLAVOR}_${ARCH}")
else()
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME_LOWER}_${CPACK_PACKAGE_VERSION}_${ARCH}")
endif()
include(CPack)