Implement actual cryptographic functions using Crypto++ library
This commit is contained in:
@@ -45,6 +45,41 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Handle Crypto++ dependency
|
||||
# First try to find it as a package
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(CRYPTOPP QUIET libcrypto++ cryptopp)
|
||||
endif()
|
||||
|
||||
if(CRYPTOPP_FOUND)
|
||||
# Use the found package
|
||||
message(STATUS "Found Crypto++ package")
|
||||
set(CRYPTOPP_INCLUDE_DIRS ${CRYPTOPP_INCLUDE_DIRS})
|
||||
set(CRYPTOPP_LIBRARIES ${CRYPTOPP_LIBRARIES})
|
||||
else()
|
||||
# Download it as a submodule or include it directly
|
||||
message(STATUS "Crypto++ not found as package, will use submodule")
|
||||
|
||||
# Check if we have it in external/cryptopp
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/cryptopp/cryptlib.h")
|
||||
set(CRYPTOPP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/cryptopp")
|
||||
# For local build, we assume the library is built separately
|
||||
set(CRYPTOPP_LIBRARIES cryptopp)
|
||||
else()
|
||||
# Try to download it
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
cryptopp
|
||||
GIT_REPOSITORY https://github.com/weidai11/cryptopp.git
|
||||
GIT_TAG CRYPTOPP_8_8_0
|
||||
)
|
||||
FetchContent_MakeAvailable(cryptopp)
|
||||
set(CRYPTOPP_INCLUDE_DIRS ${cryptopp_SOURCE_DIR})
|
||||
set(CRYPTOPP_LIBRARIES cryptopp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Add library sources
|
||||
set(SOURCES
|
||||
src/privatebinapi.cpp
|
||||
@@ -77,6 +112,10 @@ else()
|
||||
target_include_directories(privatebinapi PRIVATE ${NLOHMANN_JSON_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# Include Crypto++
|
||||
target_include_directories(privatebinapi PRIVATE ${CRYPTOPP_INCLUDE_DIRS})
|
||||
target_link_libraries(privatebinapi ${CRYPTOPP_LIBRARIES})
|
||||
|
||||
# Link dependencies
|
||||
target_link_libraries(privatebinapi ${PLATFORM_LIBS})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user