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

Conversation

paulfd
Copy link

@paulfd paulfd commented Aug 9, 2019

Hi,

I added a couple lines in the CMakeFiles.txt to be able to build against the static library. It works when the library is built using add_subdirectory and should not impact existing targets.

@@ -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?

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