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

CMake - find_boost preprocessor symbol on Windows. PCL 1.12.1 #5205

Closed
ghost opened this issue Mar 14, 2022 · 3 comments · Fixed by #5221
Closed

CMake - find_boost preprocessor symbol on Windows. PCL 1.12.1 #5205

ghost opened this issue Mar 14, 2022 · 3 comments · Fixed by #5221

Comments

@ghost
Copy link

ghost commented Mar 14, 2022

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:

string(APPEND BOOST_DEFINITIONS -DBOOST_ALL_NO_LIB)

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

string(APPEND BOOST_DEFINITIONS -DBOOST_ALL_NO_LIB)

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"
@ghost ghost added kind: bug Type of issue status: triage Labels incomplete labels Mar 14, 2022
@UnaNancyOwen
Copy link
Member

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

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Apr 10, 2022

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
Copy link
Member

UnaNancyOwen commented Apr 10, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant