Skip to content

Commit

Permalink
[cmake] Emit warnings for contradictory build settings
Browse files Browse the repository at this point in the history
Document that the `ZSTD_BUILD_{SHARED,STATIC}` take precedence over `BUILD_SHARED_LIBS` when exactly one is ON.

Thanks to @teo-tsirpanis for pointing out the potentially confusing behavior.
  • Loading branch information
terrelln committed Mar 18, 2024
1 parent cd4dba7 commit 42b02f5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build/cmake/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,17 @@ if (ZSTD_BUILD_STATIC)
add_definition(libzstd_static ZDICTLIB_STATIC_API)
endif ()
if (ZSTD_BUILD_SHARED AND NOT ZSTD_BUILD_STATIC)
if (NOT BUILD_SHARED_LIBS)
message(WARNING "BUILD_SHARED_LIBS is OFF, but ZSTD_BUILD_SHARED is ON and ZSTD_BUILD_STATIC is OFF, which takes precedence, so libzstd is a shared library")
endif ()
add_library(libzstd INTERFACE)
target_link_libraries(libzstd INTERFACE libzstd_shared)
list(APPEND library_targets libzstd)
endif ()
if (ZSTD_BUILD_STATIC AND NOT ZSTD_BUILD_SHARED)
if (BUILD_SHARED_LIBS)
message(WARNING "BUILD_SHARED_LIBS is ON, but ZSTD_BUILD_SHARED is OFF and ZSTD_BUILD_STATIC is ON, which takes precedence, is set so libzstd is a static library")
endif ()
add_library(libzstd INTERFACE)
target_link_libraries(libzstd INTERFACE libzstd_static)
list(APPEND library_targets libzstd)
Expand Down

0 comments on commit 42b02f5

Please sign in to comment.