cmake_minimum_required(VERSION 3.10) project(PrivateBinAPITests) set(CMAKE_CXX_STANDARD 17) # Create test executable add_executable(test_basic test_basic.cpp) # Link with the already-defined privatebinapi target from the root project target_link_libraries(test_basic PRIVATE privatebinapi) # Ensure nlohmann_json include directories are available to the test target target_link_libraries(test_basic PRIVATE nlohmann_json::nlohmann_json) target_link_libraries(test_basic PRIVATE cryptopp::cryptopp) # Add internal sources for direct testing of C++ components not exported by the DLL target_sources(test_basic PRIVATE ${CMAKE_SOURCE_DIR}/src/json_parser.cpp ${CMAKE_SOURCE_DIR}/src/http_client.cpp ) # Ensure the DLL is available next to the test executable on Windows if(WIN32) add_dependencies(test_basic privatebinapi) add_custom_command(TARGET test_basic POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ ) # Link WinHTTP for direct HttpClient usage in tests target_link_libraries(test_basic PRIVATE winhttp) endif() # Include directories target_include_directories(test_basic PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include ) # Register the test with CTest 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()