CTest fixes

* Allow ctest to run from build dir
* Remove extra libs linked to ctest
* Prevent test from running twice

Manually adding tests isn't useful as we have catch_discover_tests which
does the same thing on a granular basis for catch2
This commit is contained in:
Stephen E. Baker
2025-05-14 20:28:06 -04:00
parent 9263bce95a
commit bb5f323963
4 changed files with 5 additions and 7 deletions

View File

@@ -64,6 +64,10 @@ endif()
project(CorsixTH_Top_Level)
if(ENABLE_UNIT_TESTS)
enable_testing()
endif()
if(MINGW)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
endif()

View File

@@ -266,7 +266,6 @@ endif()
if(ENABLE_UNIT_TESTS)
message("Building Unit Tests")
# Enable testing if set at this level so we can use CTest from the root of the build dir
enable_testing()
add_subdirectory(${PROJECT_SOURCE_DIR}/CppTest)
endif()

View File

@@ -39,16 +39,13 @@ add_custom_target(AllTests)
add_executable(UnitTests "")
target_link_libraries(UnitTests
Catch2::Catch2WithMain
CorsixTH_lib
${LUA_LIBRARY}
${CMAKE_DL_LIBS})
CorsixTH_lib)
set_property(TARGET UnitTests PROPERTY CXX_STANDARD 14)
set_property(TARGET UnitTests PROPERTY CXX_EXTENSIONS OFF)
set_property(TARGET UnitTests PROPERTY CXX_STANDARD_REQUIRED ON)
# Add the target to CTest
add_test(NAME UnitTests COMMAND UnitTests)
set_target_properties(UnitTests PROPERTIES FOLDER UnitTests)
# Make sure we add it as a dependency to all tests (some day we can add LuaTest here)

View File

@@ -25,9 +25,7 @@ build:
verbosity: minimal
test_script:
- cd CorsixTH
- cmd: ctest --extra-verbose --build-config Release --output-on-failure
- cd ..
after_build:
- curl -L -o %APPVEYOR_BUILD_FOLDER%/CorsixTH/Release/FluidR3.sf3 https://github.com/Jacalz/fluid-soundfont/raw/master/SF3/FluidR3.sf3