Fix CMakeLists.txt for Linux compatibility while preserving Windows vcpkg support
This commit is contained in:
@ -17,8 +17,16 @@ elseif(UNIX)
|
||||
endif()
|
||||
|
||||
# Handle dependencies
|
||||
find_package(cryptopp CONFIG REQUIRED)
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
if(WIN32)
|
||||
# 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
|
||||
set(SOURCES
|
||||
@ -45,17 +53,34 @@ target_include_directories(privatebinapi PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
# Explicitly include vcpkg directories
|
||||
target_include_directories(privatebinapi PRIVATE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include
|
||||
)
|
||||
# Platform-specific include directories
|
||||
if(WIN32)
|
||||
# Windows: Include vcpkg directories
|
||||
target_include_directories(privatebinapi PRIVATE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include
|
||||
)
|
||||
endif()
|
||||
|
||||
# Link dependencies
|
||||
target_link_libraries(privatebinapi PRIVATE
|
||||
cryptopp::cryptopp
|
||||
nlohmann_json::nlohmann_json
|
||||
${PLATFORM_LIBS}
|
||||
)
|
||||
if(WIN32)
|
||||
# Windows: Use vcpkg targets
|
||||
target_link_libraries(privatebinapi PRIVATE
|
||||
cryptopp::cryptopp
|
||||
nlohmann_json::nlohmann_json
|
||||
${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 privatebinapi
|
||||
|
||||
Reference in New Issue
Block a user