-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
295 lines (270 loc) · 9.94 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
# *******************************************************************
# *** VegaFEM CMakeLists.txt ***
# *******************************************************************
# This file contains the top level CMakeLists.txt logic for the
# Vega FEM software package.
project(VegaFEM)
set(VegaFEM_VERSION 2.0)
# Minimum required version of CMake
cmake_minimum_required(VERSION 2.8)
if(COMMAND CMAKE_POLICY)
cmake_policy(SET CMP0003 NEW)
if (POLICY CMP0022)
# Use INTERFACE_LINK_LIBRARIES when available.
cmake_policy(SET CMP0022 NEW)
endif()
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
endif(COMMAND CMAKE_POLICY)
if(NOT IS_SUBBUILD)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH};")
else(NOT IS_SUBBUILD)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/CMake")
endif(NOT IS_SUBBUILD)
include(CMakePackageConfigHelpers)
include(VegaFEMMacros)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE OFF)
option(VegaFEM_BUILD_UTILITIES "Build utility applications in addition to libraries." ON)
option(VegaFEM_BUILD_MODEL_REDUCTION "Should model-reduction techniques be included?" ON)
option(VegaFEM_ENABLE_ExpoKit_SUPPORT "Should matrix classes use ExpoKit for exponentiation?" OFF)
# TODO: define USE_EXPOKIT if enabled
option(VegaFEM_ENABLE_OpenGL_SUPPORT "Should modules that require OpenGL be enabled?" ON)
option(VegaFEM_ENABLE_PTHREADS_SUPPORT "Use multithreading (pthread)" ON)
# TODO: add option for arpack++ and define USEARPACKPLUSPLUS
# TODO: add option for spooles and define SPOOLES_SOLVER_IS_AVAILABLE
if (VegaFEM_ENABLE_OpenGL_SUPPORT)
# Only add Cg support if OpenGL is turned on. This may change in the future.
option(VegaFEM_ENABLE_Cg_SUPPORT "Should modules that require Cg be enabled?" OFF)
endif()
#---------------------------------------------------------------------
# The following logic is what allows binaries to run successfully in
# the build directory AND install directory. Thanks to plplot for
# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX.
# Documentation of these options is available at
# http://www.cmake.org/Wiki/CMake_RPATH_handling
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# the RPATH/INSTALL_NAME_DIR to be used when installing
if (NOT APPLE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib")
endif(NOT APPLE)
# On OSX, we need to set INSTALL_NAME_DIR instead of RPATH
# http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH which point to
# directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Set directory variables
if(NOT BIN_DIR)
set(BIN_DIR bin)
endif(NOT BIN_DIR)
if(NOT LIB_DIR)
set(LIB_DIR lib)
endif(NOT LIB_DIR)
# Output directories - this is where built library and executable
# files will be placed after building but prior to install. The
# necessary variables change between single and multi configuration
# build systems, so it is necessary to handle both cases on a
# conditional basis.
if(NOT CMAKE_CONFIGURATION_TYPES)
# If we're not doing multi-configuration, just set the three main
# variables to the correct values.
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${VegaFEM_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all libraries.")
endif(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${VegaFEM_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all archives.")
endif(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${VegaFEM_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.")
endif(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
else(NOT CMAKE_CONFIGURATION_TYPES)
# Multi-configuration is more difficult. Not only do we need to
# properly set the output directories, but we also need to
# identify the "toplevel" directory for each configuration so
# we can place files, documentation, etc. in the correct
# relative positions. Because files may be placed by CMake
# without a build target to put them in their proper relative build
# directory position using these paths, we must fully qualify them
# without using CMAKE_CFG_INTDIR.
#
# We define directories that may not be quite "standard"
# for a particular build tool - for example, native VS2010 projects use
# another directory to denote CPU type being compiled for - but CMake only
# supports multi-configuration setups having multiple configurations,
# not multiple compilers.
#
# One additional wrinkle we must watch for here is the case where
# a multi-configuration setup uses "." for its internal directory -
# if that's the case, we need to just set the various config output
# directories to the same value.
set(CFG_ROOT ${VegaFEM_BINARY_DIR})
foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
set(CFG_ROOT ${VegaFEM_BINARY_DIR}/${CFG_TYPE})
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER)
if(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.")
endif(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
if(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.")
endif(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
if(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.")
endif(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
if(NOT "CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}")
set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.")
endif(NOT "CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}")
if(NOT "VegaFEM_BINARY_DIR_${CFG_TYPE_UPPER}")
set("VegaFEM_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.")
endif(NOT "VegaFEM_BINARY_DIR_${CFG_TYPE_UPPER}")
endforeach()
endif(NOT CMAKE_CONFIGURATION_TYPES)
if (VegaFEM_ENABLE_OpenGL_SUPPORT)
find_package(OpenGL)
find_package(GLUT)
find_package(GLEW)
find_package(GLUI)
if (GLUT_FOUND)
mark_as_advanced(GLUT_cocoa_LIBRARY)
endif()
if (VegaFEM_ENABLE_Cg_SUPPORT)
find_package(Cg REQUIRED)
mark_as_advanced(
CG_COMPILER
CG_GL_LIBRARY
CG_INCLUDE_PATH
CG_LIBRARY
)
endif()
endif()
if(VegaFEM_ENABLE_PTHREADS_SUPPORT)
#FindThreads
if(WIN32)
set(THREADS_USE_PTHREADS_WIN32 1)
endif(WIN32)
find_package(PThreads REQUIRED)
if(THREADS_FOUND)
include_directories(${THREADS_PTHREADS_INCLUDE_DIR})
endif()
endif()
if (VegaFEM_BUILD_MODEL_REDUCTION)
if (NOT APPLE)
find_package(MKL)
if(MKL_FOUND)
set(BLA_VENDOR "Intel mkl")
include_directories(${INTEL_MKL_INCLUDE_DIR})
# TODO: set option for the paradiso solvers and define PARDISO_SOLVER_IS_AVAILABLE
else()
find_package(LAPACKE REQUIRED) # Also searches for cblas
include_directories(${LAPACKE_INCLUDE_DIR})
include_directories(${CBLAS_INCLUDE_DIR})
endif()
endif()
find_package(LAPACK) # Also searches for blas
endif()
if (VegaFEM_ENABLE_OpenGL_SUPPORT)
if(NOT GLUI_INCLUDE_DIR OR NOT GLUI_LIBRARY)
add_subdirectory(thirdparty/glui/2.36/src)
set(GLUI_LIBRARY glui)
set(GLUI_INCLUDE_DIR) # Empty this as library will export its own includes.
endif()
endif()
set(VegaFEM_Modules
minivector
matrixIO
sparseMatrix
graph
imageIO
configFile
integrator
performanceCounter
insertRows
sparseSolver
forceModel
integratorSparse
objMesh
polarDecomposition
volumetricMesh
corotationalLinearFEM
massSpringSystem
stvk
quaternion
isotropicHyperelasticFEM
elasticForceModel
loadList
vega-getopts
clothBW
hashTable
rigidBodyDynamics
)
if (VegaFEM_BUILD_MODEL_REDUCTION)
set(VegaFEM_Modules
${VegaFEM_Modules}
integratorDense
matrix
modalMatrix
reducedElasticForceModel
reducedForceModel
reducedStvk
)
endif()
if (VegaFEM_ENABLE_OpenGL_SUPPORT)
set(VegaFEM_Modules
${VegaFEM_Modules}
camera
lighting
sceneObject
glslPhong
)
if (VegaFEM_ENABLE_Cg_SUPPORT)
set(VegaFEM_Modules
${VegaFEM_Modules}
objMeshGPUDeformer
)
endif()
if (VegaFEM_BUILD_MODEL_REDUCTION)
set(VegaFEM_Modules
${VegaFEM_Modules}
openGLHelper
sceneObjectReduced
renderVolumetricMesh
)
endif()
endif()
add_subdirectory(src)
export(PACKAGE VegaFEM)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/VegaFEMConfigVersion.cmake"
VERSION ${VegaFEM_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_file(
CMake/VegaFEMConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/VegaFEMConfig.cmake"
COPYONLY
)
set(ConfigPackageLocation lib/cmake/VegaFEM)
install(EXPORT VegaFEMTargets
FILE
VegaFEMTargets.cmake
#NAMESPACE VegaFEM::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
CMake/VegaFEMConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/VegaFEMConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)
add_subdirectory(include)