pcl icon indicating copy to clipboard operation
pcl copied to clipboard

CMake - find_boost preprocessor symbol on Windows. PCL 1.12.1

Open pmdifran opened this issue 3 years ago • 3 comments

On Windows, running find_package( PCL 1.12.1 REQUIRED ) in a downstream CMake project produces invalid Boost preprocessors in MSVS: BOOST_ALL_NO_LIB-DBOOST_ALL_NO_LIB

It's very simple to fix this issue manually. I'm not sure if this is simply a result of my environment.

Environment

  • OS: Windows 10,Pro 19044.1526
  • Microsoft Visual C++ 14.29
  • PCL Version 1.12.1

To Reproduce: (1) download PCL 1.12.1 Windows installer; (2) run simple downstream CMake project:

cmake_minimum_required( VERSION 3.12 )
project( foo LANGUAGES CXX)
set(SOURCE
    main.cpp
)
add_executable( foo ${SOURCE} )

find_package( PCL 1.12.0 REQUIRED )
if( PCL_FOUND )
  include_directories( ${PCL_INCLUDE_DIRS} )
  add_definitions( ${PCL_DEFINITIONS} )
  link_directories( ${PCL_LIBRARY_DIRS} )
  target_link_libraries( foo PUBLIC ${PCL_LIBRARIES} )
endif()

It looks like this line is problematic with find_boost, and it is getting called numerous times: https://github.com/PointCloudLibrary/pcl/blob/a26f6d427cbaac997e5948055347bc52f67f9fd9/PCLConfig.cmake.in#L110

PCL 1.12.1 full list of preprocessors:

%(PreprocessorDefinitions)
WIN32
_WINDOWS
BOOST_ALL_NO_LIB-DBOOST_ALL_NO_LIB
__SSE4_2__
__SSE4_1__
__SSSE3__
__SSE3__
__SSE2__
__SSE__
BOOST_ALL_NO_LIB
DISABLE_QHULL
BOOST_SYSTEM_NO_LIB
BOOST_FILESYSTEM_NO_LIB
BOOST_ATOMIC_NO_LIB
BOOST_DATE_TIME_NO_LIB
BOOST_IOSTREAMS_NO_LIB
BOOST_SERIALIZATION_NO_LIB
kiss_fft_scalar=double
KISSFFT_DLL_IMPORT=1
CMAKE_INTDIR="Debug"

PCL 1.12.0 full list of preprocessors (for reference):

%(PreprocessorDefinitions)
WIN32
_WINDOWS
__SSE4_2__
__SSE4_1__
__SSSE3__
__SSE3__
__SSE2__
__SSE__
BOOST_ALL_NO_LIB
CMAKE_INTDIR="Debug"

Troubleshooting Replacing https://github.com/PointCloudLibrary/pcl/blob/a26f6d427cbaac997e5948055347bc52f67f9fd9/PCLConfig.cmake.in#L110 with string(APPEND BOOST_DEFINITIONS " -DBOOST_ALL_NO_LIB") still produces an invalid preprocessor:

%(PreprocessorDefinitions)
WIN32
_WINDOWS
BOOST_ALL_NO_LIB
__SSE4_2__
__SSE4_1__
__SSSE3__
__SSE3__
__SSE2__
__SSE__
DISABLE_QHULL
-DBOOST_ALL_NO_LIB         ---->here
BOOST_SYSTEM_NO_LIB
BOOST_FILESYSTEM_NO_LIB
BOOST_ATOMIC_NO_LIB
BOOST_DATE_TIME_NO_LIB
BOOST_IOSTREAMS_NO_LIB
BOOST_SERIALIZATION_NO_LIB
kiss_fft_scalar=double
KISSFFT_DLL_IMPORT=1
CMAKE_INTDIR="Debug"

pmdifran avatar Mar 14 '22 04:03 pmdifran

I have confirmed that this problem can be reproduced. 2022-04-10_09h48_55

UnaNancyOwen avatar Apr 10 '22 00:04 UnaNancyOwen

It may be a problem with the Boost upgrade. This problem does not occur in PCL 1.11 with Boost 1.74.0 linked. It seems that we have to do something support to new Boost (at least it seems so Boost 1.78). @kunaltyagi @larshg Can anyone investigate this issue? Thanks,

  • PCL 1.11.1 All-in-one Installer : Boost 1.74.0
  • PCL 1.12.1 All-in-one Installer : Boost 1.78.0

2022-04-10_10h15_42

UnaNancyOwen avatar Apr 10 '22 01:04 UnaNancyOwen

It is very time consuming to investigate which version contains the problem. Therefor, I propose the following workaround. It only adds BOOST_ALL_NO_LIB at the first time.

- if(WIN32 AND NOT MINGW)
+ if(WIN32 AND NOT MINGW AND NOT "${BOOST_DEFINITIONS}" MATCHES "BOOST_ALL_NO_LIB")
    string(APPEND BOOST_DEFINITIONS -DBOOST_ALL_NO_LIB)
  endif()

The preprocessor macros defined by this workaround are as follows. There seems to be no problem. 2022-04-10_10h59_25

UnaNancyOwen avatar Apr 10 '22 02:04 UnaNancyOwen