Created
July 23, 2019 20:39
-
-
Save jedisct1/73b8e52fe220fcd2b6b07455be65c2d2 to your computer and use it in GitHub Desktop.
cmake.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Findsodium.cmake 2019-07-23 22:22:23.000000000 +0200 | |
+++ zok.cmake 2019-07-23 22:22:17.000000000 +0200 | |
@@ -18,7 +18,6 @@ | |
# Once done the following variables will be defined: | |
# | |
# sodium_FOUND sodium_INCLUDE_DIR sodium_LIBRARY_DEBUG sodium_LIBRARY_RELEASE | |
-# sodium_VERSION_STRING | |
# | |
# Furthermore an imported "sodium" target is created. | |
# | |
@@ -52,23 +51,23 @@ | |
endif() | |
if(sodium_USE_STATIC_LIBS) | |
- if(sodium_PKG_STATIC_LIBRARIES) | |
- foreach(_libname ${sodium_PKG_STATIC_LIBRARIES}) | |
- if(NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending | |
- # with .a | |
- list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a") | |
- endif() | |
- endforeach() | |
- list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES) | |
- else() | |
- # if pkgconfig for libsodium doesn't provide static lib info, then | |
- # override PKG_STATIC here.. | |
+ foreach(_libname ${sodium_PKG_STATIC_LIBRARIES}) | |
+ if(NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending | |
+ # with .a | |
+ list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a") | |
+ endif() | |
+ endforeach() | |
+ list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES) | |
+ | |
+ # if pkgconfig for libsodium doesn't provide static lib info, then override | |
+ # PKG_STATIC here.. | |
+ if(NOT sodium_PKG_STATIC_FOUND) | |
set(sodium_PKG_STATIC_LIBRARIES libsodium.a) | |
endif() | |
set(XPREFIX sodium_PKG_STATIC) | |
else() | |
- if(sodium_PKG_LIBRARIES STREQUAL "") | |
+ if(NOT sodium_PKG_FOUND) | |
set(sodium_PKG_LIBRARIES sodium) | |
endif() | |
@@ -95,7 +94,7 @@ | |
if(MSVC) | |
# detect target architecture | |
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.c" [=[ | |
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[ | |
#if defined _M_IX86 | |
#error ARCH_VALUE x86_32 | |
#elif defined _M_X64 | |
@@ -104,7 +103,7 @@ | |
#error ARCH_VALUE unknown | |
]=]) | |
try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" | |
- "${CMAKE_CURRENT_BINARY_DIR}/arch.c" | |
+ "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" | |
OUTPUT_VARIABLE _COMPILATION_LOG) | |
string(REGEX | |
REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" | |
@@ -207,27 +206,37 @@ | |
# extract sodium version | |
if(sodium_INCLUDE_DIR) | |
- set(_VERSION_HEADER "${sodium_INCLUDE_DIR}/sodium/version.h") | |
- if(EXISTS "${_VERSION_HEADER}") | |
+ set(_VERSION_HEADER "${_INCLUDE_DIR}/sodium/version.h") | |
+ if(EXISTS _VERSION_HEADER) | |
file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT) | |
- string(REGEX | |
- REPLACE ".*define[ \t]+SODIUM_VERSION_STRING[^\"]+\"([^\"]+)\".*" | |
- "\\1" | |
- sodium_VERSION_STRING | |
- "${_VERSION_HEADER_CONTENT}") | |
- set(sodium_VERSION_STRING "${sodium_VERSION_STRING}") | |
+ string( | |
+ REGEX | |
+ REPLACE ".*#[ \t]*define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*" | |
+ "\\1" | |
+ sodium_VERSION | |
+ "${_VERSION_HEADER_CONTENT}") | |
+ set(sodium_VERSION "${sodium_VERSION}" PARENT_SCOPE) | |
endif() | |
endif() | |
# communicate results | |
include(FindPackageHandleStandardArgs) | |
-find_package_handle_standard_args(sodium | |
+find_package_handle_standard_args(Sodium # The name must be either uppercase or | |
+ # match the filename case. | |
REQUIRED_VARS | |
sodium_LIBRARY_RELEASE | |
sodium_LIBRARY_DEBUG | |
sodium_INCLUDE_DIR | |
VERSION_VAR | |
- sodium_VERSION_STRING) | |
+ sodium_VERSION) | |
+ | |
+if(Sodium_FOUND) | |
+ set(sodium_LIBRARIES | |
+ optimized | |
+ ${sodium_LIBRARY_RELEASE} | |
+ debug | |
+ ${sodium_LIBRARY_DEBUG}) | |
+endif() | |
# mark file paths as advanced | |
mark_as_advanced(sodium_INCLUDE_DIR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment