Boost link UUID using CMake

232 Views Asked by At

I'm trying to include just the uuid part of the boost library into a project using CMake. This is the repo https://github.com/boostorg/uuid . When running cmake I get the following error:

CMake Error at third-party/uuid/CMakeLists.txt:15 (target_link_libraries):



The link interface of target "boost_uuid" contains:

    Boost::assert

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Which means that the assert and other dependencies are missing. How are these dependencies supposed to be installed?(Other than installing boost into the system) I would have expected them to be linked as submodules, but it isn't the case.

1

There are 1 best solutions below

0
On

If you want to integrate Boost libraries into your project as a CMake subtree, it is recommended to add Boost superproject. This repository has all Boost libraries and tools as its submodules, which will allow all dependencies between libraries to resolve. You will be able to add the superproject in your source tree using add_subdirectory CMake command and then add Boost::* targets with target_link_libraries. This will automatically add the necessary include paths to the compiler command line.

If you want to integrate only a subset of Boost libraries then you will need to manually checkout all dependencies of the libraries you need, recursively. Peter Dimov's dependency reports can be useful to gather the list of dependencies. For example, for Boost.UUID 1.82 the list of dependencies is here. Effectively, you will have to reproduce a subset of Boost superproject in your tree and maintain it as you update to the newer Boost releases.