Skip to content

Boost library link dependencies are incorrect #141

Open
@BenWhetton

Description

@BenWhetton
  • I've read Brief overview section and do understand basic concepts. [Yes]
  • I've read F.A.Q. section and there is no solution to my problem there. [Yes]
  • I've read Code of Conduct, I promise to be polite and will do my best at being constructive. [Yes]
  • I've read Reporting bugs section carefully. [Yes]
  • I've checked that all the hunter_add_package/find_package API used by me in the example is the same as in documentation. [Yes]
  • I'm using latest Hunter URL/SHA1. [Yes]
  • I've created SSCCE reproducing the issue:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.16.2)
include(CMakePrintHelpers)
include("cmake/HunterGate.cmake")

HunterGate(URL "https://github.com/cpp-pm/hunter/archive/v0.23.244.tar.gz"
           SHA1 "2c0f491fd0b80f7b09e3d21adb97237161ef9835"
           LOCAL)

project(test_hunter_boost_log)

hunter_add_package(Boost COMPONENTS log)
find_package(Boost CONFIG REQUIRED log)

cmake_print_properties(
        TARGETS Boost::log
        PROPERTIES INTERFACE_LINK_LIBRARIES
)

(cmake/Hunter/config.cmake contains hunter_config(Boost VERSION 1.71.0-p0) to avoid issues with boost 1.72)

Here is the log until first error reported by Hunter, option HUNTER_STATUS_DEBUG is OFF (it doesn't add anything):

-- [hunter] Calculating Toolchain-SHA1
-- [hunter] Calculating Config-SHA1
-- [hunter] HUNTER_ROOT: /export/home/ben.whetton/.hunter
-- [hunter] [ Hunter-ID: 2c0f491 | Toolchain-ID: 511a137 | Config-ID: 3aaac7f ]
-- [hunter] BOOST_ROOT: /export/home/ben.whetton/.hunter/_Base/2c0f491/511a137/3aaac7f/Install (ver.: 1.71.0-p0)
-- [hunter] BOOST_ROOT: /export/home/ben.whetton/.hunter/_Base/2c0f491/511a137/3aaac7f/Install (ver.: 1.71.0-p0)
-- Boost version: 1.71.0
-- Found the following Boost libraries:
--   log
-- 
 Properties for TARGET Boost::log:
   Boost::log.INTERFACE_LINK_LIBRARIES = "Boost::boost"

-- Configuring done
-- Generating done
-- Build files have been written to: /export/home/ben.whetton/project/cpp/test_hunter_boost_log/cmake-build-debug-neptune

[Finished]

As you can see, Boost::log only links to Boost::boost, which is not correct.

  • I'm building on [Linux].
  • [I'm using official CMake release]
  • CMake version: <3.16.2>
  • I'm not using toolchain (I don't think it's relevant)

I'm using the next command line on generate step:

cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles"

As you can see, hunter doesn't find and link dependent libraries.

On the other hand, if we link to system boost without using Hunter, it finds all the correct link dependencies:

cmake_minimum_required(VERSION 3.16.2)
project(test_boost_log)
include(CMakePrintHelpers)

find_package(Boost REQUIRED log)

cmake_print_variables(Boost_VERSION_STRING)
cmake_print_properties(
        TARGETS Boost::log
        PROPERTIES INTERFACE_LINK_LIBRARIES
)
-- Found Boost: /usr/include (found version "1.65.1") found components: log date_time log_setup system filesystem thread regex chrono atomic 
-- Boost_VERSION_STRING="1.65.1"
-- 
 Properties for TARGET Boost::log:
   Boost::log.INTERFACE_LINK_LIBRARIES = "Boost::date_time;Boost::log_setup;Boost::system;Boost::filesystem;Boost::thread;Boost::regex;Boost::chrono;Boost::atomic"

-- Configuring done
-- Generating done
-- Build files have been written to: /export/home/ben.whetton/project/cpp/test_boost_log/cmake-build-debug

This is a major issue because Boost libraries must be linked in specific orders to avoid linking errors and CMake may optimise the linking order and break the build in the process if there are no explicit link dependencies between libraries.

It looks like CMake's FindBoost.cmake file contains logic for setting the dependencies up correctly. I think Boost are also implementing find CONFIG mode support from v1.70.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions