Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please follow Modern CMake conventions: It's all about targets! #698

Open
helmesjo opened this issue Dec 23, 2017 · 3 comments
Open

Please follow Modern CMake conventions: It's all about targets! #698

helmesjo opened this issue Dec 23, 2017 · 3 comments

Comments

@helmesjo
Copy link

helmesjo commented Dec 23, 2017

Modern CMake is all about targets. You define targets & link against targets. You should never, ever use commands such as include_directories, link_directories etc, not even "internally-only".
As a rule of thumb, when working with targets (created with add_library), only use commands prefixed with target_. And use PRIVATE, PUBLIC & INTERFACE accordingly.
Building myapp should only required target_link_libraries(myapp PRIVATE mydependency). If it fails to build because of mydependency, then mydependency is not setup correctly and must be fixed. Nothing should have to be changed in myapp.

Similar goes for find_package, please restrict usage of "magic" & package specific variables (eg. Boost_INCLUDE_DIR). Use only those that are package agnostic. See here for a list.

Failing to do this, and more specifically failing to follow up-to-date CMake best practices, makes it very hard to supply the required dependencies (eg. Boost), and ultimately to consume websocketpp.

With that said, thanks for an otherwise great library!

@Nadav-Ruskin
Copy link

yes please

@OvermindDL1
Copy link

To see proper usages of target, a modern CMake tutorial is at: https://cgold.readthedocs.io/

@epicstar
Copy link

Please please do this.... I've had to make my own *.cmake files and force CMake to ignore the currently generated cmake file so that our library we make can install correctly and be easily consumed.

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

No branches or pull requests

4 participants