Add preference to libsodium static lib
All checks were successful
Build for Releases / ensure-release-exists (push) Successful in 1s
Run UnitTests / build-and-run-tests (push) Successful in 15s
Build for Releases / assets-release-x86_64 (push) Successful in 46s

This commit is contained in:
Stephen Seo 2024-07-13 15:18:23 +09:00
parent c2982c1e54
commit da54d0e314

View file

@ -50,7 +50,20 @@ else()
pkg_check_modules(LIBSODIUM QUIET libsodium) pkg_check_modules(LIBSODIUM QUIET libsodium)
if(LIBSODIUM_FOUND) if(LIBSODIUM_FOUND)
target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED) target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED)
# Try to link with static lib by default.
foreach(LIB_DIR IN LISTS ${LIBSODIUM_LIBRARY_DIRS})
if(EXISTS "${LIB_DIR}/libsodium.a")
set(LIBSODIUM_STATIC_LIB "${LIB_DIR}/libsodium.a")
break()
endif()
endforeach()
if(EXISTS ${LIBSODIUM_STATIC_LIB})
target_link_libraries(UDPC PUBLIC ${LIBSODIUM_STATIC_LIB})
else()
target_link_libraries(UDPC PUBLIC ${LIBSODIUM_LIBRARIES}) target_link_libraries(UDPC PUBLIC ${LIBSODIUM_LIBRARIES})
endif()
target_include_directories(UDPC PUBLIC ${LIBSODIUM_INCLUDE_DIRS}) target_include_directories(UDPC PUBLIC ${LIBSODIUM_INCLUDE_DIRS})
target_compile_options(UDPC PUBLIC ${LIBSODIUM_CFLAGS_OTHER}) target_compile_options(UDPC PUBLIC ${LIBSODIUM_CFLAGS_OTHER})
message(STATUS "libsodium enabled") message(STATUS "libsodium enabled")