-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathCMakeLists.txt
219 lines (192 loc) · 6.93 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
# open3d_set_open3d_lib_properties() sets properties for the Open3D lib itself.
# This should be used for all object libraries that make up the Open3D lib.
#
# In comparison, open3d_set_global_properties() sets properties for the Open3D
# lib, and targets that links to the Open3D lib, e.g pybind, unit tests, etc.
function(open3d_set_open3d_lib_properties target)
cmake_parse_arguments(arg "HIDDEN" "" "" ${ARGN})
set_target_properties(${target} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${OPEN3D_ABI_VERSION}
)
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(${target} PUBLIC OPEN3D_STATIC)
endif()
if (arg_HIDDEN)
set_target_properties(${target} PROPERTIES
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
else ()
target_compile_definitions(${target} PRIVATE OPEN3D_ENABLE_DLL_EXPORTS)
endif()
# Hide all 3rd party symbols, e.g. from header libraries.
get_target_property(TARGET_TYPE ${target} TYPE)
if (TARGET_TYPE STREQUAL SHARED_LIBRARY)
if (APPLE)
file(GENERATE OUTPUT libOpen3D.map CONTENT
[=[*open3d*
*Open3D*
]=])
target_link_options(${target} PRIVATE $<$<CONFIG:Release>:
-Wl,-exported_symbols_list
"${CMAKE_CURRENT_BINARY_DIR}/libOpen3D.map" >)
elseif (UNIX) # Linux
file(GENERATE OUTPUT libOpen3D.map CONTENT
[=[{
global:
*open3d*;
extern "C++" {
open3d::*;
};
local: *;
};]=])
target_link_options(${target} PRIVATE $<$<CONFIG:Release>:
"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/libOpen3D.map" >)
elseif (WIN32)
# TODO(Sameer): Only export open3d symbols
endif()
endif()
endfunction()
# Configure a header file to pass the version settings to the source code
configure_file("${PROJECT_SOURCE_DIR}/cpp/open3d/Open3D.h.in"
"${PROJECT_SOURCE_DIR}/cpp/open3d/Open3D.h")
configure_file("${PROJECT_SOURCE_DIR}/cpp/open3d/Open3DConfig.h.in"
"${PROJECT_SOURCE_DIR}/cpp/open3d/Open3DConfig.h")
add_library(Open3D)
add_subdirectory(camera)
add_subdirectory(core)
add_subdirectory(data)
add_subdirectory(geometry)
add_subdirectory(io)
add_subdirectory(ml)
add_subdirectory(pipelines)
add_subdirectory(t/geometry)
add_subdirectory(t/io)
add_subdirectory(t/pipelines)
add_subdirectory(utility)
add_subdirectory(visualization)
if (BUILD_GUI)
add_subdirectory(visualization/gui)
endif()
if (BUILD_WEBRTC)
add_subdirectory(visualization/webrtc_server)
endif()
# note: adding at least one real source file to any target that references
# reference: https://cmake.org/cmake/help/v3.12/command/add_library.html#object-libraries
target_sources(Open3D PRIVATE
Open3DConfig.cpp
)
open3d_ispc_target_sources_TARGET_OBJECTS(Open3D PRIVATE
camera
core
core_impl
data
geometry
tgeometry
tgeometry_kernel
io
tio
ml_contrib
pipelines
tpipelines
tpipelines_kernel
utility
visualization
visualization_impl
)
if (BUILD_GUI)
open3d_ispc_target_sources_TARGET_OBJECTS(Open3D PRIVATE
GUI
)
endif()
if (BUILD_WEBRTC)
open3d_ispc_target_sources_TARGET_OBJECTS(Open3D PRIVATE
webrtc_server
)
endif()
# Source group for Visual Studio
add_source_group(camera)
add_source_group(core)
add_source_group(data)
add_source_group(geometry)
add_source_group(tgeometry)
add_source_group(io)
add_source_group(tio)
add_source_group(ml)
add_source_group(pipelines)
add_source_group(tpipelines)
add_source_group(utility)
add_source_group(visualization)
open3d_show_and_abort_on_warning(Open3D)
open3d_set_global_properties(Open3D)
open3d_set_open3d_lib_properties(Open3D)
open3d_link_3rdparty_libraries(Open3D)
# If we are building a STATIC_LIBRARY, hide symbols coming from 3rd party static
# libraries that are not hidden during compilation. Don't propagate beyond
# direct consumers of libOpen3D.a
target_link_options(Open3D INTERFACE
$<$<STREQUAL:$<TARGET_PROPERTY:Open3D,TYPE>,STATIC_LIBRARY>:$<LINK_ONLY:${OPEN3D_HIDDEN_3RDPARTY_LINK_OPTIONS}>>)
add_library(Open3D::Open3D ALIAS Open3D)
include(CMakePackageConfigHelpers)
# find_package Open3D
configure_package_config_file(Open3DConfig.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Open3DConfig.cmake"
INSTALL_DESTINATION ${Open3D_INSTALL_CMAKE_DIR}
PATH_VARS Open3D_INSTALL_INCLUDE_DIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# find_package Open3D Version
write_basic_package_version_file("${PROJECT_BINARY_DIR}/Open3DConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion)
# Installation
install(TARGETS Open3D EXPORT Open3DTargets
RUNTIME DESTINATION ${Open3D_INSTALL_BIN_DIR}
LIBRARY DESTINATION ${Open3D_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${Open3D_INSTALL_LIB_DIR}
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.cuh"
)
# Install the Open3DConfig.cmake and Open3DConfigVersion.cmake
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Open3DConfig.cmake"
"${PROJECT_BINARY_DIR}/Open3DConfigVersion.cmake"
DESTINATION "${Open3D_INSTALL_CMAKE_DIR}")
# Install GUI resources
if (BUILD_GUI)
install(DIRECTORY ${GUI_RESOURCE_DIR}
DESTINATION "${Open3D_INSTALL_RESOURCE_DIR}")
endif()
if (BUILD_SHARED_LIBS AND UNIX)
file(CONFIGURE OUTPUT Open3D.pc.in
CONTENT [=[
prefix=${pcfiledir}/../..
libdir=${prefix}/lib
includedir=${prefix}/include/
Name: Open3D
Description: @PROJECT_DESCRIPTION@
URL: @PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Cflags: -std=c++@CMAKE_CXX_STANDARD@ -isystem${includedir} -isystem${includedir}/open3d/3rdparty -D$<JOIN:$<TARGET_PROPERTY:INTERFACE_COMPILE_DEFINITIONS>, -D>
Libs: -L${libdir} -Wl,-rpath,${libdir} -lOpen3D -ltbb]=] @ONLY NEWLINE_STYLE LF)
file(GENERATE OUTPUT Open3D.pc INPUT "${CMAKE_CURRENT_BINARY_DIR}/Open3D.pc.in"
TARGET "Open3D::Open3D")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Open3D.pc"
DESTINATION "${Open3D_INSTALL_LIB_DIR}/pkgconfig")
endif ()
# uninstall target
if(NOT TARGET uninstall)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
# Export GUI_RESOURCE_FILES to parent CMake context (cpp/open3d/)
set(GUI_RESOURCE_FILES ${GUI_RESOURCE_FILES} PARENT_SCOPE)
set(GUI_RESOURCE_DIR ${GUI_RESOURCE_DIR} PARENT_SCOPE)