From 5dcf78a14c75b0feec59344a7a2e0afd861752b6 Mon Sep 17 00:00:00 2001 From: Michael Ellery Date: Fri, 27 Oct 2017 13:01:20 -0700 Subject: [PATCH] CMake find module fixes for static linking: (#621) Enclose option() declaration in a defined check to allow simple caller set() use case. Provide default static lib name for find_library since pkgconfig for libsodium currently does not provide it. --- contrib/Findsodium.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/Findsodium.cmake b/contrib/Findsodium.cmake index 9d306d15..ec01ac46 100644 --- a/contrib/Findsodium.cmake +++ b/contrib/Findsodium.cmake @@ -32,7 +32,9 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" endif() # static library option -option(sodium_USE_STATIC_LIBS "enable to statically link against sodium") +if (NOT DEFINED sodium_USE_STATIC_LIBS) + option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF) +endif() if(NOT (sodium_USE_STATIC_LIBS EQUAL sodium_USE_STATIC_LIBS_LAST)) unset(sodium_LIBRARY CACHE) unset(sodium_LIBRARY_DEBUG CACHE) @@ -53,6 +55,11 @@ if (UNIX) endif() if(sodium_USE_STATIC_LIBS) + # if pkgconfig for libsodium doesn't provide + # static lib info, then override PKG_STATIC here.. + if (NOT DEFINED sodium_PKG_STATIC_LIBRARIES) + set(sodium_PKG_STATIC_LIBRARIES libsodium.a) + endif() set(XPREFIX sodium_PKG_STATIC) else() set(XPREFIX sodium_PKG)