facebook/zstd

Building libzstd as part of larger cmake project using add_directory(zstd/build/cmake) does not work

Open

#3758 aperta il 15 set 2023

Vedi su GitHub
 (1 commento) (1 reazione) (0 assegnatari)C (2481 fork)batch import
buildhelp wanted

Metriche repository

Star
 (27.100 star)
Metriche merge PR
 (Merge medio 50m) (2 PR mergiate in 30 g)

Descrizione

Describe the bug The cmake file under build/cmake/ is missing these under static and shared library creation which prevent the inclusion libzstd_static or libzstd_shared targets into another project that uses libzstd. By adding these lines (marked with +):

if (ZSTD_BUILD_STATIC)
    add_library(libzstd_static STATIC ${Sources} ${Headers})
+    target_include_directories(libzstd_static
+        PUBLIC $<BUILD_INTERFACE:${LIBRARY_DIR}>
+        INTERFACE $<BUILD_INTERFACE:${LIBRARY_DIR}/common>
      ) 

the project using libzstd_static can find header files when the new project linked with zstdlib using in target_link_libraries(${TEST_APP} PRIVATE libzstd_static)

Same fix is also required for ZSTD_BUILD_SHARED. Without this fix, during the build, the project depending on libzstd will not compile because it cannot find libzstd headers.

Found out when cross compiling mcap library for custom linux and mcap is using zstdlib 1.4.7 and cmake 3.22.1 in Ubuntu 22.04

Guida contributor