[CMake] [PATCH] FindBoost does not detect absence of header file
rleigh at codelibre.net
rleigh at codelibre.net
Wed May 11 10:38:44 EDT 2016
On 2016-04-12 11:22, Joachim Wuttke wrote:
> FindBoost does not detect absence of header files.
>
> To be specific: Run the following under cmake version 3.5.1:
>
> set(Boost_NO_BOOST_CMAKE ON) # prevent shortcut
> set(Boost_USE_STATIC_LIBS OFF)
> set(Boost_USE_MULTITHREADED ON)
> set(Boost_USE_STATIC_RUNTIME OFF)
> add_definitions(-DBOOST_ALL_DYN_LINK) # line is needed for MSVC
> #add_definitions(-DBOOST_LIB_DIAGNOSTIC) # shows during compilation
> auto-linked libraries
> if(WIN32)
> set(boost_libraries_required date_time chrono program_options zlib
> bzip2 iostreams system filesystem regex thread)
> else()
> set(boost_libraries_required date_time chrono program_options
> iostreams system filesystem regex thread)
> endif()
> find_package(Boost 1.48.0 COMPONENTS ${boost_libraries_required}
> REQUIRED)
> message(STATUS "--> Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
> message(STATUS " Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
> message(STATUS " Boost_LIBRARIES: ${Boost_LIBRARIES}")
>
> It will pass, even if files like /usr/include/boost/date_time.hpp &c
> are removed
> from the system.
Attached is a patch to add this extra checking.
For each library component, there is a corresponding header which has
been present in all versions of boost to date which provide the library;
the list used to validate this is also attached. I have also validated
that each component works with find_package for Boost 1.58 and 1.60.
If your system contains both the libraries and headers, then FindBoost
will behave exactly as before. But if you have the libraries without
the headers, FindBoost will now fail, rather than passing and then
having the build subsequently fail when it tries to use the nonexistent
headers. So it's essentially adding an additional header check per
component, which will identify situations where the user has an
incomplete Boost installation e.g. no all the -dev packages are
installed.
I can merge this into next for testing, but if anyone wanted to have an
initial play with it to verify that it's still functional and that the
approach is sound, I can wait off for now.
Regards,
Roger
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-FindBoost-Add-checks-for-component-specific-headers.patch
Type: text/x-diff
Size: 6669 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160511/a35ec55a/attachment-0001.patch>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: boost-header-versions.txt
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160511/a35ec55a/attachment-0001.txt>
More information about the CMake
mailing list