intel / safestringlib

Other
355 stars 87 forks source link

Issues with CMake and FetchContent_Declare #53

Open bensuperpc opened 3 years ago

bensuperpc commented 3 years ago

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 commented 2 years ago

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 commented 1 month ago

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.