Use sfml_add_test macro for unit tests and copy dlls to output directory if required
This commit is contained in:
parent
2c3a321afd
commit
53972ed5f2
3 changed files with 47 additions and 13 deletions
|
@ -12,9 +12,7 @@ SET(SYSTEM_SRC
|
|||
"${SRCROOT}/TestUtilities/SystemUtil.hpp"
|
||||
"${SRCROOT}/TestUtilities/SystemUtil.cpp"
|
||||
)
|
||||
add_executable(systemtest ${SYSTEM_SRC})
|
||||
target_link_libraries(systemtest sfml-system)
|
||||
add_test(System-module-tests systemtest)
|
||||
sfml_add_test(systemtest "${SYSTEM_SRC}" sfml-system)
|
||||
|
||||
if(SFML_BUILD_WINDOW)
|
||||
SET(WINDOW_SRC
|
||||
|
@ -22,9 +20,7 @@ if(SFML_BUILD_WINDOW)
|
|||
"${SRCROOT}/TestUtilities/WindowUtil.hpp"
|
||||
"${SRCROOT}/TestUtilities/WindowUtil.cpp"
|
||||
)
|
||||
add_executable(windowtest ${WINDOW_SRC})
|
||||
target_link_libraries(windowtest sfml-window)
|
||||
add_test(Window-module-tests windowtest)
|
||||
sfml_add_test(windowtest "${WINDOW_SRC}" sfml-window)
|
||||
endif()
|
||||
|
||||
if(SFML_BUILD_GRAPHICS)
|
||||
|
@ -34,17 +30,15 @@ if(SFML_BUILD_GRAPHICS)
|
|||
"${SRCROOT}/TestUtilities/GraphicsUtil.hpp"
|
||||
"${SRCROOT}/TestUtilities/GraphicsUtil.cpp"
|
||||
)
|
||||
add_executable(graphicstest ${GRAPHICS_SRC})
|
||||
target_link_libraries(graphicstest sfml-graphics)
|
||||
add_test(Graphics-module-tests graphicstest)
|
||||
sfml_add_test(graphicstest "${GRAPHICS_SRC}" sfml-graphics)
|
||||
endif()
|
||||
|
||||
# Automatically run the tests at the end of the build
|
||||
add_custom_target(runtests ALL
|
||||
DEPENDS systemtest windowtest graphicstest
|
||||
)
|
||||
|
||||
add_custom_command(TARGET runtests
|
||||
COMMENT "Run tests"
|
||||
POST_BUILD COMMAND ctest ARGS --output-on-failure
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue