Skip to content

Commit 511ea48

Browse files
authored
Make Boost filesystem optional for C++17 (#5937)
* Make Boost filesystem optional for C++17 * Add more changes * Simpler changes * Review changes
1 parent 8a2ead6 commit 511ea48

File tree

6 files changed

+47
-13
lines changed

6 files changed

+47
-13
lines changed

apps/3d_rec_framework/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ set(SUBSUBSYS_DESC "3D recognition framework")
33
set(SUBSUBSYS_DEPS common geometry io filters sample_consensus segmentation visualization kdtree features surface octree registration keypoints tracking search recognition ml)
44
set(SUBSUBSYS_EXT_DEPS vtk openni)
55

6+
if(NOT TARGET Boost::filesystem)
7+
set(DEFAULT FALSE)
8+
set(REASON "Boost filesystem is not available.")
9+
else()
10+
set(DEFAULT TRUE)
11+
endif()
12+
613
# Default to not building for now
714
if(${DEFAULT} STREQUAL "TRUE")
815
set(DEFAULT FALSE)

cmake/pcl_find_boost.cmake

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,25 @@ set(Boost_ADDITIONAL_VERSIONS
1919
"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"
2020
"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")
2121

22-
# Optional boost modules
23-
find_package(Boost 1.65.0 QUIET COMPONENTS serialization mpi)
24-
if(Boost_SERIALIZATION_FOUND)
25-
set(BOOST_SERIALIZATION_FOUND TRUE)
22+
if(CMAKE_CXX_STANDARD MATCHES "14")
23+
# Optional boost modules
24+
set(BOOST_OPTIONAL_MODULES serialization mpi)
25+
# Required boost modules
26+
set(BOOST_REQUIRED_MODULES filesystem iostreams system)
27+
else()
28+
# Optional boost modules
29+
set(BOOST_OPTIONAL_MODULES filesystem serialization mpi)
30+
# Required boost modules
31+
set(BOOST_REQUIRED_MODULES iostreams system)
2632
endif()
2733

28-
# Required boost modules
29-
set(BOOST_REQUIRED_MODULES filesystem iostreams system)
34+
find_package(Boost 1.65.0 QUIET COMPONENTS ${BOOST_OPTIONAL_MODULES})
3035
find_package(Boost 1.65.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES})
3136

37+
if(Boost_SERIALIZATION_FOUND)
38+
set(BOOST_SERIALIZATION_FOUND TRUE)
39+
endif()
40+
3241
if(Boost_FOUND)
3342
set(BOOST_FOUND TRUE)
3443
endif()

cmake/pcl_pclconfig.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ foreach(_ss ${PCL_SUBSYSTEMS_MODULES})
8585
endforeach()
8686

8787
#Boost modules
88-
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "system filesystem iostreams")
88+
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "system iostreams")
89+
if(Boost_FILESYSTEM_FOUND)
90+
string(APPEND PCLCONFIG_AVAILABLE_BOOST_MODULES " filesystem")
91+
endif()
8992
if(Boost_SERIALIZATION_FOUND)
9093
string(APPEND PCLCONFIG_AVAILABLE_BOOST_MODULES " serialization")
9194
endif()
@@ -101,4 +104,4 @@ install(FILES
101104
"${PCL_BINARY_DIR}/PCLConfig.cmake"
102105
"${PCL_BINARY_DIR}/PCLConfigVersion.cmake"
103106
COMPONENT pclconfig
104-
DESTINATION ${PCLCONFIG_INSTALL_DIR})
107+
DESTINATION ${PCLCONFIG_INSTALL_DIR})

io/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${incs} ${c
343343

344344
target_include_directories(${LIB_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
345345

346-
target_link_libraries("${LIB_NAME}" Boost::boost Boost::filesystem Boost::iostreams pcl_common pcl_io_ply)
346+
target_link_libraries("${LIB_NAME}" Boost::boost Boost::iostreams pcl_common pcl_io_ply)
347+
if(TARGET Boost::filesystem)
348+
target_link_libraries("${LIB_NAME}" Boost::filesystem)
349+
endif()
347350

348351
if(VTK_FOUND)
349352
if(${VTK_VERSION} VERSION_GREATER_EQUAL 9.0)

outofcore/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ set(SUBSYS_NAME outofcore)
22
set(SUBSYS_DESC "Point cloud outofcore library")
33
set(SUBSYS_DEPS common io filters octree visualization)
44

5-
set(build TRUE)
6-
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
5+
if(NOT TARGET Boost::filesystem)
6+
set(DEFAULT FALSE)
7+
set(REASON "Boost filesystem is not available.")
8+
else()
9+
set(DEFAULT TRUE)
10+
endif()
11+
12+
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ${DEFAULT} "${REASON}")
713
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
814

915
PCL_ADD_DOC("${SUBSYS_NAME}")

recognition/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ set(SUBSYS_NAME recognition)
22
set(SUBSYS_DESC "Point cloud recognition library")
33
set(SUBSYS_DEPS common io search kdtree octree features filters registration sample_consensus ml)
44

5-
set(build TRUE)
6-
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
5+
if(${PCL_VERSION} VERSION_LESS "1.15.0" AND NOT TARGET Boost::filesystem)
6+
set(DEFAULT FALSE)
7+
set(REASON "Boost filesystem is not available.")
8+
else()
9+
set(DEFAULT TRUE)
10+
endif()
11+
12+
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ${DEFAULT} "${REASON}")
713
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
814

915
PCL_ADD_DOC("${SUBSYS_NAME}")

0 commit comments

Comments
 (0)