Initial commit: PrivateBin API C++ DLL implementation
This commit is contained in:
88
CMakeLists.txt
Normal file
88
CMakeLists.txt
Normal file
@@ -0,0 +1,88 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(PrivateBinAPI)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# Platform-specific configurations
|
||||
if(WIN32)
|
||||
# Windows-specific settings
|
||||
add_definitions(-DWINDOWS)
|
||||
set(PLATFORM_LIBS winhttp)
|
||||
elseif(UNIX)
|
||||
# Linux-specific settings
|
||||
add_definitions(-DLINUX)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
set(PLATFORM_LIBS ${CURL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# Handle nlohmann/json dependency
|
||||
# First try to find it as a package
|
||||
find_package(nlohmann_json QUIET)
|
||||
|
||||
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
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
nlohmann_json
|
||||
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
||||
GIT_TAG v3.11.2
|
||||
)
|
||||
FetchContent_MakeAvailable(nlohmann_json)
|
||||
set(NLOHMANN_JSON_INCLUDE_DIRS ${nlohmann_json_SOURCE_DIR}/include)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Add library sources
|
||||
set(SOURCES
|
||||
src/privatebinapi.cpp
|
||||
src/http_client.cpp
|
||||
src/crypto.cpp
|
||||
src/json_parser.cpp
|
||||
src/base58.cpp
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
include/privatebinapi.h
|
||||
include/http_client.h
|
||||
include/crypto.h
|
||||
include/json_parser.h
|
||||
include/base58.h
|
||||
)
|
||||
|
||||
# Create the shared library
|
||||
add_library(privatebinapi SHARED ${SOURCES} ${HEADERS})
|
||||
|
||||
# Include directories
|
||||
target_include_directories(privatebinapi PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
# Include nlohmann/json
|
||||
if(nlohmann_json_FOUND)
|
||||
target_link_libraries(privatebinapi nlohmann_json::nlohmann_json)
|
||||
else()
|
||||
target_include_directories(privatebinapi PRIVATE ${NLOHMANN_JSON_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# Link dependencies
|
||||
target_link_libraries(privatebinapi ${PLATFORM_LIBS})
|
||||
|
||||
# Install targets
|
||||
install(TARGETS privatebinapi
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
install(FILES ${HEADERS} DESTINATION include/privatebinapi))
|
||||
Reference in New Issue
Block a user