diff --git a/CMakeLists.txt b/CMakeLists.txt index d375c5d..71aef7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ install(FILES ${HEADERS} DESTINATION include/privatebinapi) include(CTest) enable_testing() add_subdirectory(tests) +add_subdirectory(example) # ===================== LLVM/clang-cl Coverage (optional) ===================== option(ENABLE_LLVM_COVERAGE "Enable LLVM/clang-cl coverage instrumentation" OFF) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 157ac69..738ed33 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -24,4 +24,13 @@ target_link_libraries(example PRIVATE ${PRIVATEBINAPI_LIB} winhttp) target_include_directories(example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include -) \ No newline at end of file +) + +# Install/run helpers for tests: copy DLL next to example on Windows +if(WIN32) + add_custom_command(TARGET example POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${PRIVATEBINAPI_BUILD_DIR}/Release/privatebinapi.dll + $ + ) +endif() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3c8ddc3..18b1ab2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,4 +25,13 @@ target_include_directories(test_basic PRIVATE ) # Register the test with CTest -add_test(NAME test_basic COMMAND test_basic) \ No newline at end of file +add_test(NAME test_basic COMMAND test_basic) + +# Optional example run as a test (requires network and live server) +# Example-Test nur aktiv, wenn PRIVATEBIN_IT=1 gesetzt ist +add_test(NAME example_run COMMAND $) +if(DEFINED ENV{PRIVATEBIN_IT} AND NOT "$ENV{PRIVATEBIN_IT}" STREQUAL "0") + set_tests_properties(example_run PROPERTIES DISABLED FALSE) +else() + set_tests_properties(example_run PROPERTIES DISABLED TRUE) +endif() \ No newline at end of file