libhashkit/aes: make using openssl configurable
[awesomized/libmemcached] / src / libhashkit / CMakeLists.txt
index 48a9a1b9dab151aa8caf44ee7babf398d63319e5..ed3f7f1d77caf79d7db960a07239ba735b7badf2 100644 (file)
@@ -1,4 +1,4 @@
-add_library(libhashkit SHARED
+set(libhashkit_sources
         aes.cc
         algorithm.cc
         common.h
@@ -22,6 +22,7 @@ add_library(libhashkit SHARED
         strerror.cc
         string.cc
         )
+add_library(libhashkit SHARED)
 add_library(hashkit ALIAS libhashkit)
 set_target_properties(libhashkit PROPERTIES
         CXX_STANDARD ${CXX_STANDARD}
@@ -38,6 +39,19 @@ target_include_directories(libhashkit PUBLIC
         $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
         $<INSTALL_INTERFACE:include>)
+
+if(ENABLE_OPENSSL_CRYPTO)
+        find_package(OpenSSL)
+        if(OPENSSL_FOUND)
+                if(OPENSSL_CRYPTO_LIBRARY)
+                        target_compile_definitions(libhashkit PRIVATE HAVE_OPENSSL_CRYPTO)
+                        target_link_libraries(libhashkit PUBLIC OpenSSL::Crypto)
+                else()
+                        message(WARNING "Could not find OpenSSL::Crypto")
+                endif()
+        endif()
+endif()
+
 configure_file(hashkitcon.h.in hashkitcon.h @ONLY)
 
 install(TARGETS libhashkit EXPORT libhashkit-targets
@@ -56,3 +70,7 @@ install_public_headers(
 
         hashkit.h
         )
+
+target_sources(libhashkit PRIVATE
+        ${libhashkit_sources}
+        ${libhashkit_includes})