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

Issues with CMake and FetchContent_Declare #53

Open
bensuperpc opened this issue Nov 17, 2021 · 2 comments
Open

Issues with CMake and FetchContent_Declare #53

bensuperpc opened this issue Nov 17, 2021 · 2 comments

Comments

@bensuperpc
Copy link

bensuperpc commented Nov 17, 2021

I tried using this project with my CMakefile but it doesn't work

include(FetchContent)
FetchContent_Declare(
  safestringlib
  GIT_REPOSITORY https://github.com/intel/safestringlib.git
  GIT_TAG master)
  
set(BUILD_UNITTESTS
OFF
CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(safestringlib)
target_link_libraries(crc32_crc32 PRIVATE safestringlib)

I have these errors:

/crc32/crc32.h:20:10: erreur fatale: safe_lib.h : Aucun fichier ou dossier de ce type
   20 | #include "safe_lib.h"
      |          ^~~~~~~~~~~~
/crc32/crc32.h:20:10: erreur fatale: safe_str_lib.h : Aucun fichier ou dossier de ce type
   20 | #include "safe_str_lib.h"
      |          ^~~~~~~~~~~~
@matyalatte
Copy link

It might be too late but I'll put my answer.

See CMakeLists.txt for the library names.

project(safestring)

︙

add_library(${PROJECT_NAME}_shared SHARED $<TARGET_OBJECTS:${PROJECT_NAME}_objlib>)
add_library(${PROJECT_NAME}_static STATIC $<TARGET_OBJECTS:${PROJECT_NAME}_objlib>)

safestring_shared and safestring_static are the available libraries.

So, you should use
target_link_libraries(crc32_crc32 PRIVATE safestring_shared)
or
target_link_libraries(crc32_crc32 PRIVATE safestring_static)

@LecrisUT
Copy link

Making a project be FetchContent compatible is a bit nuanced. There are issues like namespacing options. I would recommend a review of the whole build system to adapt to modern CMake standards.

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

No branches or pull requests

3 participants