Using this lib over FetchContent
rafaeldelboni opened this issue · 5 comments
I'm trying to use your libs over cmake's FetchContent like so:
# Download / Include Commons libs SC
FetchContent_Declare(
sc_lib
GIT_REPOSITORY https://github.com/tezc/sc.git
GIT_TAG master)
FetchContent_MakeAvailable(sc_lib)
Then when I try to link the sc_str
in my build
target_link_libraries(
disassembler
constants
sc_str
)
I get this error:
...
CMake Error at src/CMakeLists.txt:11 (target_link_libraries):
Target "sc_str" of type EXECUTABLE may not be linked into another target.
One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
executables with the ENABLE_EXPORTS property set.
...
Hi,
I'm not familiar with FetchContent unfortunately, I'll take a look though.
To make source distribution easier, folders are independent. If you want to use sc_str, you just copy sc_str.h sc_str.c to your project. At least, this is how I use these libraries in my projects, I just copy pieces I want. Doesn't this work for you?
I use CMake just for testing, it doesn't build .a or .so file.
Edit : Just to clarify, library distribution is drag & drop source and header files. If you want map, copy sc_map.h sc_map.c to your project. I did this deliberately not to deal with library build process. I think what FetchContent trying to do is, pull code & build & link to your project, this is why it doesn't work, I don't build library for sc_* files in Cmake files.
Hi @tezc, thanks for your input,
I was able to make it work in my fork I did a PR to you check how I made, feel free to ignore or close it.
I know is super simple just copy and paste the libs in my project, but feels a little bit more modern to add as a downloadable dependency, in this way I can do better version control and even ignore lib files from my project git.
If you interested about cmake FetchContent I made a little boilerplate where I download a test library using it.
Anyways is just a suggestion thanks for your attention and libraries it will help me a lot :)
Best Regards
Thanks a lot for the PR. I really appreciate it. I'll merge another PR for a few things and create a release tag, if FetchContent is being used for version control, that will help people who use FetchContent I believe.
Let me know if you have any issues while using libs :)
Cheers.
I've created v1.0.0 tag. I will keep api stable for major versions.
Thanks a lot! :)