Boost logo

Boost :

From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2021-07-16 08:28:34


> when it comes to boost integration - would be great to have some
> HOW-to-do-it correct tutorial
Sure:
find_package(Boost 1.71.0 REQUIRED COMPONENTS unit_test_framework) #
Optionally with CONFIG if you require a recent enough Boost
target_link_libraries(foo PUBLIC Boost::unit_test_framework)

Done. Nothing more than that. Plus it pretty much works for EVERY dependency

> and the current solution is how i though it should be done (while
> fighting with my co-workers)
Your current solution uses variables: target_link_libraries(test
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
Replace that by the target, then you are fine
> now i need to make my other co-workers understand that
Tell them this: OOP is key. OOP in CMake means targets. Work with
targets and target_* functions, not e.g. `include_directories`
> it works with and without lib/cmake but i also got the feeling that its
> not correct - thanks
> so its just the path i used with --stagedir= while building boost
This is documented in the CMake docs, that CMake searchs the
<PREFIX>/lib/cmake folder:
https://cmake.org/cmake/help/v3.9/command/find_package.html#command:find_package
> the hardcoded path are only in this example - normaly these are based on
> cmake command line parameters or environment variables
Try to avoid touching  CMAKE_PREFIX_PATH in a CML unless you install
stuff in the same CMake to that path. Require users to export that env
variable instead.
This makes your files more portable. Having to set different env vars
for every software you install makes a mess.




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk