-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
142 lines (115 loc) · 4.4 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
################################################################################
# Preliminaries
################################################################################
project(ELEMENTS)
# CMake version > 3.8 required for C++17 standard
cmake_minimum_required(VERSION 3.8)
# C++17 standard required for MATAR
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Build type
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
# set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
# Set module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
################################################################################
# Dependencies
################################################################################
# Optional BLAS/LAPACK dependency (disabled by default)
option(WITH_BLAS_LAPACK "Build ELEMENTS with BLAS/LAPACK" OFF)
if (WITH_BLAS_LAPACK)
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
endif()
# Optional VTK dependency (disabled by default)
option(WITH_VTK "Build ELEMENTS with VTK" OFF)
if (WITH_VTK)
# Have user provide VTK_DIR flag to identify VTK installation location and
# VTK_SOURCE_DIR to identify VTK source location
find_package(VTK REQUIRED NO_MODULE)
endif()
# Optional Doxygen and Sphinx dependencies
option(WITH_DOCS "Build the documentation locally" OFF)
if (WITH_DOCS)
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)
endif()
add_subdirectory(matar)
include_directories(matar/src/include)
################################################################################
# Build
################################################################################
# Includes
include_directories(common)
include_directories(elements)
include_directories(geometry)
include_directories(slam)
include_directories(swage)
include_directories(io)
# Libraries
add_subdirectory(common)
add_subdirectory(elements)
add_subdirectory(geometry)
add_subdirectory(slam)
add_subdirectory(swage)
add_subdirectory(io)
# Documentation
if (WITH_DOCS)
add_subdirectory(docs)
endif()
# mesh tools
add_subdirectory(mesh_tools)
################################################################################
# Install
################################################################################
# Install headers in include/ subdirectory of the specified install directory
# (Note: This is an inelegant way of installing the headers. Resursing through
# subdirectories looking for anything that matches the pattern "*.h" is
# indiscriminate, and the resulting include/ directory isn't affected by
# distclean. If there's a better way to do this, please introduce it here.)
add_library(Elements INTERFACE)
file(GLOB_RECURSE ALL_HEADERS elements/*.h geometry/*.h slam/*.h swage/*.h common/*.h swage2vtk/*.h)
install(FILES ${ALL_HEADERS} DESTINATION include)
target_include_directories(Elements INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/ElementsConfigVersion.cmake"
VERSION 1.0
COMPATIBILITY AnyNewerVersion
)
install(TARGETS Elements elements geometry slam swage common matar
EXPORT ElementsTargets
LIBRARY DESTINATION lib COMPONENT Runtime
ARCHIVE DESTINATION lib COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Runtime
PUBLIC_HEADER DESTINATION include COMPONENT Development
BUNDLE DESTINATION bin COMPONENT Runtime
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/ElementsConfig.cmake.in"
"${PROJECT_BINARY_DIR}/ElementsConfig.cmake"
INSTALL_DESTINATION lib/cmake/Elements
)
set_target_properties(Elements
PROPERTIES
PUBLIC_HEADER "${ALL_HEADERS}"
)
install(EXPORT ElementsTargets DESTINATION lib/cmake/Elements)
install(FILES "${PROJECT_BINARY_DIR}/ElementsConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/ElementsConfig.cmake"
DESTINATION lib/cmake/Elements)
# Install libraries in lib/ subdirectory of the specified install directory
if (WITH_VTK AND VTK_FOUND)
install(TARGETS swage2vtk EXPORT ElementsTargets DESTINATION lib)
endif()
target_link_libraries(Elements INTERFACE elements geometry slam swage common)
if (WITH_VTK AND VTK_FOUND)
target_link_libraries(Elements INTERFACE swage2vtk)
endif()
target_link_libraries(Elements INTERFACE matar)