example: plattformneutral gegen target link; linux delete via POST; build.sh nutzt vcpkg-Toolchain, baut lib+example; tests laufen

This commit is contained in:
2025-08-28 16:15:47 +02:00
parent df74c8a1af
commit 063800df12
3 changed files with 22 additions and 34 deletions

View File

@ -3,34 +3,15 @@ project(PrivateBinAPIExample)
set(CMAKE_CXX_STANDARD 17)
# Use the prebuilt library from the parent build directory
set(PRIVATEBINAPI_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../build")
set(PRIVATEBINAPI_RELEASE_LIB "${PRIVATEBINAPI_BUILD_DIR}/Release/privatebinapi.lib")
if(EXISTS "${PRIVATEBINAPI_RELEASE_LIB}")
set(PRIVATEBINAPI_LIB "${PRIVATEBINAPI_RELEASE_LIB}")
else()
# Fallback: try the build root (multi-config generators may place libs differently)
find_library(PRIVATEBINAPI_LIB privatebinapi PATHS "${PRIVATEBINAPI_BUILD_DIR}")
endif()
if(NOT PRIVATEBINAPI_LIB)
message(FATAL_ERROR "privatebinapi library not found. Please run build.bat in the project root first.")
endif()
# Build example and link against the in-tree target
add_executable(example example.cpp)
target_link_libraries(example PRIVATE privatebinapi)
target_link_libraries(example PRIVATE ${PRIVATEBINAPI_LIB} winhttp)
target_include_directories(example PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../include
)
# Install/run helpers for tests: copy DLL next to example on Windows
# On Windows, copy the DLL next to the example for easy execution
if(WIN32)
add_custom_command(TARGET example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PRIVATEBINAPI_BUILD_DIR}/Release/privatebinapi.dll
$<TARGET_FILE:privatebinapi>
$<TARGET_FILE_DIR:example>
)
endif()