Update to use vcpkg manifest approach for dependencies
This commit is contained in:
@ -16,43 +16,9 @@ elseif(UNIX)
|
|||||||
set(PLATFORM_LIBS ${CURL_LIBRARIES})
|
set(PLATFORM_LIBS ${CURL_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Handle nlohmann/json dependency
|
# Handle dependencies
|
||||||
# First try to find it as a package
|
find_package(cryptopp CONFIG REQUIRED)
|
||||||
find_package(nlohmann_json QUIET)
|
find_package(nlohmann_json CONFIG REQUIRED)
|
||||||
|
|
||||||
if(nlohmann_json_FOUND)
|
|
||||||
# Use the found package
|
|
||||||
message(STATUS "Found nlohmann_json package")
|
|
||||||
else()
|
|
||||||
# Download it as a submodule or include it directly
|
|
||||||
message(STATUS "nlohmann_json not found as package, will use submodule")
|
|
||||||
|
|
||||||
# Check if we have it in external/json
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/json/include/nlohmann/json.hpp")
|
|
||||||
set(NLOHMANN_JSON_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/json/include")
|
|
||||||
else()
|
|
||||||
# Try to download it with compatibility settings
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
nlohmann_json
|
|
||||||
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
|
||||||
GIT_TAG v3.11.2
|
|
||||||
)
|
|
||||||
# Set compatibility flag for older CMake versions
|
|
||||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
|
|
||||||
FetchContent_MakeAvailable(nlohmann_json)
|
|
||||||
set(NLOHMANN_JSON_INCLUDE_DIRS ${nlohmann_json_SOURCE_DIR}/include)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Handle Crypto++ dependency
|
|
||||||
find_package(cryptopp CONFIG QUIET)
|
|
||||||
|
|
||||||
if(cryptopp_FOUND)
|
|
||||||
message(STATUS "Found Crypto++ package via vcpkg")
|
|
||||||
else()
|
|
||||||
message(WARNING "Crypto++ not found via vcpkg. Make sure to use the vcpkg toolchain file.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Add library sources
|
# Add library sources
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
@ -79,19 +45,12 @@ target_include_directories(privatebinapi PUBLIC
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
# Link Crypto++
|
# Link dependencies
|
||||||
if(cryptopp_FOUND)
|
target_link_libraries(privatebinapi PRIVATE
|
||||||
target_link_libraries(privatebinapi PRIVATE cryptopp::cryptopp)
|
cryptopp::cryptopp
|
||||||
endif()
|
nlohmann_json::nlohmann_json
|
||||||
|
${PLATFORM_LIBS}
|
||||||
# Include nlohmann/json
|
)
|
||||||
if(nlohmann_json_FOUND)
|
|
||||||
target_link_libraries(privatebinapi PRIVATE nlohmann_json::nlohmann_json)
|
|
||||||
else()
|
|
||||||
target_include_directories(privatebinapi PRIVATE ${NLOHMANN_JSON_INCLUDE_DIRS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(privatebinapi PRIVATE ${PLATFORM_LIBS})
|
|
||||||
|
|
||||||
# Install targets
|
# Install targets
|
||||||
install(TARGETS privatebinapi
|
install(TARGETS privatebinapi
|
||||||
|
|||||||
1
vcpkg.json
Normal file
1
vcpkg.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name": "privatebin-api", "version-string": "1.0.0", "dependencies": ["cryptopp", "nlohmann-json"]}
|
||||||
Reference in New Issue
Block a user