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

Adding target options to cnpy-static to be linked against as a subdirectory module #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ install(TARGETS "cnpy" LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRIT

if(ENABLE_STATIC)
add_library(cnpy-static STATIC "cnpy.cpp")
target_link_libraries(cnpy-static PUBLIC ${ZLIB_LIBRARIES})
target_include_directories(cnpy-static PUBLIC ".")
Copy link
Owner

Choose a reason for hiding this comment

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

Can we remove this line or is it necessary? I can build on my machine w/o it.

Copy link
Owner

Choose a reason for hiding this comment

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

specifically, the target_include_directories command

Copy link
Author

Choose a reason for hiding this comment

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

Can you build when including it as a subdirectory?

My CMakeFiles looks like this, more or less...

add_subdirectory(external/cnpy)
[...]
add_executable(tests ${SOURCES})
target_link_libraries(tests Catch2::Catch2 cnpy-static gsl::gsl-lite)

I may be doing it wrong though :) I clone cnpy as a submodule and include it this way, is there a better approach?

set_target_properties(cnpy-static PROPERTIES OUTPUT_NAME "cnpy")
install(TARGETS "cnpy-static" ARCHIVE DESTINATION lib)
endif(ENABLE_STATIC)
Expand Down