# SPDX-License-Identifier: GPL-3.0-or-later
cmake_minimum_required(VERSION 3.12)
project(wolf2009_source_player_hull_checks LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(core "${CMAKE_CURRENT_SOURCE_DIR}/../../src/wolf2009")
add_library(source_player_hull STATIC "${core}/SourcePlayerHull.cpp")
target_include_directories(source_player_hull PUBLIC "${core}")
if(NOT MSVC)
    target_compile_options(source_player_hull PRIVATE -ffp-contract=off -fno-fast-math)
endif()
add_executable(wolf2009-source-player-hull SourcePlayerHullTest.cpp)
target_link_libraries(wolf2009-source-player-hull PRIVATE source_player_hull)
enable_testing()
add_test(NAME wolf2009_source_player_hull_synthetic COMMAND wolf2009-source-player-hull)
set(WOLF2009_WIDE_TRM_NEO "${CMAKE_CURRENT_SOURCE_DIR}/../../engine/doom3/neo" CACHE PATH "Prepared engine neo directory containing the wide CM cache header")
if(EXISTS "${WOLF2009_WIDE_TRM_NEO}/cm/CollisionModel_traceBits.h")
    add_executable(wolf2009-wide-trace-bits WideTraceBitsTest.cpp)
    target_include_directories(wolf2009-wide-trace-bits PRIVATE "${WOLF2009_WIDE_TRM_NEO}")
    set_property(TARGET wolf2009-wide-trace-bits PROPERTY CXX_STANDARD 98)
    add_test(NAME wolf2009_wide_trace_bits COMMAND wolf2009-wide-trace-bits)
endif()
set(WOLF2009_SOURCE_PLAYER_HULL_POINTS "" CACHE FILEPATH "Optional private native-f32 source points (text count then xyz triples)")
if(WOLF2009_SOURCE_PLAYER_HULL_POINTS)
    add_test(NAME wolf2009_source_player_hull_original COMMAND wolf2009-source-player-hull --source-points "${WOLF2009_SOURCE_PLAYER_HULL_POINTS}")
endif()
