2
2
# refer to the root source directory of the project as ${MFAST_SOURCE_DIR} and
3
3
# to the root binary directory of the project as ${MFAST_BINARY_DIR}.
4
4
5
- cmake_minimum_required (VERSION 2.8.0 )
6
-
7
-
5
+ cmake_minimum_required (VERSION 2.8.11 )
8
6
project (mFAST CXX )
9
7
10
-
11
- set (EXT_PROJECTS_DIR external_projects )
12
-
13
-
14
- if (CMAKE_BUILD_TYPE STREQUAL "Coverage" )
15
- list (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /cmake" )
16
- include (CodeCoverage )
17
- set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_COVERAGE} )
18
- endif ()
8
+ list (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /cmake" )
19
9
20
10
set (MFAST_MAJOR_VERSION 1 )
21
11
set (MFAST_MINOR_VERSION 3 )
@@ -25,195 +15,45 @@ set(MFAST_SOVERSION ${MFAST_MAJOR_VERSION}.${MFAST_MINOR_VERSION})
25
15
26
16
set (CPACK_PACKAGE_VERSION ${MFAST_VERSION} )
27
17
set (CPACK_PACKAGE_NAME "mfast" )
28
- include (CPack )
29
-
30
18
19
+ include (CPack )
20
+ include (SetInstallPaths )
21
+ include (Emscripten )
22
+ include (SetCXXStandard )
23
+ include (SetCompilerWarnings )
24
+ include (SetupCoverage )
31
25
32
26
# flag to enable building shared/dynamic library
33
27
set (BUILD_SHARED_LIBS OFF CACHE BOOL "build shared/dynamic library" )
34
- # Offer the user the choice of overriding the installation directories
35
- set (INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries" )
36
- set (INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables" )
37
- set (INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files" )
38
- set (INSTALL_DATA_DIR share CACHE PATH "Installation directory for data files" )
39
- # flag to enable/disable building examples and/or tests
40
- set (BUILD_EXAMPLES ON CACHE BOOL "build mFAST examples" )
41
- set (BUILD_TESTS ON CACHE BOOL "build mFAST unit tests" )
42
-
43
- if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten" )
44
- if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
45
- set (CMAKE_INSTALL_PREFIX $ENV{EMSCRIPTEN} /system/local CACHE PATH "default install path" FORCE )
46
- endif ()
47
- set (BUILD_FAST_TYPE_GEN OFF CACHE BOOL "Build fast_type_gen from source" )
48
- else ()
49
- set (BUILD_FAST_TYPE_GEN ON CACHE BOOL "Build fast_type_gen from source" )
50
- endif ()
51
-
52
- # determine default path for CMake files
53
- if (WIN32 AND NOT CYGWIN )
54
- set (DEF_INSTALL_CMAKE_DIR CMake )
55
- else ()
56
- if (${CMAKE_LIBRARY_ARCHITECTURE} ) #support for multiarch debian-based distros, need cmake>=2.8.5
57
- set (DEF_INSTALL_CMAKE_DIR lib/${CMAKE_LIBRARY_ARCHITECTURE}/cmake/mFAST )
58
- else ()
59
- set (DEF_INSTALL_CMAKE_DIR lib/cmake/mFAST )
60
- endif ()
61
- endif ()
62
- set (INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
63
- "Installation directory for CMake files" )
64
-
65
- # Make relative paths absolute (needed later on)
66
- foreach (p IN ITEMS LIB BIN INCLUDE DATA CMAKE )
67
- set (var "INSTALL_${p} _DIR" )
68
- if (NOT IS_ABSOLUTE "${${var} }" )
69
- set ("ABSOLUTE_${var} " "${CMAKE_INSTALL_PREFIX} /${${var} }" )
70
- else ()
71
- set ("ABSOLUTE_${var} " "${${var} }" )
72
- endif ()
73
- endforeach (p )
74
-
75
-
76
- include_directories ("${PROJECT_BINARY_DIR} "
77
- "${PROJECT_SOURCE_DIR} /src" )
78
-
79
- ################################################################################
80
- ## Setting up Boost Library
81
- ################################
82
-
83
28
84
29
find_package (Boost 1.56.0 REQUIRED )
85
-
86
-
87
- if (NOT BUILD_FAST_TYPE_GEN )
88
- find_program (FAST_TYPE_GEN NAMES fast_type_gen )
89
- if ("${FAST_TYPE_GEN} " STREQUAL "FAST_TYPE_GEN-NOTFOUND" )
90
- message (SEND_ERROR "Unable to find the required program fast_type_gen." )
91
- endif ()
92
- endif (NOT BUILD_FAST_TYPE_GEN )
93
-
94
30
include_directories (${Boost_INCLUDE_DIR} )
95
-
96
-
97
- ################################################################################
98
- ## Setting up tinyxml2 Library
99
- ################################
100
-
101
31
include_directories (${CMAKE_CURRENT_SOURCE_DIR} /tinyxml2 )
102
-
103
- ################################################################################
104
-
105
-
106
- # Select flags.
107
- # Initialize CXXFLAGS.
108
- if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" ))
109
- set (CMAKE_CXX_FLAGS "-W -Wall ${CMAKE_CXX_FLAGS} -std=c++11" )
110
- endif ()
111
- if (MSVC )
112
- add_definitions (/D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS )
113
- endif ()
32
+ include_directories ("${PROJECT_SOURCE_DIR} /src" )
114
33
115
34
add_definitions (-DSIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P} )
116
35
117
- if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten" )
118
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-warn-absolute-paths -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s OUTLINING_LIMIT=20000 -s DISABLE_EXCEPTION_CATCHING=0" )
119
- endif ()
120
36
# variables to be used later
121
37
set (MFAST_SHARED_LIBRARIES CACHE INTERNAL "" )
122
38
set (MFAST_STATIC_LIBRARIES CACHE INTERNAL "" )
123
39
set (MFAST_DYNAMIC_COMPONENTS CACHE INTERNAL "" )
124
40
set (MFAST_STATIC_COMPONENTS CACHE INTERNAL "" )
125
41
126
- ############################################################################
127
- # Setting up RPATH
128
- #
129
-
130
- # add the automatically determined parts of the RPATH
131
- # which point to directories outside the build tree to the install RPATH
132
- SET (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
133
-
134
-
135
- ############################################################################
136
-
42
+ set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
137
43
138
44
add_subdirectory (src )
45
+ include (FastTypeGenTarget )
139
46
140
- link_directories ("${PROJECT_BINARY_DIR} /src" )
141
-
142
- #============================================================
143
- # Install fast_type_gen batch file to set up the PATH environment
144
- # variable for using BOOST libraries
145
-
146
- # if(MSVC_IDE)
147
- # configure_file(invoke.bat.in
148
- # "${PROJECT_BINARY_DIR}/bin/invoke.bat"
149
- # @ONLY)
150
- # endif(MSVC_IDE)
151
-
152
- #============================================================
153
- # FASTTYPEGEN_TARGET (public function)
154
- #============================================================
155
- #
156
-
157
- function (FASTTYPEGEN_TARGET Name )
158
- set (FASTTYPEGEN_TARGET_usage "FASTTYPEGEN_TARGET(<Name> Input1 Input2 ...]" PARENT_SCOPE )
159
-
160
- set ("FASTTYPEGEN_${Name} _OUTPUTS" )
161
- set (INPUTS )
162
-
163
- foreach (input IN LISTS ARGN )
164
- get_filename_component (noext_name "${input} " NAME_WE )
165
- list (APPEND "FASTTYPEGEN_${Name} _OUTPUTS"
166
- "${CMAKE_CURRENT_BINARY_DIR} /${noext_name} .cpp"
167
- "${CMAKE_CURRENT_BINARY_DIR} /${noext_name} .h"
168
- "${CMAKE_CURRENT_BINARY_DIR} /${noext_name} .inl" )
169
- list (APPEND INPUTS "${CMAKE_CURRENT_SOURCE_DIR} /${input} " )
170
- endforeach (input )
171
-
172
- if (BUILD_FAST_TYPE_GEN )
173
- set (FAST_TYPE_GEN fast_type_gen )
174
- set (FAST_TYPE_GEN_TARGET fast_type_gen )
175
- else (BUILD_FAST_TYPE_GEN )
176
- set (FAST_TYPE_GEN_TARGET )
177
- endif (BUILD_FAST_TYPE_GEN )
178
-
179
- add_custom_command (
180
- OUTPUT ${FASTTYPEGEN_${Name}_OUTPUTS}
181
- COMMAND "${FAST_TYPE_GEN} " -- ${INPUTS}
182
- DEPENDS ${ARGN} ${FAST_TYPE_GEN_TARGET}
183
- COMMENT "[FASTTYPEGEN][${Name} ] Building Fast Application Types"
184
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} "
185
- VERBATIM )
186
-
187
- include_directories (BEFORE "${CMAKE_CURRENT_BINARY_DIR} " )
188
-
189
- set ("FASTTYPEGEN_${Name} _OUTPUTS" "${FASTTYPEGEN_${Name} _OUTPUTS}" PARENT_SCOPE )
190
- set ("FASTTYPEGEN_${Name} _DEFINED" TRUE PARENT_SCOPE )
191
- set ("FASTTYPEGEN_${Name} _INPUTS" "${ARGN} " PARENT_SCOPE )
192
- endfunction (FASTTYPEGEN_TARGET )
193
-
194
-
195
-
196
- # Includes Catch in the project:
197
- #add_subdirectory(${EXT_PROJECTS_DIR}/catch)
198
- include_directories (${CMAKE_CURRENT_SOURCE_DIR} /catch/include ${COMMON_INCLUDES} )
199
-
200
- if (BUILD_TESTS )
201
- enable_testing ()
202
- add_subdirectory (tests )
203
- endif (BUILD_TESTS )
47
+ enable_testing ()
48
+ add_subdirectory (tests )
204
49
205
50
if (BUILD_SHARED_LIBS )
206
51
set (MFAST_LIBRARIES "${MFAST_SHARED_LIBRARIES} " )
207
- if ("${CMAKE_VERSION} " VERSION_LESS "2.8.12" )
208
- add_definitions (-DMFAST_DYN_LINK )
209
- endif ("${CMAKE_VERSION} " VERSION_LESS "2.8.12" )
210
52
else (BUILD_SHARED_LIBS )
211
53
set (MFAST_LIBRARIES "${MFAST_STATIC_LIBRARIES} " )
212
54
endif (BUILD_SHARED_LIBS )
213
55
214
- if (BUILD_EXAMPLES )
215
- add_subdirectory (examples )
216
- endif (BUILD_EXAMPLES )
56
+ add_subdirectory (examples )
217
57
218
58
219
59
# Setting up dist target
@@ -224,61 +64,13 @@ add_custom_target(dist
224
64
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
225
65
| bzip2 > ${CMAKE_BINARY_DIR} /${ARCHIVE_NAME}.tar.bz2
226
66
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} )
67
+
227
68
228
- # Provide mfast-config.cmake and mfast-config.version to be used by other applications
229
- # ===============================
230
-
231
- export (PACKAGE ${CMAKE_PROJECT_NAME} )
232
-
233
- if (BUILD_FAST_TYPE_GEN )
234
- export (TARGETS fast_type_gen ${MFAST_SHARED_LIBRARIES} ${MFAST_STATIC_LIBRARIES}
235
- FILE "${PROJECT_BINARY_DIR} /mFASTTargets.cmake" )
236
- else (BUILD_FAST_TYPE_GEN )
237
- export (TARGETS ${MFAST_SHARED_LIBRARIES} ${MFAST_STATIC_LIBRARIES}
238
- FILE "${PROJECT_BINARY_DIR} /mFASTTargets.cmake" )
239
- set (FAST_TYPE_GEN_INSTALL_LOCATION ${FAST_TYPE_GEN} )
240
- endif (BUILD_FAST_TYPE_GEN )
241
-
242
- # Create the mFASTConfig.cmake for the build tree
243
- set (CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR} /src" )
244
- configure_file (mFASTConfig.cmake.in
245
- "${PROJECT_BINARY_DIR} /mFASTConfig.cmake"
246
- @ONLY )
247
-
248
- # Create the mFASTConfig.cmake for the install tree
249
- file (RELATIVE_PATH REL_INCLUDE_DIR "${ABSOLUTE_INSTALL_CMAKE_DIR} " "${ABSOLUTE_INSTALL_INCLUDE_DIR} " )
250
- set (CONF_INCLUDE_DIRS "\$ {MFAST_CMAKE_DIR}/${REL_INCLUDE_DIR} " )
251
- configure_file (mFASTConfig.cmake.in
252
- "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY} /mFASTConfig.cmake"
253
- @ONLY )
254
-
255
- # Create the mFASTConfigVersion.cmake for both
256
- configure_file (mFASTConfigVersion.cmake.in
257
- "${PROJECT_BINARY_DIR} /mFASTConfigVersion.cmake"
258
- @ONLY )
259
-
260
- # Install the mFASTConfig.cmake and mFASTConfigVersion.cmake
261
- install (FILES
262
- "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY} /mFASTConfig.cmake"
263
- "${PROJECT_BINARY_DIR} /mFASTConfigVersion.cmake"
264
- DESTINATION "${INSTALL_CMAKE_DIR} " COMPONENT dev )
265
-
266
- # Install the export set for use with the install-tree
267
- install (EXPORT mFASTTargets DESTINATION "${INSTALL_CMAKE_DIR} " COMPONENT dev )
69
+ include (GenProjectConfig )
268
70
269
71
file (GLOB schema_files "${CMAKE_CURRENT_SOURCE_DIR} /schema/*.*" )
270
-
271
72
install (FILES
272
73
${schema_files}
273
74
DESTINATION ${INSTALL_DATA_DIR} /mfast )
274
75
275
76
276
- if (CMAKE_BUILD_TYPE STREQUAL "Coverage" )
277
- SETUP_TARGET_FOR_COVERAGE (
278
- coverage # Name for custom target.
279
- mfast_test # Name of the test driver executable that runs the tests.
280
- # NOTE! This should always have a ZERO as exit code
281
- # otherwise the coverage generation will not complete.
282
- coverage # Name of output directory.
283
- )
284
- endif ()
0 commit comments