Fix CMakeLists.txt for Linux compatibility while preserving Windows vcpkg support
This commit is contained in:
@@ -17,8 +17,16 @@ elseif(UNIX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Handle dependencies
|
# Handle dependencies
|
||||||
find_package(cryptopp CONFIG REQUIRED)
|
if(WIN32)
|
||||||
find_package(nlohmann_json CONFIG REQUIRED)
|
# Windows: Use vcpkg packages
|
||||||
|
find_package(cryptopp CONFIG REQUIRED)
|
||||||
|
find_package(nlohmann_json CONFIG REQUIRED)
|
||||||
|
else()
|
||||||
|
# Linux: Use system packages
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(CRYPTOPP REQUIRED libcryptopp)
|
||||||
|
pkg_check_modules(NLOHMANN_JSON REQUIRED nlohmann_json)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Add library sources
|
# Add library sources
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
@@ -45,17 +53,34 @@ target_include_directories(privatebinapi PUBLIC
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
# Explicitly include vcpkg directories
|
# Platform-specific include directories
|
||||||
target_include_directories(privatebinapi PRIVATE
|
if(WIN32)
|
||||||
|
# Windows: Include vcpkg directories
|
||||||
|
target_include_directories(privatebinapi PRIVATE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include
|
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Link dependencies
|
# Link dependencies
|
||||||
target_link_libraries(privatebinapi PRIVATE
|
if(WIN32)
|
||||||
|
# Windows: Use vcpkg targets
|
||||||
|
target_link_libraries(privatebinapi PRIVATE
|
||||||
cryptopp::cryptopp
|
cryptopp::cryptopp
|
||||||
nlohmann_json::nlohmann_json
|
nlohmann_json::nlohmann_json
|
||||||
${PLATFORM_LIBS}
|
${PLATFORM_LIBS}
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
# Linux: Use system libraries
|
||||||
|
target_link_libraries(privatebinapi PRIVATE
|
||||||
|
${CRYPTOPP_LIBRARIES}
|
||||||
|
${NLOHMANN_JSON_LIBRARIES}
|
||||||
|
${PLATFORM_LIBS}
|
||||||
|
)
|
||||||
|
target_include_directories(privatebinapi PRIVATE
|
||||||
|
${CRYPTOPP_INCLUDE_DIRS}
|
||||||
|
${NLOHMANN_JSON_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Install targets
|
# Install targets
|
||||||
install(TARGETS privatebinapi
|
install(TARGETS privatebinapi
|
||||||
|
|||||||
Reference in New Issue
Block a user