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

Provide CMake imported targets instead of variables #243

Open
ras0219-msft opened this issue Sep 20, 2016 · 0 comments
Open

Provide CMake imported targets instead of variables #243

ras0219-msft opened this issue Sep 20, 2016 · 0 comments

Comments

@ras0219-msft
Copy link
Contributor

From microsoft/vcpkg#6 (comment), Orphis wrote:

In modern CMake, you are not supposed to give the user a list of variables but an imported target you use directly with "target_link_libraries".
It's a bit sad to see the example requiring CMake 3.0 but using patterns from CMake 2.6 dating from the CMake stone age.
https://cmake.org/cmake/help/v3.6/command/add_library.html#imported-libraries

find_library(CPPREST_LIBRARY cpprest_2_8)
find_path(CPPREST_INCLUDE_DIR cpprest/version.h)
include_directories(${CPPREST_INCLUDE_DIR})
link_libraries(${CPPREST_LIBRARY})

You should be providing instead something like "find_package(vcpkg::cpprest_2_8 REQUIRED)" and then have people link against the target "vcpkg::cpprest_2_8".
You can generate files for find_package directly that create the imported targets for you.
The pkg-config CMake support upstream has been doing that.

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

1 participant