diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e091639edc..8ee2c26bfa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -471,7 +471,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") diff --git a/PCLConfig.cmake.in b/PCLConfig.cmake.in index 9f78fcfa066..1c4d721c570 100644 --- a/PCLConfig.cmake.in +++ b/PCLConfig.cmake.in @@ -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.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}) - 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 diff --git a/cmake/Modules/FindBoost.cmake b/cmake/Modules/FindBoost.cmake new file mode 100644 index 00000000000..66c872d6590 --- /dev/null +++ b/cmake/Modules/FindBoost.cmake @@ -0,0 +1,62 @@ + +# 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() + +# use static Boost in Windows +if(WIN32) + set(Boost_USE_STATIC_LIBS @Boost_USE_STATIC_LIBS@) + set(Boost_USE_STATIC @Boost_USE_STATIC@) + set(Boost_USE_MULTITHREAD @Boost_USE_MULTITHREAD@) +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 mpi) # MPI needed? +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() diff --git a/cmake/pcl_pclconfig.cmake b/cmake/pcl_pclconfig.cmake index 2332eafc020..4fb794d7173 100644 --- a/cmake/pcl_pclconfig.cmake +++ b/cmake/pcl_pclconfig.cmake @@ -1,4 +1,3 @@ - set(PCL_SUBSYSTEMS_MODULES ${PCL_SUBSYSTEMS}) list(REMOVE_ITEM PCL_SUBSYSTEMS_MODULES tools cuda_apps global_tests proctor examples) @@ -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)