Skip to content

Commit a509c75

Browse files
author
=
committed
Make interface libraries for header only.
Added more of original func to PCLConfig. Changed io_ply into a subsys system so its listed as modules.
1 parent 18e1395 commit a509c75

File tree

9 files changed

+416
-66
lines changed

9 files changed

+416
-66
lines changed

2d/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ endif()
3737
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
3838

3939
set(LIB_NAME "pcl_${SUBSYS_NAME}")
40+
41+
PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME})
42+
4043
PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC} PCL_DEPS ${SUBSYS_DEPS} HEADER_ONLY)
4144

4245
#Install include files

PCLConfig.cmake.in

+334-7
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,339 @@ set_and_check(PCL_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
2323

2424
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules")
2525

26-
find_dependency(Boost)
27-
find_dependency(Eigen3)
28-
find_dependency(Threads)
29-
find_dependency(OpenMP)
26+
### ---[ 3rd party libraries
27+
macro(find_boost)
28+
if(PCL_ALL_IN_ONE_INSTALLER)
29+
set(BOOST_ROOT "${PCL_ROOT}/3rdParty/Boost")
30+
elseif(NOT BOOST_INCLUDEDIR)
31+
set(BOOST_INCLUDEDIR "@Boost_INCLUDE_DIR@")
32+
endif()
33+
34+
set(Boost_ADDITIONAL_VERSIONS
35+
"@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@.@Boost_SUBMINOR_VERSION@" "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@"
36+
"1.84.0" "1.84" "1.83.0" "1.83" "1.82.0" "1.82" "1.81.0" "1.81" "1.80.0" "1.80"
37+
"1.79.0" "1.79" "1.78.0" "1.78" "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75"
38+
"1.74.0" "1.74" "1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70"
39+
"1.69.0" "1.69" "1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65")
40+
41+
find_package(Boost 1.65.0 ${QUIET_} COMPONENTS @PCLCONFIG_AVAILABLE_BOOST_MODULES@)
3042

31-
# Add the targets file
32-
include("${CMAKE_CURRENT_LIST_DIR}/pcl_common.cmake")
43+
set(BOOST_FOUND ${Boost_FOUND})
44+
set(BOOST_INCLUDE_DIRS "${Boost_INCLUDE_DIR}")
45+
set(BOOST_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}")
46+
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
47+
if(WIN32 AND NOT MINGW AND NOT "${BOOST_DEFINITIONS}" MATCHES "BOOST_ALL_NO_LIB")
48+
string(APPEND BOOST_DEFINITIONS -DBOOST_ALL_NO_LIB)
49+
endif()
50+
endmacro()
3351

34-
check_required_components(PCL)
52+
macro(find_eigen3)
53+
if(PCL_ALL_IN_ONE_INSTALLER)
54+
set(Eigen3_DIR "${PCL_ROOT}/3rdParty/Eigen3/share/eigen3/cmake/")
55+
endif()
56+
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
57+
if(NOT EIGEN3_FOUND AND Eigen3_FOUND)
58+
set(EIGEN3_FOUND ${Eigen3_FOUND})
59+
endif()
60+
# In very new Eigen versions, EIGEN3_INCLUDE_DIR(S) is not defined any more, only the target:
61+
if(TARGET Eigen3::Eigen)
62+
set(EIGEN3_LIBRARIES Eigen3::Eigen)
63+
endif()
64+
endmacro()
65+
66+
#remove this as soon as qhull is shipped with FindQhull.cmake
67+
macro(find_qhull)
68+
if(PCL_ALL_IN_ONE_INSTALLER)
69+
set(QHULL_ROOT "${PCL_ROOT}/3rdParty/Qhull")
70+
elseif(NOT QHULL_ROOT)
71+
get_filename_component(QHULL_ROOT "@QHULL_INCLUDE_DIRS@" PATH)
72+
endif()
73+
74+
set(PCL_QHULL_REQUIRED_TYPE @PCL_QHULL_REQUIRED_TYPE@)
75+
find_package(Qhull)
76+
endmacro()
77+
78+
#remove this as soon as libopenni is shipped with FindOpenni.cmake
79+
macro(find_openni)
80+
if(PCL_FIND_QUIETLY)
81+
set(OpenNI_FIND_QUIETLY TRUE)
82+
endif()
83+
84+
if(NOT OPENNI_ROOT AND ("@HAVE_OPENNI@" STREQUAL "TRUE"))
85+
set(OPENNI_INCLUDE_DIRS_HINT "@OPENNI_INCLUDE_DIRS@")
86+
get_filename_component(OPENNI_LIBRARY_HINT "@OPENNI_LIBRARY@" PATH)
87+
endif()
88+
89+
find_package(OpenNI)
90+
endmacro()
91+
92+
#remove this as soon as libopenni2 is shipped with FindOpenni2.cmake
93+
macro(find_openni2)
94+
if(PCL_FIND_QUIETLY)
95+
set(OpenNI2_FIND_QUIETLY TRUE)
96+
endif()
97+
98+
if(NOT OPENNI2_ROOT AND ("@HAVE_OPENNI2@" STREQUAL "TRUE"))
99+
set(OPENNI2_INCLUDE_DIRS_HINT "@OPENNI2_INCLUDE_DIRS@")
100+
get_filename_component(OPENNI2_LIBRARY_HINT "@OPENNI2_LIBRARY@" PATH)
101+
endif()
102+
103+
find_package(OpenNI2)
104+
endmacro()
105+
106+
#remove this as soon as the Ensenso SDK is shipped with FindEnsenso.cmake
107+
macro(find_ensenso)
108+
if(PCL_FIND_QUIETLY)
109+
set(ensenso_FIND_QUIETLY TRUE)
110+
endif()
111+
112+
if(NOT ENSENSO_ROOT AND ("@HAVE_ENSENSO@" STREQUAL "TRUE"))
113+
get_filename_component(ENSENSO_ABI_HINT "@ENSENSO_INCLUDE_DIR@" PATH)
114+
endif()
115+
116+
find_package(Ensenso)
117+
endmacro()
118+
119+
#remove this as soon as the davidSDK is shipped with FinddavidSDK.cmake
120+
macro(find_davidSDK)
121+
if(PCL_FIND_QUIETLY)
122+
set(DAVIDSDK_FIND_QUIETLY TRUE)
123+
endif()
124+
125+
if(NOT davidSDK_ROOT AND ("@HAVE_DAVIDSDK@" STREQUAL "TRUE"))
126+
get_filename_component(DAVIDSDK_ABI_HINT @DAVIDSDK_INCLUDE_DIR@ PATH)
127+
endif()
128+
129+
find_package(davidSDK)
130+
endmacro()
131+
132+
macro(find_dssdk)
133+
if(PCL_FIND_QUIETLY)
134+
set(DSSDK_FIND_QUIETLY TRUE)
135+
endif()
136+
if(NOT DSSDK_DIR AND ("@HAVE_DSSDK@" STREQUAL "TRUE"))
137+
get_filename_component(DSSDK_DIR_HINT "@DSSDK_INCLUDE_DIRS@" PATH)
138+
endif()
139+
140+
find_package(DSSDK)
141+
endmacro()
142+
143+
macro(find_rssdk)
144+
if(PCL_FIND_QUIETLY)
145+
set(RSSDK_FIND_QUIETLY TRUE)
146+
endif()
147+
if(NOT RSSDK_DIR AND ("@HAVE_RSSDK@" STREQUAL "TRUE"))
148+
get_filename_component(RSSDK_DIR_HINT "@RSSDK_INCLUDE_DIRS@" PATH)
149+
endif()
150+
151+
find_package(RSSDK)
152+
endmacro()
153+
154+
macro(find_rssdk2)
155+
if(PCL_ALL_IN_ONE_INSTALLER)
156+
set(realsense2_DIR "${PCL_ROOT}/3rdParty/librealsense2/lib/cmake/realsense2" CACHE PATH "The directory containing realsense2Config.cmake")
157+
elseif(NOT realsense2_DIR)
158+
get_filename_component(realsense2_DIR "@REALSENSE2_INCLUDE_DIRS@" PATH)
159+
set(realsense2_DIR "${realsense2_DIR}/lib/cmake/realsense2" CACHE PATH "The directory containing realsense2Config.cmake")
160+
endif()
161+
find_package(RSSDK2)
162+
endmacro()
163+
164+
#remove this as soon as flann is shipped with FindFlann.cmake
165+
macro(find_flann)
166+
if(PCL_ALL_IN_ONE_INSTALLER)
167+
set(FLANN_ROOT "${PCL_ROOT}/3rdParty/Flann")
168+
elseif(NOT FLANN_ROOT)
169+
set(FLANN_ROOT "@FLANN_ROOT@")
170+
endif()
171+
172+
set(PCL_FLANN_REQUIRED_TYPE @PCL_FLANN_REQUIRED_TYPE@)
173+
find_package(FLANN)
174+
endmacro()
175+
176+
macro(find_VTK)
177+
if(PCL_ALL_IN_ONE_INSTALLER AND NOT ANDROID)
178+
if(EXISTS "${PCL_ROOT}/3rdParty/VTK/lib/cmake")
179+
set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/cmake/vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@" CACHE PATH "The directory containing VTKConfig.cmake")
180+
else()
181+
set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@" CACHE PATH "The directory containing VTKConfig.cmake")
182+
endif()
183+
elseif(NOT VTK_DIR AND NOT ANDROID)
184+
set(VTK_DIR "@VTK_DIR@" CACHE PATH "The directory containing VTKConfig.cmake")
185+
endif()
186+
if(NOT ANDROID)
187+
find_package(VTK ${QUIET_} COMPONENTS ${PCL_VTK_COMPONENTS})
188+
endif()
189+
endmacro()
190+
191+
macro(find_libusb)
192+
find_package(libusb)
193+
endmacro()
194+
195+
macro(find_glew)
196+
find_package(GLEW)
197+
endmacro()
198+
199+
# Finds each component external libraries if any
200+
# The functioning is as following
201+
# try to find _lib
202+
# |--> _lib found ==> include the headers,
203+
# | link to its library directories or include _lib_USE_FILE
204+
# `--> _lib not found
205+
# |--> _lib is optional ==> disable it (thanks to the guardians)
206+
# | and warn
207+
# `--> _lib is required
208+
# |--> component is required explicitly ==> error
209+
# `--> component is induced ==> warn and remove it
210+
# from the list
211+
212+
function(find_external_library _component _lib _is_optional)
213+
if("${_lib}" STREQUAL "boost")
214+
find_boost()
215+
elseif("${_lib}" STREQUAL "eigen3")
216+
find_eigen3()
217+
elseif("${_lib}" STREQUAL "flann")
218+
find_flann()
219+
elseif("${_lib}" STREQUAL "qhull")
220+
find_qhull()
221+
elseif("${_lib}" STREQUAL "openni")
222+
find_openni()
223+
elseif("${_lib}" STREQUAL "openni2")
224+
find_openni2()
225+
elseif("${_lib}" STREQUAL "ensenso")
226+
find_ensenso()
227+
elseif("${_lib}" STREQUAL "davidSDK")
228+
find_davidSDK()
229+
elseif("${_lib}" STREQUAL "dssdk")
230+
find_dssdk()
231+
elseif("${_lib}" STREQUAL "rssdk")
232+
find_rssdk()
233+
elseif("${_lib}" STREQUAL "rssdk2")
234+
find_rssdk2()
235+
elseif("${_lib}" STREQUAL "vtk")
236+
find_VTK()
237+
elseif("${_lib}" STREQUAL "libusb")
238+
find_libusb()
239+
elseif("${_lib}" STREQUAL "glew")
240+
find_glew()
241+
elseif("${_lib}" STREQUAL "opengl")
242+
find_package(OpenGL)
243+
elseif("${_lib}" STREQUAL "pcap")
244+
find_package(Pcap)
245+
elseif("${_lib}" STREQUAL "png")
246+
find_package(PNG)
247+
elseif("${_lib}" STREQUAL "OpenMP")
248+
find_package(OpenMP COMPONENTS CXX)
249+
# the previous find_package call sets OpenMP_CXX_LIBRARIES, but not OPENMP_LIBRARIES, which is used further down
250+
# we can link to the CMake target OpenMP::OpenMP_CXX by setting the following:
251+
set(OPENMP_LIBRARIES OpenMP::OpenMP_CXX)
252+
else()
253+
message(WARNING "${_lib} is not handled by find_external_library")
254+
endif()
255+
256+
string(TOUPPER "${_component}" COMPONENT)
257+
string(TOUPPER "${_lib}" LIB)
258+
string(REGEX REPLACE "[.-]" "_" LIB ${LIB})
259+
260+
if(${LIB}_FOUND)
261+
list(APPEND PCL_${COMPONENT}_INCLUDE_DIRS ${${LIB}_INCLUDE_DIRS})
262+
set(PCL_${COMPONENT}_INCLUDE_DIRS ${PCL_${COMPONENT}_INCLUDE_DIRS} PARENT_SCOPE)
263+
264+
if(${LIB} MATCHES "VTK")
265+
if(${${LIB}_VERSION_MAJOR} GREATER_EQUAL 9)
266+
set(ISVTK9ORGREATER TRUE)
267+
endif()
268+
endif()
269+
else()
270+
if("${_is_optional}" STREQUAL "OPTIONAL")
271+
list(APPEND PCL_${COMPONENT}_DEFINITIONS "-DDISABLE_${LIB}")
272+
pcl_message("** WARNING ** ${_component} features related to ${_lib} will be disabled")
273+
elseif("${_is_optional}" STREQUAL "REQUIRED")
274+
if((NOT PCL_FIND_ALL) OR (PCL_FIND_ALL EQUAL 1))
275+
pcl_report_not_found("${_component} is required but ${_lib} was not found")
276+
elseif(PCL_FIND_ALL EQUAL 0)
277+
# raise error and remove _component from PCL_TO_FIND_COMPONENTS
278+
string(TOUPPER "${_component}" COMPONENT)
279+
pcl_message("** WARNING ** ${_component} will be disabled cause ${_lib} was not found")
280+
list(REMOVE_ITEM PCL_TO_FIND_COMPONENTS ${_component})
281+
endif()
282+
endif()
283+
endif()
284+
endfunction()
285+
286+
#flatten dependencies recursivity is great \o/
287+
macro(compute_dependencies TO_FIND_COMPONENTS)
288+
foreach(component ${${TO_FIND_COMPONENTS}})
289+
set(pcl_component pcl_${component})
290+
if(${pcl_component}_int_dep AND (NOT PCL_FIND_ALL))
291+
foreach(dependency ${${pcl_component}_int_dep})
292+
list(FIND ${TO_FIND_COMPONENTS} ${component} pos)
293+
list(FIND ${TO_FIND_COMPONENTS} ${dependency} found)
294+
if(found EQUAL -1)
295+
set(pcl_dependency pcl_${dependency})
296+
if(${pcl_dependency}_int_dep)
297+
list(INSERT ${TO_FIND_COMPONENTS} ${pos} ${dependency})
298+
if(pcl_${dependency}_ext_dep)
299+
list(APPEND pcl_${component}_ext_dep ${pcl_${dependency}_ext_dep})
300+
endif()
301+
if(pcl_${dependency}_opt_dep)
302+
list(APPEND pcl_${component}_opt_dep ${pcl_${dependency}_opt_dep})
303+
endif()
304+
compute_dependencies(${TO_FIND_COMPONENTS})
305+
else()
306+
list(INSERT ${TO_FIND_COMPONENTS} 0 ${dependency})
307+
endif()
308+
endif()
309+
endforeach()
310+
endif()
311+
endforeach()
312+
endmacro()
313+
314+
set(pcl_all_components @PCLCONFIG_AVAILABLE_COMPONENTS@)
315+
list(LENGTH pcl_all_components PCL_NB_COMPONENTS)
316+
317+
#list each component dependencies IN PCL
318+
@PCLCONFIG_INTERNAL_DEPENDENCIES@
319+
320+
#list each component external dependencies (ext means mandatory and opt means optional)
321+
@PCLCONFIG_EXTERNAL_DEPENDENCIES@
322+
323+
@PCLCONFIG_OPTIONAL_DEPENDENCIES@
324+
325+
# VTK components required by PCL
326+
set(PCL_VTK_COMPONENTS "@PCL_VTK_COMPONENTS@")
327+
328+
#check if user provided a list of components
329+
#if no components at all or full list is given set PCL_FIND_ALL
330+
if(PCL_FIND_COMPONENTS)
331+
list(LENGTH PCL_FIND_COMPONENTS PCL_FIND_COMPONENTS_LENGTH)
332+
if(PCL_FIND_COMPONENTS_LENGTH EQUAL PCL_NB_COMPONENTS)
333+
set(PCL_TO_FIND_COMPONENTS ${pcl_all_components})
334+
set(PCL_FIND_ALL 1)
335+
else()
336+
set(PCL_TO_FIND_COMPONENTS ${PCL_FIND_COMPONENTS})
337+
endif()
338+
else()
339+
set(PCL_TO_FIND_COMPONENTS ${pcl_all_components})
340+
set(PCL_FIND_ALL 1)
341+
endif()
342+
343+
compute_dependencies(PCL_TO_FIND_COMPONENTS)
344+
345+
# compute external dependencies per component
346+
foreach(component ${PCL_TO_FIND_COMPONENTS})
347+
foreach(opt ${pcl_${component}_opt_dep})
348+
find_external_library(${component} ${opt} OPTIONAL)
349+
endforeach()
350+
foreach(ext ${pcl_${component}_ext_dep})
351+
find_external_library(${component} ${ext} REQUIRED)
352+
endforeach()
353+
endforeach()
354+
355+
set(PCL_LIBRARIES)
356+
foreach(component ${PCL_TO_FIND_COMPONENTS})
357+
# Add the targets file
358+
include("${CMAKE_CURRENT_LIST_DIR}/pcl_${component}.cmake")
359+
check_required_components(${component})
360+
list(APPEND PCL_LIBRARIES "pcl::pcl_${component}")
361+
endforeach()

0 commit comments

Comments
 (0)