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

Add CMake Interface Library #258

Closed
jwillikers opened this issue Dec 26, 2019 · 2 comments
Closed

Add CMake Interface Library #258

jwillikers opened this issue Dec 26, 2019 · 2 comments

Comments

@jwillikers
Copy link
Contributor

jwillikers commented Dec 26, 2019

I am very interested in using your library. I would like to use FetchContent and have access to your library through add_subdirectory. However, your library does not create a convenience target to use with target_link_libraries. While it is little effort for me to add the necessary include directory myself, I would much rather just "link" against your header only library like so:

target_link_libraries(MyTarget PRIVATE Boost::ut)

I have included an import prefix to mirror Boost's component linking behavior.
Defining an interface library through CMake with the appropriate include directories will make this possible.
The changes might look like the following.

add_library(ut INTERFACE)
add_library(Boost::ut ALIAS ut)
target_include_directories(ut INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)

This code also paves the way for the interface target to be exported and included with find_package.

@krzysztof-jusiak
Copy link
Contributor

Thanks, @athrun22, it should be fixed now, let me know if it works for you 🤔

@jwillikers
Copy link
Contributor Author

@krzysztof-jusiak, thanks! The interface library works perfectly 😃😃😃

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

2 participants