diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-11-06 15:51:37 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2024-12-01 13:56:01 +0100 |
commit | 17527795fffbd55f1e9edfbfee89c7d958e5671f (patch) | |
tree | 618b3299fc218c41f94d8e70fab218964b79d165 /CMakeLists.txt | |
parent | c7268a172e1dc041dc8f6dab737d8277a4303dda (diff) |
digest: implement compile time option to exclude less common algorithms
Introduce a new default enabled CMake option `DIGEST_SUPPORT_EXTENDED`
which, when turned off, disables all but the most common md5, sha1 and
sha256 alogirthms to reduce the library size.
Also prefer statically linking libmd if possible.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eaf8271..bdf0738 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ find_library(libubox NAMES ubox) find_library(libubus NAMES ubus) find_library(libblobmsg_json NAMES blobmsg_json) find_package(ZLIB) -find_library(libmd NAMES md) +find_library(libmd NAMES libmd.a md) if(LINUX) find_library(libnl_tiny NAMES nl-tiny) @@ -73,6 +73,7 @@ option(LOG_SUPPORT "Log plugin support" ON) option(SOCKET_SUPPORT "Socket plugin support" ON) option(ZLIB_SUPPORT "Zlib plugin support" ${DEFAULT_ZLIB_SUPPORT}) option(DIGEST_SUPPORT "Digest plugin support" ${DEFAULT_DIGEST_SUPPORT}) +option(DIGEST_SUPPORT_EXTENDED "Enable additional hash algorithms" ${DEFAULT_DIGEST_SUPPORT}) set(LIB_SEARCH_PATH "${CMAKE_INSTALL_PREFIX}/lib/ucode/*.so:${CMAKE_INSTALL_PREFIX}/share/ucode/*.uc:./*.so:./*.uc" CACHE STRING "Default library search path") string(REPLACE ":" "\", \"" LIB_SEARCH_DEFINE "${LIB_SEARCH_PATH}") @@ -297,9 +298,14 @@ if(ZLIB_SUPPORT) endif() if(DIGEST_SUPPORT) + pkg_check_modules(LIBMD REQUIRED libmd) + include_directories(${LIBMD_INCLUDE_DIRS}) set(LIBRARIES ${LIBRARIES} digest_lib) add_library(digest_lib MODULE lib/digest.c) set_target_properties(digest_lib PROPERTIES OUTPUT_NAME digest PREFIX "") + if(DIGEST_SUPPORT_EXTENDED) + target_compile_definitions(digest_lib PUBLIC HAVE_DIGEST_EXTENDED) + endif() target_link_options(digest_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS}) target_link_libraries(digest_lib ${libmd}) endif() |