forked from socrocket/greenlib
-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
347 lines (257 loc) · 8.19 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
cmake_minimum_required(VERSION 2.8)
project (GREENLIB)
include(FeatureSummary)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# Compile and run the tests
add_custom_target(check COMMAND make compile_test COMMAND make test)
# Compile the test
add_custom_target(compile_test)
enable_testing()
# Test if the compilation/running/diff is good
add_custom_target(run_test COMMAND make test)
# Require SystemC
set(SystemC_USE_STATIC_LIBS ${USE_STATIC_SYSTEMC})
find_package(SystemC 2.3.0)
if(SystemC_FOUND)
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${SystemC_INCLUDE_DIRS})
else()
message( FATAL_ERROR "SystemC library not found." )
endif()
# Require TLM
find_package( TLM )
if(TLM_FOUND)
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${TLM_INCLUDE_DIRS})
else()
message( FATAL_ERROR "TLM library not found." )
endif()
# Require Boost
set(Boost_ADDITIONAL_VERSIONS 1.34 1.34.0 1.34.1)
find_package(Boost)
if(Boost_FOUND)
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Boost library not found.")
endif()
# Require Python
if(DEFINED ENV{PYTHON_ROOT})
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} $ENV{PYTHON_ROOT})
else()
find_package(PythonLibs REQUIRED)
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
endif()
# Require Lua
if(DEFINED ENV{LUA_INCLUDE_DIR} AND DEFINED ENV{LUA_LIBRARIES})
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} $ENV{LUA_INCLUDE_DIR})
link_directories($ENV{LUA_LIBRARIES})
else()
find_package(Lua)
if(LUA_FOUND)
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
link_directories(${LUA_LIBRARIES})
else()
message(FATAL_ERROR "Lua library not found.")
endif()
endif()
# Require SWIG
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
# GreenSocs library
set(GreenSocs_INCLUDE_DIRS "include")
set(GreenSocs_LIBRARY_DIRS ../../../lib)
set(GreenSocs_LIBRARIES pthread)
# License
install(FILES greencontrol/LICENSE
DESTINATION .
)
install(DIRECTORY include/
DESTINATION include
)
# GreenControl
configure_file(
greencontrol/examples/Makefile.defs.in
Makefile.defs
@ONLY
)
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greencontrol/include/)
install(DIRECTORY greencontrol/include/
DESTINATION include
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greencontrol/examples/
DESTINATION examples/greencontrol
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greencontrol/docs/
DESTINATION docs/greencontrol
PATTERN ".svn" EXCLUDE
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.defs
DESTINATION examples/greencontrol
)
# GreenSocket
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greensocket/include/)
install(DIRECTORY greensocket/include/
DESTINATION include
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greensocket/examples/
DESTINATION examples/greensocket
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greensocket/doc/ # TODO: doc or docs?
DESTINATION docs/greensocket
PATTERN ".svn" EXCLUDE
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.defs
DESTINATION examples/greensocket
)
# GsgpSocket
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} gsgpsocket/include/)
install(DIRECTORY gsgpsocket/include/
DESTINATION include
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY gsgpsocket/examples/
DESTINATION examples/gsgpsocket
PATTERN ".svn" EXCLUDE
)
# install(DIRECTORY gsgpsocket/doc/ # TODO: doc or docs?
# DESTINATION docs/gsgpsocket
# PATTERN ".svn" EXCLUDE
# )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.defs
DESTINATION examples/gsgpsocket
)
# GreenRouter
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greenrouter/include/)
install(DIRECTORY greenrouter/include/
DESTINATION include
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greenrouter/examples/
DESTINATION examples/greenrouter
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greenrouter/docs/ # TODO: doc or docs?
DESTINATION docs/greenrouter
PATTERN ".svn" EXCLUDE
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.defs
DESTINATION examples/greenrouter
)
# GreenSignalSocket
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greensignalsocket/include/)
install(DIRECTORY greensignalsocket/include/
DESTINATION include
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greensignalsocket/examples/
DESTINATION examples/greensignalsocket
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greensignalsocket/docs/ # TODO: doc or docs?
DESTINATION docs/greensignalsocket
PATTERN ".svn" EXCLUDE
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.defs
DESTINATION examples/greensignalsocket
)
# Greenreg
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greenreg/include/)
set(GreenSocs_LIB_DIRS ${GreenSocs_LIB_DIRS} ${PROJECT_SOURCE_DIR}/greenreg/lib/libgreenreg.a)
install(DIRECTORY greenreg/include/
DESTINATION include
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greenreg/examples/
DESTINATION examples/greenreg
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY greenreg/doc/ # TODO: doc or docs?
DESTINATION docs/greenreg
PATTERN ".svn" EXCLUDE
)
# Greenmessage
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greenmessage/include/)
install(DIRECTORY greenmessage/include/
DESTINATION include
)
install(DIRECTORY greenmessage/examples/
DESTINATION examples/greenmessage
)
install(DIRECTORY greenmessage/docs/
DESTINATION docs/greenmessage
)
# Greenscript
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greenscript/include/)
install(DIRECTORY greenscript/include/
DESTINATION include
)
install(DIRECTORY greenscript/examples/
DESTINATION examples/greenscript
)
install(DIRECTORY greenscript/docs/
DESTINATION docs/greenscript
)
# Greenmemory
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greenmemory/include/)
install(DIRECTORY greenmemory/include/
DESTINATION include
)
install(DIRECTORY greenmemory/examples/
DESTINATION examples/memory
)
install(DIRECTORY greenmemory/docs/
DESTINATION docs/greenmemory
)
# Greensignalbus
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} greensignalbus/include/)
install(DIRECTORY greensignalbus/include/
DESTINATION include
)
install(DIRECTORY greensignalbus/examples/
DESTINATION examples/signalbus
)
# GreenSerialSocket
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS}
greenserialsocket/include/)
install(DIRECTORY greenserialsocket/include/
DESTINATION include
)
install(DIRECTORY greenserialsocket/docs/
DESTINATION docs/greenserialsocket
)
# Include directory must use first the repository headers!
set(GreenSocs_INCLUDE_DIRS ${GreenSocs_INCLUDE_DIRS} ${EXTERNAL_INCLUDE_DIRS})
# Greensocs Library include directory (for example).
include_directories(${GreenSocs_INCLUDE_DIRS})
link_directories(${GreenSocs_LIB_DIRS})
# CXX flags for example or library compilation.
if(MINGW)
set(CMAKE_CXX_FLAGS "-g -Wall -DSC_INCLUDE_DYNAMIC_PROCESSES -D_REENTRANT -static-libgcc -static-libstdc++")
else(MINGW)
set(CMAKE_CXX_FLAGS "-g -Wall -DSC_INCLUDE_DYNAMIC_PROCESSES -D_REENTRANT -fPIC")
endif(MINGW)
add_subdirectory(greensignalsocket EXCLUDE_FROM_ALL)
add_subdirectory(greenrouter EXCLUDE_FROM_ALL)
add_subdirectory(greenmemory EXCLUDE_FROM_ALL)
add_subdirectory(greensocket EXCLUDE_FROM_ALL)
add_subdirectory(greenmessage EXCLUDE_FROM_ALL)
add_subdirectory(gsgpsocket EXCLUDE_FROM_ALL)
add_subdirectory(greensignalbus EXCLUDE_FROM_ALL)
add_subdirectory(greenserialsocket EXCLUDE_FROM_ALL)
# Compile greenreg library.
add_subdirectory(greenreg)
# Compile greenscript library
if(NOT MINGW)
# FIX ME : add greenscript support with MINGW
add_subdirectory(greenscript)
endif(NOT MINGW)
# build a CPack driven installer package
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/greencontrol/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR "1")
set (CPACK_PACKAGE_VERSION_MINOR "0")
set (CPACK_PACKAGE_VERSION_PATCH "0")
include (CPack)