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

set the cmake install interface directories on the library targets #196

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

hsitter
Copy link
Contributor

@hsitter hsitter commented Dec 2, 2019

the cmake package gets imported targets generated for use by API consumers.

so they can do

target_link_libraries(myapp KDSoap::kdsoap)

in their cmake code and because KDSoap::kdsoap is an imported target cmake
automatically knows where to find the library. alas, since we didn't
set an interface directory cmake did not know where to find the relevant
headers.
this isn't a problem so long as they are in one of the standard search
paths (e.g. /usr/include), but when the are installed elsewhere (e.g.
/opt/kdsoap/include) they will not be found.

by explicitly setting the INSTALL_INTERFACE to INSTALL_INCLUDE_DIR the
generated KDSoapTargets.cmake will set the relevant path on the target
and thus allow idiomatic use of the imported target without having to
mess with include dirs manually.

the cmake package gets imported targets generated for use by API consumers.

so they can do

```
target_link_libraries(myapp KDSoap::kdsoap)
```

in their cmake code and because KDSoap::kdsoap is an imported target cmake
automatically knows where to find the library. alas, since we didn't
set an interface directory cmake did not know where to find the relevant
headers.
this isn't a problem so long as they are in one of the standard search
paths (e.g. /usr/include), but when the are installed elsewhere (e.g.
/opt/kdsoap/include) they will not be found.

by explicitly setting the INSTALL_INTERFACE to INSTALL_INCLUDE_DIR the
generated KDSoapTargets.cmake will set the relevant path on the target
and thus allow idiomatic use of the imported target without having to
mess with include dirs manually.
@Pointedstick
Copy link

+1, fixes the issue for me with a self-compiled library.

Copy link
Member

@dfaure-kdab dfaure-kdab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe, I review code by the same people on my KDE time at home and on my KDAB time at work :)
Small world.

This change is obviously correct and very much wanted indeed. I teach people to do that in my cmake trainings :-)

@dfaure-kdab dfaure-kdab merged commit c095f17 into KDAB:master Dec 3, 2019
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

Successfully merging this pull request may close these issues.

3 participants