From 7dc3f2240c3f4573ed1171a3c0a3d1d3a485e9ec Mon Sep 17 00:00:00 2001 From: Siddharth Date: Wed, 26 Jun 2024 20:55:09 -0400 Subject: [PATCH] Add liboqs with find_package --- src/Mayaqua/3rdparty/Findliboqs.cmake | 2 ++ src/Mayaqua/CMakeLists.txt | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/Mayaqua/3rdparty/Findliboqs.cmake diff --git a/src/Mayaqua/3rdparty/Findliboqs.cmake b/src/Mayaqua/3rdparty/Findliboqs.cmake new file mode 100644 index 00000000..80900f23 --- /dev/null +++ b/src/Mayaqua/3rdparty/Findliboqs.cmake @@ -0,0 +1,2 @@ +set(oqs_FOUND TRUE) +add_library(OQS::oqs ALIAS oqs) diff --git a/src/Mayaqua/CMakeLists.txt b/src/Mayaqua/CMakeLists.txt index b472ac4a..4bea77a8 100644 --- a/src/Mayaqua/CMakeLists.txt +++ b/src/Mayaqua/CMakeLists.txt @@ -74,12 +74,21 @@ if(WIN32) "ws2_32.lib" "WtsApi32.Lib" ) + if (SKIP_OQS_PROVIDER) add_definitions(-DSKIP_OQS_PROVIDER) else() - add_subdirectory(3rdparty/liboqs) + set(OQS_BUILD_ONLY_LIB ON CACHE BOOL "Set liboqs to build only the library (no tests)") set(OQS_PROVIDER_BUILD_STATIC ON CACHE BOOL "Build a static library instead of a shared library") # Build oqsprovider as a static library (defaults to shared) + list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/Mayaqua/3rdparty/") + + add_subdirectory(3rdparty/liboqs) add_subdirectory(3rdparty/oqs-provider) + + target_include_directories(oqsprovider PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/liboqs/include) + get_target_property(target_include_dirs oqsprovider INCLUDE_DIRECTORIES) + message("Include directories for target_name: ${target_include_dirs}") + set_property(TARGET oqsprovider PROPERTY POSITION_INDEPENDENT_CODE ON) target_link_libraries(mayaqua PRIVATE oqsprovider) endif() @@ -101,13 +110,21 @@ if(UNIX) $<$:${LIB_M}> $<$:${LIB_RT}> ) - + if (SKIP_OQS_PROVIDER) add_definitions(-DSKIP_OQS_PROVIDER) else() - add_subdirectory(3rdparty/liboqs) + set(OQS_BUILD_ONLY_LIB ON CACHE BOOL "Set liboqs to build only the library (no tests)") set(OQS_PROVIDER_BUILD_STATIC ON CACHE BOOL "Build a static library instead of a shared library") # Build oqsprovider as a static library (defaults to shared) + list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/Mayaqua/3rdparty/") + + add_subdirectory(3rdparty/liboqs) add_subdirectory(3rdparty/oqs-provider) + + target_include_directories(oqsprovider PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/liboqs/include) + get_target_property(target_include_dirs oqsprovider INCLUDE_DIRECTORIES) + message("Include directories for target_name: ${target_include_dirs}") + set_property(TARGET oqsprovider PROPERTY POSITION_INDEPENDENT_CODE ON) target_link_libraries(mayaqua PRIVATE oqsprovider) endif()