Fix CMakeLists.txt for Linux compatibility while preserving Windows vcpkg support

This commit is contained in:
2025-08-28 20:37:34 +02:00
parent b97d9f2d7f
commit 000fde485f

View File

@@ -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)
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include # Windows: Include vcpkg directories
) target_include_directories(privatebinapi PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include
)
endif()
# Link dependencies # Link dependencies
target_link_libraries(privatebinapi PRIVATE if(WIN32)
cryptopp::cryptopp # Windows: Use vcpkg targets
nlohmann_json::nlohmann_json target_link_libraries(privatebinapi PRIVATE
${PLATFORM_LIBS} 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
install(TARGETS privatebinapi install(TARGETS privatebinapi