Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Boost CMake module #3731

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ if(WITH_OPENGL)
endif()

# Boost (required)
include("${PCL_SOURCE_DIR}/cmake/pcl_find_boost.cmake")
find_package(Boost REQUIRED)

### ---[ Create the config.h file
set(pcl_config_h_in "${CMAKE_CURRENT_SOURCE_DIR}/pcl_config.h.in")
Expand Down
16 changes: 0 additions & 16 deletions PCLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,7 @@ macro(find_boost)
set(Boost_USE_STATIC @Boost_USE_STATIC@)
set(Boost_USE_MULTITHREAD @Boost_USE_MULTITHREAD@)
endif()
set(Boost_ADDITIONAL_VERSIONS
"@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@.@Boost_SUBMINOR_VERSION@" "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@"
"1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70"
"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"
"1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60"
"1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55")
# Disable the config mode of find_package(Boost)
set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.55.0 ${QUIET_} COMPONENTS @PCLCONFIG_AVAILABLE_BOOST_MODULES@)

set(BOOST_FOUND ${Boost_FOUND})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this stop overriding the Boost_LIBRARIES variable for anyone consuming PCL? There's an issue open (and verified) which says that find_package(Boost) before find_package(PCL) causes PCL to override the Boost libraries

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what's the relationship of pcl_find_boost.cmake with Modules/FindBoost.cmake (because I notice it's untouched in this PR)

Copy link
Contributor Author

@shrijitsingh99 shrijitsingh99 May 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what's the relationship of pcl_find_boost.cmake with Modules/FindBoost.cmake (because I notice it's untouched in this PR)

That is to be removed.

Would this stop overriding the Boost_LIBRARIES variable for anyone consuming PCL? There's an issue open (and verified) which says that find_package(Boost) before find_package(PCL) causes PCL to override the Boost libraries

Currently, no. It should be possible though to append the already existing found components to the list of found components.

set(BOOST_INCLUDE_DIRS "${Boost_INCLUDE_DIR}")
set(BOOST_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}")
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
if(WIN32 AND NOT MINGW)
set(BOOST_DEFINITIONS ${BOOST_DEFINITIONS} -DBOOST_ALL_NO_LIB)
endif()
endmacro()

#remove this as soon as eigen is shipped with FindEigen.cmake
Expand Down
61 changes: 61 additions & 0 deletions cmake/Modules/FindBoost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# use static Boost in Windows
if(WIN32)
kunaltyagi marked this conversation as resolved.
Show resolved Hide resolved
set(Boost_USE_STATIC_LIBS @Boost_USE_STATIC_LIBS@)
set(Boost_USE_STATIC @Boost_USE_STATIC@)
set(Boost_USE_MULTITHREAD @Boost_USE_MULTITHREAD@)
endif()

# If we would like to compile against a dynamically linked Boost
if(PCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32 AND WIN32)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC OFF)
set(Boost_USE_MULTITHREAD ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB")
else()
if(NOT PCL_SHARED_LIBS OR WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC ON)
endif()
endif()

set(Boost_ADDITIONAL_VERSIONS
"1.71.0" "1.71" "1.70.0" "1.70"
"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"
"1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60"
"1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55")

# Disable the config mode of find_package(Boost)
set(Boost_NO_BOOST_CMAKE ON)

# Required boost modules
set(BOOST_OPTIONAL_MODULES serialization)
set(BOOST_REQUIRED_MODULES filesystem date_time iostreams system)

# Temporarily clean out CMAKE_MODULE_PATH, so that we can pick up the built-in Find-module from CMake:
set( CMAKE_MODULE_PATH_BAK ${CMAKE_MODULE_PATH} )
set( CMAKE_MODULE_PATH )

# Call CMake's own Find-module
find_package(Boost 1.55.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_MODULES})

set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH_BAK} )

if(Boost_SERIALIZATION_FOUND)
set(BOOST_SERIALIZATION_FOUND TRUE)
endif()

if(Boost_FOUND)
set(BOOST_FOUND TRUE)
# Obtain diagnostic information about Boost's automatic linking outputted
# during compilation time.
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
endif()

set(BOOST_INCLUDE_DIRS "${Boost_INCLUDE_DIR}")
set(BOOST_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}")
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
if(WIN32 AND NOT MINGW)
set(BOOST_DEFINITIONS ${BOOST_DEFINITIONS} -DBOOST_ALL_NO_LIB)
endif()
6 changes: 1 addition & 5 deletions cmake/pcl_pclconfig.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

set(PCL_SUBSYSTEMS_MODULES ${PCL_SUBSYSTEMS})
list(REMOVE_ITEM PCL_SUBSYSTEMS_MODULES tools cuda_apps global_tests proctor examples)

Expand Down Expand Up @@ -78,12 +77,9 @@ endforeach()

#Boost modules
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "system filesystem date_time iostreams")
if(Boost_SERIALIZATION_FOUND)
if(BOOST_SERIALIZATION_FOUND)
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "${PCLCONFIG_AVAILABLE_BOOST_MODULES} serialization")
endif()
if(Boost_CHRONO_FOUND)
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "${PCLCONFIG_AVAILABLE_BOOST_MODULES} chrono")
endif()

configure_file("${PCL_SOURCE_DIR}/PCLConfig.cmake.in"
"${PCL_BINARY_DIR}/PCLConfig.cmake" @ONLY)
Expand Down