-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathCMakeLists.txt
208 lines (179 loc) · 6.83 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
cmake_minimum_required(VERSION 3.12)
project(OpenTissue VERSION 0.994
DESCRIPTION "A header only c++ library collection of generic algorithms and data structures for rapid development of interactive modeling and simulation."
HOMEPAGE_URL "https://github.com/erleben/OpenTissue")
# Add connan dependencies, conan targets will be used.
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS NO_OUTPUT_DIRS)
set(Boost_USE_STATIC_LIBS ON)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#-----------------------------------------------------------------------------
#
# Avoid in-source builds.
#
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(
FATAL_ERROR
"CMake generation for OpenTissue is not allowed within the source directory!"
)
endif()
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
#-----------------------------------------------------------------------------
#
# Global variables that control the behaviour of CMake. Use these in
# the GUI to turn on/off different kind of things.
#
option(OPENTISSUE_ENABLE_UNIT_TESTS "Build unit test" OFF)
option(OPENTISSUE_ENABLE_DOCUMENTATION "Build documentation" OFF)
option(OPENTISSUE_ENABLE_DEMOS "Build demos" OFF)
#-----------------------------------------------------------------------------
#
# Try to find Boost (http://www.boost.org/), Boost is needed by almost all
# OpenTissue code, one have to make sure this one works!
# FindBoost
if(OPENTISSUE_ENABLE_UNIT_TESTS)
set(OPENTISSUE_BOOST_COMPONENTS unit_test_framework)
endif()
set(OPENTISSUE_BOOST_VERSION 1.39.0)
find_package(Boost ${OPENTISSUE_BOOST_VERSION} COMPONENTS "${OPENTISSUE_BOOST_COMPONENTS}" REQUIRED)
if(OPENTISSUE_ENABLE_DEMOS)
#-----------------------------------------------------------------------------
#
# Try to find OpenGL (http://www.opengl.org/)
#
# OpenGL is used by the default demo applications in OpenTissue. The
# visualization part of OpenTissue has been designed as separate code
# pieces. These code pieces are intended for illustration purpose and
# for brute-force debug utilities for the OpenTissue developers. The
# openGL code pieces have never been intended to be used by end-users.
# Therefore end-users should be able to use OpenTissue without OpenGL.
#
# The only expcetion is our GPGPU code pieces, these are hard-wired to OpenGL
# and Cg.
#
#
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
#-----------------------------------------------------------------------------
#
# Try to find GLUT (read more here http://www.opengl.org/resources/libraries/).
#
# Glut is only needed by the Demo applications that comes with OpenTissue.
# End-users that are writting their own applications do not need this GLUT
# depedency and can ignore it.
#
option(OPENTISSUE_ENABLE_GLUT "Enable deprecated GLUT graphics interface." OFF)
if(OPENTISSUE_ENABLE_GLUT)
find_package(GLUT REQUIRED)
endif()
set(glfw3_ROOT /usr/local)
find_package(glfw3 REQUIRED)
#-----------------------------------------------------------------------------
#
# Try to get GLEW (http://glew.sourceforge.net/). Our demo application
# framework relies on GLEW for initialization of any OpenGL extentions.
# End-users are not required to use GLEW.
#
# As long as if they use any GPGPU stuff from OpenTissue they provide their
# own extention initialization. If no GPGPU stuff is used then this library
# dependency can be ignored.
#
find_package(GLEW REQUIRED)
endif()
find_package(TinyXML REQUIRED)
find_package(TetGen REQUIRED)
find_package(Triangle REQUIRED)
find_package(PNG REQUIRED)
#-----------------------------------------------------------------------------
#
# Try to find QHull (http://www.qhull.org/). Our mesh and t4mesh utilities
# make use of QHull for both convex hull as well as Delaunay triangulations.
#
find_package(Qhull REQUIRED)
#-----------------------------------------------------------------------------
#
# Look into subfolders
#
add_subdirectory(OpenTissue)
if(OPENTISSUE_ENABLE_DEMOS)
add_subdirectory(demos)
endif()
if(OPENTISSUE_ENABLE_DOCUMENTATION)
add_subdirectory(documentation)
endif()
if(OPENTISSUE_ENABLE_UNIT_TESTS)
option(BUILD_TESTING "Enable cmake testing utils." ON)
include(CTest)
add_subdirectory(unit_tests)
endif()
#-----------------------------------------------------------------------------
#
# Option for removing deprecated code from deprecated preprocessor
#
option(OPENTISSUE_EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" OFF)
if(OPENTISSUE_EXCLUDE_DEPRECATED)
set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED)
endif()
#-------------------------------------------------------------------------------
#
# Add support for other CMake applications, so it is easier to use OpenTissue.
#
# Recall, that CMake works with tree terms: source-, build- (ie. binary-) and
# isntall- configuration/tree.
#
# OpenTissue is a header only library (mostly), so the build-tree only makes sense for
# demo applications and units. Source- and install trees are basically just all
# the header-files, third-party libraries and cmake finding scripts.
#
include(CMakePackageConfigHelpers)
include(CPack)
include(GNUInstallDirs)
export(PACKAGE OpenTissue) # Makes OT discoverable, via ~/.cmake
export(TARGETS headers depends NAMESPACE OpenTissue:: FILE OpenTissueTargets.cmake)
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/OpenTissueConfig.cmake.in"
"${PROJECT_SOURCE_DIR}/OpenTissueConfig.cmake"
@ONLY
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/OpenTissueConfig.cmake.in"
"${PROJECT_BINARY_DIR}/OpenTissueConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenTissue
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
OpenTissueConfigVersion.cmake
VERSION ${OpenTissue_VERSION}
COMPATIBILITY SameMajorVersion
)
install(TARGETS headers depends
EXPORT OpenTissueTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(EXPORT OpenTissueTargets
FILE OpenTissueTargets.cmake
NAMESPACE OpenTissue::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenTissue
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/OpenTissueConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/OpenTissueConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenTissue
)
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/OpenTissue
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PATTERN "*.h.in" EXCLUDE
PATTERN "*.cmake" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/OpenTissue/configuration.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenTissue
)