zstd icon indicating copy to clipboard operation
zstd copied to clipboard

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

Open JaggeV opened this issue 2 years ago • 1 comments

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

JaggeV avatar Sep 15 '23 12:09 JaggeV