Skip to content

Commit 05b8e34

Browse files
AnastaZIukdeprilula28
authored andcommitted
Patch PCL to make it build able for shared configuration with external build system
1 parent 371a8e1 commit 05b8e34

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

CMakeLists.txt

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "")
2323
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "build type default to RelWithDebInfo, set to Release to improve performance" FORCE)
2424
endif()
2525

26+
set(PCL_SHARED_LIBS ON CACHE BOOL "" FORCE) # shared build is a way, otherwise too many errors
27+
set(WITH_VTK OFF CACHE BOOL "" FORCE)
28+
set(WITH_QT OFF CACHE BOOL "" FORCE)
29+
2630
project(PCL VERSION 1.13.0)
2731
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
2832

@@ -314,14 +318,29 @@ endif()
314318
find_package(Threads REQUIRED)
315319

316320
# Eigen (required)
321+
# PATCH: Build system needs to pass PC_EIGEN_INCLUDE_DIRS variable to make it search-able
322+
if(NOT DEFINED PC_EIGEN_INCLUDE_DIRS)
323+
message(FATAL_ERROR "PATCH: PC_EIGEN_INCLUDE_DIRS is required!")
324+
endif()
325+
317326
find_package(Eigen 3.3 REQUIRED)
318327
include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS})
319328

320329
# FLANN (required)
321-
find_package(FLANN 1.9.1 REQUIRED)
322-
if(NOT (${FLANN_LIBRARY_TYPE} MATCHES ${PCL_FLANN_REQUIRED_TYPE}) AND NOT (${PCL_FLANN_REQUIRED_TYPE} MATCHES "DONTCARE"))
323-
message(FATAL_ERROR "Flann was selected with ${PCL_FLANN_REQUIRED_TYPE} but found as ${FLANN_LIBRARY_TYPE}")
330+
# PATCH: manually set flann.pc variables and make it work with build system
331+
if(NOT DEFINED _PATCHED_FLANN_INSTALL_DIR_)
332+
message(FATAL_ERROR "PATCH: _PATCHED_FLANN_INSTALL_DIR_ is required!")
324333
endif()
334+
set(FLANN_FOUND 1)
335+
set(FLANN_INCLUDE_DIRS ${_PATCHED_FLANN_INSTALL_DIR_}/include)
336+
set(FLANN_LIBRARY_DIRS ${_PATCHED_FLANN_INSTALL_DIR_}/lib)
337+
set(FLANN_LIBRARIES ${FLANN_LIBRARY_DIRS}/flann_cpp_s.lib)
338+
339+
include_directories(${FLANN_INCLUDE_DIRS})
340+
341+
# Create interface library that effectively becomes an alias for the appropriate (static/dynamic) imported FLANN target
342+
add_library(FLANN::FLANN INTERFACE IMPORTED)
343+
set_property(TARGET FLANN::FLANN APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${FLANN_LIBRARIES})
325344

326345
# libusb
327346
option(WITH_LIBUSB "Build USB RGBD-Camera drivers" TRUE)
@@ -409,7 +428,14 @@ if(WITH_OPENGL)
409428
endif()
410429

411430
# Boost (required)
431+
# PATCH: Build system needs to pass Boost_DIR variable to make it search-able
432+
if(NOT DEFINED Boost_DIR)
433+
message(FATAL_ERROR "PATCH: Boost_DIR is required!")
434+
endif()
435+
436+
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
412437
include("${PCL_SOURCE_DIR}/cmake/pcl_find_boost.cmake")
438+
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG FALSE)
413439

414440
### ---[ Create the config.h file
415441
set(pcl_config_h_in "${CMAKE_CURRENT_SOURCE_DIR}/pcl_config.h.in")
@@ -448,4 +474,4 @@ MAKE_DEP_GRAPH()
448474

449475
### ---[ Finish up
450476
PCL_WRITE_STATUS_REPORT()
451-
PCL_RESET_MAPS()
477+
PCL_RESET_MAPS()

0 commit comments

Comments
 (0)