-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
222 lines (162 loc) · 6.97 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
# CMakeLists.txt
# Copyright (C) 2017 Sebastien Vavassori
# This code is released under the LGPL license.
# For conditions of distribution and use, see the disclaimer
# and license in LICENSE
cmake_minimum_required(VERSION 2.8)
#cmake_policy(VERSION 2.8)
project(FastenerPattern)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
##############################################################################
## Versioning
##############################################################################
# read 'version' file into a variable (stripping any newlines or spaces)
file(READ version versionFile)
if (NOT versionFile)
message(FATAL_ERROR "Unable to determine FastenerPattern version. Version file is missing.")
endif()
string(STRIP "${versionFile}" FASTENER_PATTERN_VERSION)
# add a dependency on the versino file
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS version)
# split version string into components, note CMAKE_MATCH_0 is the entire regexp match
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" APP_VERSION ${FASTENER_PATTERN_VERSION} )
set(APP_VERSION_MAJOR ${CMAKE_MATCH_1})
set(APP_VERSION_MINOR ${CMAKE_MATCH_2})
set(APP_VERSION_PATCH ${CMAKE_MATCH_3})
configure_file( ./src/config.h.cmake ./src/config.h )
##############################################################################
# Rename the executable for DEBUG and RELEASE
##############################################################################
set(FastenerPattern_NAME "fastenerpattern")
# Change the default build type to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# to distinguish between debug and release
set(CMAKE_DEBUG_POSTFIX "d")
##############################################################################
# build options
##############################################################################
#TODO: enable_testing()
option(ENABLE_TESTS "Set to ON to build test applications (default)" ON)
##############################################################################
## Qt5
##############################################################################
# https://cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html
# find_package(Qt5Core REQUIRED)
# find_package(Qt5Gui REQUIRED)
# find_package(Qt5Widgets REQUIRED)
find_package(Qt5 5.1 COMPONENTS Core)
find_package(Qt5 5.1 COMPONENTS Gui)
find_package(Qt5 5.1 COMPONENTS Widgets)
if(ENABLE_TESTS)
find_package(Qt5 5.1 COMPONENTS Test)
endif(ENABLE_TESTS)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
##############################################################################
## 3RD-PARTY DEPENDENCIES
##############################################################################
include(${CMAKE_CURRENT_SOURCE_DIR}/3rd/CMakeLists.txt)
##############################################################################
### Include
##############################################################################
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(./include/)
##############################################################################
### Sources
##############################################################################
include(${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/core/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/dialogs/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/editor/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/math/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/widgets/CMakeLists.txt)
##############################################################################
# Qt -- Run the MOC, resource, etc.
##############################################################################
qt5_wrap_cpp( fastenerpattern_HEADERS_MOC ${MY_HEADERS} )
qt5_wrap_ui( fastenerpattern_FORMS_HEADERS ${MY_FORMS} )
add_library(configwin
${fastenerpattern_HEADERS_MOC}
${fastenerpattern_FORMS_HEADERS}
)
qt5_use_modules(configwin Widgets)
##############################################################################
# Linking the executable
##############################################################################
add_executable(${FastenerPattern_NAME}
WIN32
${MY_SOURCES}
${configwin}
${MY_RESOURCES}
)
# Qt5
qt5_use_modules(${FastenerPattern_NAME} Core Gui Widgets )
##############################################################################
# Unit Tests
##############################################################################
#TODO: add_test()
if(ENABLE_TESTS)
include(${CMAKE_CURRENT_SOURCE_DIR}/test/boost/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/test/delaunay/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/test/math/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/test/optimisationsolver/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/test/rigidbodysolver/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/test/splicecalculator/CMakeLists.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/test/tensor/CMakeLists.txt)
# install(TARGETS test1 test2 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif(ENABLE_TESTS)
##############################################################################
## Deploying documentation and files
##############################################################################
set(MY_RELEASE_DOCS
./user-manual/User_Manual.pdf
./LICENSE
)
install (
FILES ${MY_RELEASE_DOCS}
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT release_docs
)
## Example files
set(MY_RELEASE_EXAMPLES
./src/examples/4BoltJoint.splice
./src/examples/PatternJoint.splice
./src/examples/RandomJoint.splice
./src/examples/Optimize_4BoltJoint.splice
)
install (
FILES ${MY_RELEASE_EXAMPLES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/examples
COMPONENT release_examples
)
## 3rd-party libraries
if (MSVC OR MSYS OR MINGW) # for detecting Windows compilers
## Qt Libraries
get_target_property(QtCore_LOCATION Qt5::Core LOCATION)
get_filename_component(QT_DLL_DIR ${QtCore_LOCATION} PATH)
install(FILES
${QT_DLL_DIR}/libgcc_s_dw2-1.dll
${QT_DLL_DIR}/libstdc++-6.dll
${QT_DLL_DIR}/libwinpthread-1.dll
${QT_DLL_DIR}/Qt5Core.dll
${QT_DLL_DIR}/Qt5Gui.dll
${QT_DLL_DIR}/Qt5Widgets.dll
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
## Qt Platform Plugin
install(FILES
${QT_DLL_DIR}/../plugins/platforms/qwindows.dll
DESTINATION ${CMAKE_INSTALL_PREFIX}/platforms
)
endif(MSVC OR MSYS OR MINGW)
##############################################################################
# Deploying executable
##############################################################################
install(TARGETS ${FastenerPattern_NAME}
RUNTIME
DESTINATION ${CMAKE_INSTALL_PREFIX}
)