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

Export generated defines directory #268

Merged
merged 1 commit into from
Jun 12, 2018
Merged

Conversation

MaxSavenkov
Copy link
Contributor

This will make the library usable via add_subdirectory from another CMake-based project (without this change, the build fails because it can't find the header with generated defines).

…a add_subdirectory from another CMake-based project
@KjellKod
Copy link
Owner

Thanks. Looks good. Pending verification

@KjellKod
Copy link
Owner

KjellKod commented Jun 5, 2018

@MaxSavenkov can you describe in this PR how this would be used? I think you mentioned this earlier but I cannot find it. I need this information to be able to replicate the issue and the solution to the issue.

Thanks

@MaxSavenkov
Copy link
Contributor Author

@KjellKod

Issue: currently, if you try to use g3log as a sub-project in your CMakeLists.txt by using add_subdirectory and target_link_library( my_project PRIVATE g3log ) command, and use g3log in that project by including its header, you will not be able to compile the resulting project, because the main g3log's header would include a generated g3log header, yet the path where generated headers reside is not propagated from sub-project to the main project.

Solution: added a directive for CMake to export the path to generated files (in addition to currently exported path to static header files), so when g3log is imported from another CMakeLists.txt, all necessary include directories will also be imported.

Result: g3log can now be used via add_subdirectory/target_link_library in CMake, without the need to install the library into system or manually specify necessary paths.

Copy link
Owner

@KjellKod KjellKod left a comment

Choose a reason for hiding this comment

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

👍

@KjellKod KjellKod merged commit 5ffb360 into KjellKod:master Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants