forked from MASD-Project/dogen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
376 lines (329 loc) · 10.6 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# -*- mode: cmake; tab-width: 4; indent-tabs-mode: nil -*-
#
# Copyright (C) 2012 Kitanda <info@kitanda.co.uk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# avoid nonsense warning on cygwin
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
# enable ctest support
enable_testing()
# prohibit in-source builds: i.e. users are not allowed to perform
# builds either in the source root directory or in any of its
# sub-directories.
string(REGEX MATCH "^${CMAKE_SOURCE_DIR}" source_build ${CMAKE_BINARY_DIR})
if (source_build)
message(FATAL_ERROR "Attempting to build in the source directory."
"Please create a separate build directory and invoke cmake from there.")
endif()
project(dogen)
# add our own modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/build/cmake)
# options
option(WITH_DEBUG "Build the project with debug symbols" off)
option(WITH_DOXYGEN "Build the project documentation" off)
option(WITH_PRESENTATIONS "Build all presentations. Requires pdflatex and beamer." off)
option(WITH_PROFILING "Build the project with profiling support" off)
option(WITH_MINIMAL_PACKAGING "Package just the main application" off)
option(WITH_JSON_VALIDATION "Adds JSON validation targets. Requires jq." on)
#
# check for dependencies
#
# threads
find_package(Threads REQUIRED)
# boost
if (DEFINED ENV{PFH_LOCATION})
set(BOOST_ROOT "$ENV{PFH_LOCATION}")
set(Boost_NO_SYSTEM_PATHS "ON")
include_directories(SYSTEM $ENV{PFH_LOCATION}/include)
endif()
# note: we should be able to compile with boost 1.54, but due to some
# strange behaviour with boost::variant, we can't. see this email for
# details: http://lists.boost.org/boost-users/2013/08/79650.php
add_definitions(-DBOOST_ALL_DYN_LINK)
find_package(Boost 1.55 REQUIRED COMPONENTS
system
chrono
serialization
date_time
thread
log
filesystem
program_options
iostreams
)
if(Boost_FOUND)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
endif()
# libxml
find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
set(LIBS ${LIBS} ${LIBXML2_LIBRARY_DIR})
endif()
# odb
find_package(ODB)
if(ODB_FOUND)
message(STATUS "Found odb...")
include_directories(SYSTEM ${ODB_INCLUDE_DIR})
set(LIBS ${LIBS} ${LIBXML2_LIBRARY_DIR})
else()
message(STATUS "odb not found.")
endif()
# eos
if(WIN32)
set(EOS_FOUND "EOS_FOUND-NOTFOUND")
message(STATUS "eos disabled for WIN32 due to compilation errors.")
elseif(APPLE)
set(EOS_FOUND "EOS_FOUND-NOTFOUND")
message(STATUS "eos disabled for APPLE due to linker errors.")
elseif(UNIX)
find_package(EOS)
if(EOS_FOUND)
message(STATUS "Found eos...")
include_directories(SYSTEM ${EOS_INCLUDE_DIR})
else()
message(STATUS "eos not found.")
endif()
endif()
# packaging type
if(WITH_MINIMAL_PACKAGING)
message(STATUS "Packaging just the main application")
else()
message(STATUS "Packaging everything main application")
endif()
# profiling
if(WITH_PROFILING)
if(WITH_DEBUG)
message(STATUS "Profiling enabled...")
else()
message(STATUS "Ignoring attempt to enable profiling without debug...")
set(WITH_PROFILING off)
endif()
else()
message(STATUS "Profiling NOT enabled...")
endif()
# WinSock (for database)
if (WIN32)
find_library(WSOCK_LIB NAMES wsock32 DOC "The winsock library")
if(WSOCK_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES wsock32)
else()
message(FATAL_ERROR "winsock not found.")
endif()
find_library(WSOCK2_LIB NAMES ws2_32 DOC "The winsock 2 library")
if(WSOCK2_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ws2_32)
else()
message(FATAL_ERROR "winsock2 not found.")
endif()
find_library(MSWSOCK_LIB NAMES mswsock DOC "The winsock 2 library")
if(MSWSOCK_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES mswsock)
else()
message(FATAL_ERROR "mswsock not found.")
endif()
endif()
#
# Test models
#
set(all_dia_test_models "")
file(GLOB_RECURSE all_dia_test_models ABSOLUTE
"${CMAKE_SOURCE_DIR}/test_data/dia_sml/input/*.dia")
#
# setup git
#
find_program(GIT_COMMAND NAMES git)
if(NOT DEFINED GIT_COMMAND)
message(FATAL_ERROR "git not found.")
endif()
message(STATUS "Found git (${GIT_COMMAND})...")
#
# setup pdflatex
#
find_program(PDFLATEX_COMMAND NAMES pdflatex)
if(NOT DEFINED PDFLATEX_COMMAND)
message(STATUS "pdflatex not found, disabling presentations.")
set(WITH_PRESENTATIONS "off")
else()
message(STATUS "Found pdflatex (${PDFLATEX_COMMAND})...")
endif()
if(WITH_PRESENTATION)
message(STATUS "Building latex presentations...")
else()
message(STATUS "NOT building latex presentations...")
endif()
#
# setup jq, for JSON validation.
#
find_program(JQ_COMMAND NAMES jq)
if(NOT DEFINED JQ_COMMAND)
message(STATUS "jq not found, disabling JSON validation.")
set(WITH_JSON_VALIDATION "off")
else()
message(STATUS "Found jq (${JQ_COMMAND})...")
add_custom_target(validate_all_json)
endif()
# hash of the top commit
execute_process(COMMAND ${GIT_COMMAND} rev-list -n 1 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
ERROR_VARIABLE git_error
OUTPUT_VARIABLE CURRENT_GIT_COMMIT
RESULT_VARIABLE ret_var
OUTPUT_STRIP_TRAILING_WHITESPACE)
# commit count
execute_process(
COMMAND ${GIT_COMMAND} rev-list master
COMMAND wc -l
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
ERROR_VARIABLE git_error
OUTPUT_VARIABLE GIT_COMMIT_COUNT
RESULT_VARIABLE ret_var
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(STRIP ${GIT_COMMIT_COUNT} GIT_COMMIT_COUNT)
#
# useful vars
#
# site (for ctest)
site_name(DOGEN_SITE)
# staging directory
set(stage_dir ${CMAKE_BINARY_DIR}/stage)
set(stage_bin_dir ${stage_dir}/bin)
set(stage_pkg_dir ${stage_dir}/pkg)
set(stage_lib_dir ${stage_dir}/lib)
set(stage_inc_dir ${stage_dir}/include)
set(stage_test_data_dir ${stage_dir}/test_data)
set(stage_doc_dir ${stage_dir}/doc)
set(stage_doxygen_dir ${stage_dir}/doxygen)
# ensure cmake dumps binaries in the right places
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${stage_bin_dir})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${stage_bin_dir})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${stage_bin_dir})
# version info
set(DOGEN_MAJOR_VERSION 0)
set(DOGEN_MINOR_VERSION 70)
set(DOGEN_PATCH_VERSION ${GIT_COMMIT_COUNT})
set(DOGEN_VERSION "${DOGEN_MAJOR_VERSION}")
set(DOGEN_VERSION "${DOGEN_VERSION}.${DOGEN_MINOR_VERSION}")
set(DOGEN_VERSION "${DOGEN_VERSION}.${DOGEN_PATCH_VERSION}")
if(WITH_DEBUG)
message(STATUS "Building WITH DEBUG symbols...")
set(DOGEN_VERSION "${DOGEN_VERSION}d")
else()
message(STATUS "Building WITHOUT DEBUG symbols...")
endif()
message(STATUS "Product version: ${DOGEN_VERSION}")
#
# doxygen
#
if (WITH_DOXYGEN)
find_package(Doxygen)
if(DOXYGEN_FOUND)
message(STATUS "Doxygen enabled - generating API documentation")
# input directories (used in doxygen template)
set(DOGEN_CPP_CODE_DIR ${CMAKE_SOURCE_DIR}/projects)
set(DOGEN_DOX_DIR ${stage_doxygen_dir}/dox)
# output directory (used in doxygen template)
set(DOGEN_DOXYGEN_DIR ${stage_doxygen_dir})
# input file
set(doxy_file ${stage_doxygen_dir}/dogen.doxy)
add_custom_target(doxy ALL
COMMENT "Generating doxygen documentation."
COMMAND rm -rf ${stage_doxygen_dir}/html
COMMAND ${DOXYGEN_EXECUTABLE} ${doxy_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM)
set(target_dir "/usr/share/cdash/doxygen/dogen")
add_custom_target(deploy_doxy
COMMENT "Deploying doxygen documentation."
COMMAND rm -rf ${target_dir}.new
COMMAND mkdir ${target_dir}.new
COMMAND cp -r ${stage_dir}/doxygen/html ${target_dir}.new/
COMMAND rm -rf ${target_dir}
COMMAND mv ${target_dir}.new ${target_dir}
)
add_dependencies(deploy_doxy doxy)
install(
DIRECTORY ${stage_doxygen_dir}/html/
DESTINATION share/doc/${DOGEN_VERSION}/
COMPONENT documentation
)
else()
message(STATUS "Could not find Doxygen.")
endif()
else()
message(STATUS "Doxygen not enabled (set WITH_DOXYGEN=on).")
endif()
#
# Top-level knitter target.
#
add_custom_target(knit_all)
set(use_latest_knitter FALSE)
if(use_latest_knitter)
add_dependencies(knit_all knitter)
endif()
set(knitter_binary "${stage_bin_dir}/dogen_knitter")
set(knitter_version "")
execute_process(
COMMAND ${knitter_binary} --version
COMMAND head -n1
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
OUTPUT_VARIABLE knitter_version
RESULT_VARIABLE ret_var
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using: ${knitter_version}")
#
# Top-level stitcher target.
#
add_custom_target(stitch_all)
set(use_latest_stitcher FALSE)
if(use_latest_stitcher)
add_dependencies(stitch_all stitcher)
endif()
set(stitcher_binary "${stage_bin_dir}/dogen_stitcher")
set(stitcher_version "")
execute_process(
COMMAND ${stitcher_binary} --version
COMMAND head -n1
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
OUTPUT_VARIABLE stitcher_version
RESULT_VARIABLE ret_var
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using: ${stitcher_version}")
#
# aggregate targets
#
add_custom_target(run_all_specs)
add_custom_target(rebase)
add_custom_target(diff)
add_custom_target(knit_and_stitch)
add_dependencies(knit_and_stitch knit_all)
add_dependencies(knit_and_stitch stitch_all)
#
# include all sub directories
#
add_subdirectory(${CMAKE_SOURCE_DIR}/build)
add_subdirectory(${CMAKE_SOURCE_DIR}/data)
add_subdirectory(${CMAKE_SOURCE_DIR}/doc)
add_subdirectory(${CMAKE_SOURCE_DIR}/test_data)
add_subdirectory(${CMAKE_SOURCE_DIR}/projects)
add_subdirectory(${CMAKE_SOURCE_DIR}/diagrams)
#
# dependencies for aggregate targets
#
add_dependencies(rebase rebase_test_models rebase_dataset)
add_dependencies(diff diff_test_models diff_dataset)