Skip to content

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

Open
paulfd wants to merge 1 commit into
rogersce:masterfrom
paulfd:master
Open

Adding target options to cnpy-static to be linked against as a subdirectory module#50
paulfd wants to merge 1 commit into
rogersce:masterfrom
paulfd:master

Conversation

@paulfd
Copy link
Copy Markdown

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

Comment thread CMakeLists.txt
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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