Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost_LIBRARIES not defined

Tags:

boost

cmake

I am trying to compile FreeLing, that uses CMake to detect Boost. This is the code responsible for it:

  find_package(Boost COMPONENTS regex filesystem thread program_options REQUIRED)

These components are found (accordingly to the output generated by CMake):

-- Found Boost 1.70.0 at /home/ambs/usr/lib/cmake/Boost-1.70.0
--   Requested configuration: QUIET REQUIRED COMPONENTS regex;filesystem;thread;program_options
-- Found boost_headers 1.70.0 at /home/ambs/usr/lib/cmake/boost_headers-1.70.0
-- Found boost_regex 1.70.0 at /home/ambs/usr/lib/cmake/boost_regex-1.70.0
--   libboost_regex.so.1.70.0
-- Adding boost_regex dependencies: headers
-- Found boost_filesystem 1.70.0 at /home/ambs/usr/lib/cmake/boost_filesystem-1.70.0
--   libboost_filesystem.so.1.70.0
-- Adding boost_filesystem dependencies: headers
-- Found boost_thread 1.70.0 at /home/ambs/usr/lib/cmake/boost_thread-1.70.0
--   libboost_thread.so.1.70.0
-- Adding boost_thread dependencies: headers
-- Found boost_program_options 1.70.0 at /home/ambs/usr/lib/cmake/boost_program_options-1.70.0
--   libboost_program_options.so.1.70.0
-- Adding boost_program_options dependencies: headers
-- Boost  found.
-- Found Boost components:
   regex;filesystem;thread;program_options

Nevertheless, it looks like Boost_LIBRARIES is never set. I tried this:

  find_package(Boost COMPONENTS regex filesystem thread program_options REQUIRED)
  message(STATUS "Boost_LIBRARIES=" ${Boost_LIBRARIES})

and it output always a empty string.

For reference, I have CMake version 3.14.3, and Boost version 1.70.0.

like image 995
Alberto Avatar asked May 08 '19 08:05

Alberto


1 Answers

The line

Found Boost 1.70.0 at /home/ambs/usr/lib/cmake/Boost-1.70.0

means that CMake module FindBoost.cmake doesn't detects Boost libraries and headers using its own methods but resorts to BoostConfig.cmake script, located in the directory shown in the log.

Documentation for FindBoost.cmake module notes such way:

This module finds headers and requested component libraries OR a CMake package configuration file provided by a “Boost CMake” build. For the latter case skip to the “Boost CMake” section below. For the former case results are reported in variables:

In short, using BoostConfig.cmake script means that it sets its own variables or targets, and ones described in the documentation for FindBoost.cmake are not valid.

Most likely, the "Config" file sets IMPORTED targets in the same manner, as described in FindBoost.cmake documentation, that is Boost::regex, Boost::filesystem and so on.


If you want to disable using BoostConfig.cmake and force FindBoost.cmake to behave as described in its documentation, set Boost_NO_BOOST_CMAKE variable. E.g., when call cmake:

cmake -DBoost_NO_BOOST_CMAKE=ON <other-options>
like image 158
Tsyvarev Avatar answered Nov 03 '22 02:11

Tsyvarev