Update crypto implementation to handle missing Crypto++ library

This commit is contained in:
2025-08-28 09:44:54 +02:00
parent b384a6a404
commit 3d3bff31b7
2 changed files with 80 additions and 28 deletions

View File

@ -58,26 +58,10 @@ if(CRYPTOPP_FOUND)
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()
# For now, we'll provide a warning and use stub implementations
# In a real implementation, you would install Crypto++ separately
message(WARNING "Crypto++ not found. Using stub implementations for cryptographic functions.")
add_definitions(-DNO_CRYPTO)
endif()
# Add library sources
@ -113,8 +97,10 @@ else()
endif()
# Include Crypto++
target_include_directories(privatebinapi PRIVATE ${CRYPTOPP_INCLUDE_DIRS})
target_link_libraries(privatebinapi ${CRYPTOPP_LIBRARIES})
if(CRYPTOPP_FOUND)
target_include_directories(privatebinapi PRIVATE ${CRYPTOPP_INCLUDE_DIRS})
target_link_libraries(privatebinapi ${CRYPTOPP_LIBRARIES})
endif()
# Link dependencies
target_link_libraries(privatebinapi ${PLATFORM_LIBS})