forked from quesnel/Echll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
258 lines (218 loc) · 9.71 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
project(Echll)
cmake_minimum_required(VERSION 2.8.7)
set(Echll_MAJOR 0)
set(Echll_MINOR 0)
set(Echll_PATCH 99)
set(Echll_VERSION "${Echll_MAJOR}.${Echll_MINOR}.${Echll_PATCH}")
set(Echll_STABLEVERSION "${Echll_MAJOR}.${Echll_MINOR}")
if (CMAKE_BUILD_TYPE STREQUAL "")
set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
endif ()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL "3.5" OR ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER "3.5")
message(STATUS "Clang ${CMAKE_CXX_COMPILER_VERSION} so, remarks system enabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Weverything")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
endif ()
endif ()
if ("${CMAKE_BUILD_TYPE}" EQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" EQUAL "RelWithDebInfo")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb3")
endif ()
endif ()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR})
message(STATUS "checking for a (p)thread library")
find_package(Threads REQUIRED)
if (NOT Threads_FOUND)
message(ERROR " failed to found a (p)thread support.")
else ()
message(STATUS " threads support enabled (${CMAKE_THREAD_LIBS_INIT})")
set(Echll_LINK_LIBRARIES ${Echll_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif ()
message(STATUS "checking for a C++ compiler with MPI support")
find_package(MPI REQUIRED)
if (NOT MPI_CXX_FOUND)
message(ERROR " failed to found a C++ compiler with MPI support.
Please assign MPI_CXX_COMPILER to the MPI wrapper (mpicc, etc.) and
rerun CMake. If this fails, set both MPI_CXX_LIBRARIES and
MPI_CXX_INCLUDE_PATH and rerun CMake.")
else()
message(STATUS " MPI support enabled")
include_directories(${MPI_CXX_INCLUDE_PATH})
set(Echll_LINK_LIBRARIES ${Echll_LINK_LIBRARIES} ${MPI_CXX_LIBRARIES})
endif ()
message(STATUS "checking for Boost headers and libraries")
find_package(Boost 1.55 REQUIRED COMPONENTS mpi serialization)
if (NOT Boost_FOUND)
message(ERROR " failed to found Boost headers or Boost MPI library.
Please install them or assign BOOST_ROOT, BOOST_INCLUDREDIR,
BOOST_LIBRARYDIR and rerun CMake. Read the installed FindBoost in
CMAke's directory too.")
else ()
message(STATUS " Boost found")
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
set(Echll_LINK_LIBRARIES ${Echll_LINK_LIBRARIES} ${Boost_LIBRARIES})
endif ()
### # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## Echll-x.y.pc
#
set(Echll_PKGCONFIG_PREFIX_DIR "${CMAKE_INSTALL_PREFIX}")
set(Echll_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
configure_file(Echll.pc.in ${PROJECT_BINARY_DIR}/Echll-${Echll_STABLEVERSION}.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/Echll-${Echll_STABLEVERSION}.pc
DESTINATION lib/pkgconfig)
### # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## Core library
#
install(DIRECTORY vle
DESTINATION include/Echll-${Echll_STABLEVERSION})
### # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## Core binary
#
add_executable(devsml2 bin/echll.cpp bin/echll.hpp bin/main.cpp
bin/vle1x.hpp bin/writer.cpp bin/writer.hpp)
target_link_libraries(devsml2 ${Echll_LINK_LIBRARIES})
set_target_properties(devsml2 PROPERTIES
COMPILE_FLAGS "${echll_compile_flags}")
### # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## Testing
#
option(WITH_LOGGING "Logging system in echll [default=ON]" ON)
option(WITH_DEBUG "Debugging system in echll [default=ON]" ON)
option(WITH_EXAMPLES "Compile example [default=ON]" ON)
if (WITH_LOGGING)
set(echll_compile_flags "-DENABLE_LOGGING")
endif ()
if (WITH_DEBUG)
set(echll_compile_flags "-DENABLE_DEBUG ${echll_compile_flags}")
endif ()
if (WITH_EXAMPLES)
add_executable(dsde-qss1-fireforrest examples/dsde-qss1-fireforrest.cpp)
target_link_libraries(dsde-qss1-fireforrest
${Echll_LINK_LIBRARIES})
set_target_properties(dsde-qss1-fireforrest PROPERTIES
COMPILE_FLAGS "${echll_compile_flags}")
endif()
message(STATUS "link libraries: ${Echll_LINK_LIBRARIES}")
enable_testing()
message(STATUS "checking for 'catch.hpp'")
find_path(CATCH_INCLUDE_DIR catch.hpp PATHS /usr/include /usr/local/include ENV CATCH_INCLUDE_DIR)
if (CATCH_INCLUDE_DIR)
message(STATUS " found 'catch.hpp' in ${CATCH_INCLUDE_DIR}")
include_directories(${CATCH_INCLUDE_DIR})
add_executable(test_parser_devsml2 tests/parser-devsml2.cpp)
target_link_libraries(test_parser_devsml2 ${Echll_LINK_LIBRARIES})
set_target_properties(test_parser_devsml2 PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_parser_devsml2 COMMAND test_parser_devsml2)
add_executable(test_utils tests/utils.cpp)
target_link_libraries(test_utils ${Echll_LINK_LIBRARIES})
set_target_properties(test_utils PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_utils COMMAND test_utils)
add_executable(test_devs-engine tests/devs-engine.cpp)
target_link_libraries(test_devs-engine ${Echll_LINK_LIBRARIES})
set_target_properties(test_devs-engine PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_devs-engine COMMAND test_devs-engine)
add_executable(test_dsde-engine tests/dsde-engine.cpp)
target_link_libraries(test_dsde-engine ${Echll_LINK_LIBRARIES})
set_target_properties(test_dsde-engine PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_dsde-engine COMMAND test_dsde-engine)
add_executable(test_dsde-qss-engine tests/dsde-qss.cpp)
target_link_libraries(test_dsde-qss-engine ${Echll_LINK_LIBRARIES})
set_target_properties(test_dsde-qss-engine PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_dsde-qss-engine COMMAND test_dsde-qss-engine)
add_executable(test_dtss-engine tests/dtss-engine.cpp)
target_link_libraries(test_dtss-engine ${Echll_LINK_LIBRARIES})
set_target_properties(test_dtss-engine PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_dtss-engine COMMAND test_dtss-engine)
add_executable(test_mpi-synchronous tests/mpi-synchronous.cpp)
target_link_libraries(test_mpi-synchronous ${Echll_LINK_LIBRARIES})
set_target_properties(test_mpi-synchronous PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_mpi-synchronous COMMAND mpirun -np 4
test_mpi-synchronous)
add_executable(test_tree-mpi-synchronous tests/tree.cpp)
target_link_libraries(test_tree-mpi-synchronous ${Echll_LINK_LIBRARIES})
set_target_properties(test_tree-mpi-synchronous PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_tree-mpi-synchronous COMMAND mpirun -np 4
test_tree-mpi-synchronous)
add_executable(test_mpi-timewarp tests/mpi-timewarp.cpp)
target_link_libraries(test_mpi-timewarp ${Echll_LINK_LIBRARIES})
set_target_properties(test_mpi-timewarp PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR="${CMAKE_SOURCE_DIR}/tests"
COMPILE_FLAGS "${echll_compile_flags}")
add_test(NAME test_mpi-timewarp COMMAND mpirun -np 4
test_mpi-timewarp)
else ()
message(STATUS " not found catch.hpp. Unit test disabled")
endif ()
### # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## CPack
#
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Echll - A new kernel for VLE")
set(CPACK_PACKAGE_VENDOR "INRA")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_NAME "Echll")
set(CPACK_PACKAGE_VERSION_MAJOR "${Echll_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${Echll_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${Echll_PATCH}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Echll ${Echll_MAJOR}.${Echll_MINOR}")
set(CPACK_STRIP_FILES "1")
set(CPACK_PACKAGE_CONTACT "Gauthier Quesnel <[email protected]>")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY "1")
if (WIN32)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY "0")
set (CPACK_GENERATOR "ZIP;NSIS")
set (CPACK_SOURCE_GENERATOR "ZIP")
else ()
set (CPACK_GENERATOR "TGZ;DEB;RPM")
set (CPACK_SOURCE_GENERATOR "TGZ;TBZ2")
endif ()
set(CPACK_SOURCE_PACKAGE_FILE_NAME "echll-${Echll_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES
"/\\\\.git/"
"\\\\.#"
"/#"
"/\\\\.gitignore$"
"/\\\\.gitattributes$"
"/build-debug-clang/"
"/build-debug-gcc/"
"/build-release-clang/"
"/build-release-gcc/"
"/build-cross/"
"/coverage/"
)
if (WIN32 AND NOT UNIX)
set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}\\\\echll.ico")
set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}\\\\echll.ico")
set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}\\\\echll.bmp")
set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\echll.exe")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} Echll ${Echll_VERSION}")
set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\https://github.com/quesnel/Echll")
set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\https://github.com/quesnel/Echll")
set(CPACK_NSIS_CONTACT "[email protected]")
set(CPACK_NSIS_MODIFY_PATH ON)
else ()
set(CPACK_STRIP_FILES "bin/echll")
endif ()
INCLUDE(CPack)