Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

CMake configure incompatible with Boost CMake config files #265

Open
Flamefire opened this issue Jul 5, 2021 · 0 comments
Open

CMake configure incompatible with Boost CMake config files #265

Flamefire opened this issue Jul 5, 2021 · 0 comments

Comments

@Flamefire
Copy link

Flamefire commented Jul 5, 2021

CMake and Boost are moving to targets. Hence if you want to use e.g. Boost.ProgramOptions you have to target_link_libraries(target PUBLIC Boost::program_options) which always works

However here you only link the executable (and not also the libraries) to the boost libraries and use the (discouraged) include_directories("${Boost_INCLUDE_DIRS}") which is problematic:

  • Quoting the value may not expand a list of directories -> Remove the quotes
  • It might be empty (e.g. for the Boost CMake config option) -> Empty value added, again: Remove the quotes
  • It only works with the legacy FindBoost which doesn't work well going forward -> Use target_link_libraries as suggested above INSTEAD

Bottom line: Do not use functions like include_directories where a target_* function exists. Also use target_link_libraries to declare the dependencies of your targets (the naming is a bit misleading, it is not necessarily "linking" but declaring a dependency to another target which may imply linking or "just" adding header paths)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant