-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
218 lines (187 loc) · 5.29 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
cmake_minimum_required(VERSION 3.18)
project(VegaFEM CXX C)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# configuration options
option(VEGA_USE_TBB "Build VegaFEM using TBB" ON)
option(VEGA_USE_INTEL_MKL "Build VegaFEM using MKL" OFF)
option(VEGA_USE_PARDISO "Build VegaFEM using PARDISO (requires MKL)" OFF)
option(VEGA_USE_SPOOLES "Build VegaFEM using SPOOLES" OFF)
option(VEGA_USE_GLEW "Build OpenGL shaders using GLEW" OFF)
option(VEGA_USE_GLUT "Build components that depend on GLUT" OFF)
option(VEGA_USE_CG_TOOLKIT "Build GPU components using Cg Toolkit" OFF)
option(VEGA_USE_CGAL "Build meshing components using CGAL" OFF)
option(VEGA_USE_EXPOKIT "Build matrix exponentials using Expokit" OFF)
option(VEGA_BUILD_UTILITIES "Build utilities" OFF)
# thirdparties
set(VEGA_DEPENDENCIES)
if(VEGA_USE_SPOOLES AND VEGA_USE_PARDISO)
message(FATAL_ERROR "Cannot select PARDISO and SPOOLES")
endif()
find_package(OpenGL REQUIRED)
list(APPEND VEGA_DEPENDENCIES OpenGL::GL)
if(VEGA_USE_TBB)
find_package(TBB REQUIRED)
list(APPEND VEGA_DEPENDENCIES TBB::tbb)
endif()
if(VEGA_USE_SPOOLES)
find_package(SPOOLES REQUIRED)
list(APPEND VEGA_DEPENDENCIES SPOOLES)
endif()
if(VEGA_USE_GLUT)
find_package(GLUT REQUIRED)
list(APPEND VEGA_DEPENDENCIES GLUT::GLUT)
endif()
if(VEGA_USE_GLEW)
find_package(GLEW REQUIRED)
list(APPEND VEGA_DEPENDENCIES GLEW::GLEW)
endif()
if(VEGA_USE_CGAL)
find_package(CGAL REQUIRED)
find_path(IGL_INCLUDE_DIRS igl/harmonic.h PATHS $ENV{IGL_ROOT}/include
REQUIRED)
endif()
if(${VEGA_USE_PARDISO} AND NOT ${VEGA_USE_INTEL_MKL})
message(FATAL_ERROR "PARDISO requires MKL")
endif()
set(ENABLE_BLAS95 ON)
set(ENABLE_LAPACK95 ON)
set(ENABLE_CPARDISO ${VEGA_USE_PARDISO})
find_package(MKL QUIET)
if(MKL_FOUND AND ${VEGA_USE_INTEL_MKL})
set(VEGA_USE_INTEL_MKL ON)
list(APPEND VEGA_DEPENDENCIES MKL::MKL)
elseif(${VEGA_USE_INTEL_MKL})
message(FATAL_ERROR "MKL not found")
else()
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
list(APPEND VEGA_DEPENDENCIES BLAS::BLAS LAPACK::LAPACK)
foreach(lib ${BLAS_LIBRARIES})
if(${lib} MATCHES "mkl")
set(VEGA_USE_INTEL_MKL ON)
endif()
endforeach()
message(STATUS "Using Intel MKL: ${VEGA_USE_INTEL_MKL}")
endif()
if(VEGA_USE_CG_TOOLKIT)
message(FATAL_ERROR "Cg toolkit not supported")
endif()
if(VEGA_USE_EXPOKIT)
message(FATAL_ERROR "Expkit not supported")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libraries/include/vega-config.h.in
${CMAKE_BINARY_DIR}/vega-config.h)
# select components to build
set(VEGA_LIBRARIES
basicAlgorithms
clothBW
configFile
constrainedDOFs
corotationalLinearFEM
elasticForceModel
forceModel
getopts
graph
hashTable
imageIO
integrator
integratorDense
integratorSparse
interpolationCoordinates
isotropicHyperelasticFEM
laplacianMatrix
listIO
matrix
massSpringSystem
matrixIO
mesh
minivector
modalMatrix
objMesh
performanceCounter
polarDecomposition
quaternion
reducedElasticForceModel
reducedForceModel
reducedStvk
rigidBodyDynamics
sparseMatrix
sparseSolver
stencilForceModel
stvk
volumetricMesh)
if(VEGA_USE_GLUT)
list(
APPEND
VEGA_LIBRARIES
camera
lighting
openGLHelper
renderVolumetricMesh
sceneObject
sceneObjectReduced)
endif()
if(VEGA_USE_GLUT AND VEGA_USE_GLEW)
list(APPEND VEGA_LIBRARIES glslPhong)
endif()
if(VEGA_USE_CGAL)
list(APPEND VEGA_LIBRARIES exactArithmetic libiglInterface virtualTets)
endif()
if(VEGA_USE_CG_TOOLKIT)
list(APPEND VEGA_LIBRARIES objMeshGPUDeformer)
endif()
# include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libraries/include
${CMAKE_BINARY_DIR})
foreach(lib ${VEGA_LIBRARIES})
include_directories(libraries/${lib})
endforeach()
# preprocessor definitions
add_definitions(-D_USE_MATH_DEFINES -DGL_SILENCE_DEPRECATION)
if(WIN32)
add_definitions(-DNOMINMAX)
endif()
set(VEGA_SOURCES)
macro(collect_sources var)
set(sources)
foreach(s ${ARGN})
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/${s})
endforeach()
set(${var}
"${${var}};${sources}"
PARENT_SCOPE)
endmacro()
foreach(lib ${VEGA_LIBRARIES})
add_subdirectory(libraries/${lib})
endforeach()
# link everything together into one library
set(CMAKE_DEBUG_POSTFIX d)
add_library(vega ${VEGA_SOURCES})
target_link_libraries(vega ${VEGA_DEPENDENCIES})
if(BUILD_SHARED_LIBS)
set_target_properties(vega PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
# make sure config is visible
target_precompile_headers(vega PRIVATE "${CMAKE_BINARY_DIR}/vega-config.h")
# build utilities
if(VEGA_BUILD_UTILITIES)
add_subdirectory(utilities)
endif()
# install
install(
TARGETS vega
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libraries/
DESTINATION include
FILES_MATCHING
PATTERN "*.h")
install(FILES ${CMAKE_BINARY_DIR}/vega-config.h DESTINATION include)