sots-engine/tests/mars_vfs/CMakeLists.txt

31 lines
1.7 KiB
CMake

# Optional CMake wiring for the mars_vfs tests; the canonical runner is
# build_and_run.sh (plain g++). Include from the root with
# add_subdirectory(tests/mars_vfs) after add_subdirectory(src/mars/vfs)
# (and src/mars/parse + src/mars/text for the real-data test).
add_executable(mars_vfs_unit_tests test_main.cpp unit_tests.cpp)
target_link_libraries(mars_vfs_unit_tests PRIVATE mars_vfs)
target_include_directories(mars_vfs_unit_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME mars_vfs_unit COMMAND mars_vfs_unit_tests)
# The deflated fixture comes from Python's zipfile so the inflate path is
# checked against an independent producer. Without Python that one test SKIPs.
find_package(Python3 COMPONENTS Interpreter QUIET)
if(Python3_Interpreter_FOUND)
set(_fixture ${CMAKE_CURRENT_BINARY_DIR}/deflated.zip)
add_custom_command(OUTPUT ${_fixture}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/make_fixture.py ${_fixture}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make_fixture.py
COMMENT "Generating mars_vfs deflated fixture")
add_custom_target(mars_vfs_fixture DEPENDS ${_fixture})
add_dependencies(mars_vfs_unit_tests mars_vfs_fixture)
set_tests_properties(mars_vfs_unit PROPERTIES ENVIRONMENT "MARS_VFS_FIXTURE=${_fixture}")
endif()
add_executable(mars_vfs_cat vfs_cat.cpp)
target_link_libraries(mars_vfs_cat PRIVATE mars_vfs)
if(TARGET mars_parse AND TARGET mars_text)
add_executable(mars_vfs_realdata_test realdata_test.cpp)
target_link_libraries(mars_vfs_realdata_test PRIVATE mars_vfs mars_parse mars_text)
add_test(NAME mars_vfs_realdata COMMAND mars_vfs_realdata_test) # SKIPs without SOTS_GOB_DIR
endif()