Files
lib-privatebin/tests/CMakeLists.txt

37 lines
1.2 KiB
CMake

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 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
$<TARGET_FILE:privatebinapi>
$<TARGET_FILE_DIR:test_basic>
)
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 $<TARGET_FILE:example>)
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()