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 directory of library's header as the include directory #220

Merged
merged 1 commit into from
May 18, 2024

Conversation

grosscol
Copy link
Contributor

Avoid having consumers need to know or declare internal structure of project.

E.g. a project that is using this library could then get the library using FetchContent_Declare

FetchContent_Declare(
  csv  
  GIT_REPOSITORY https://github.com/vincentlaucsb/csv-parser.git
  GIT_SHALLOW TRUE 
  GIT_TAG 2.1.3 
) 

Then use the this library without having to worry about the specifics of where it's located.

target_include_directories(my_project
  PUBLIC
    ${CMAKE_SOURCE_DIR}/include
  PRIVATE
    csv
) 

target_link_libraries(my_project PRIVATE csv)

This would also greatly simplify including this in an existing project as the user would not have to manually clone the repo as if it were part of the code base they're maintaining.

Avoid having consumers need to know or declare internal structure of project.

Facilitate use with `FetchContent_Declare` to get the repo and then simply use `target_include_directories( their_proj PRIVATE csv)`.
Copy link
Owner

@vincentlaucsb vincentlaucsb left a comment

Choose a reason for hiding this comment

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

Thanks for your PR. I just whipped up a quick CMake project using FetchContent_Declare and this small change makes integrating my library significantly simpler.

@vincentlaucsb vincentlaucsb merged commit 6d40fe8 into vincentlaucsb:master May 18, 2024
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.

2 participants