diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5e18fcf3..28cbba35 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -202,7 +202,7 @@ endif(USE_SYSTEM_JSONCPP) IF (NOT DISABLE_TESTS) ############### SET TEST SOURCE FILES ################# - SET ( OPENSHOT_TEST_FILES tests.cpp + SET ( OPENSHOT_TEST_FILES Cache_Tests.cpp Clip_Tests.cpp Color_Tests.cpp @@ -220,6 +220,7 @@ IF (NOT DISABLE_TESTS) ################ TESTER EXECUTABLE ################# # Create unit test executable (openshot-test) + message (STATUS "Tests enabled, test executable will be built as tests/openshot-test") add_executable(openshot-test tests.cpp ${OPENSHOT_TEST_FILES} ) @@ -227,7 +228,24 @@ IF (NOT DISABLE_TESTS) # Link libraries to the new executable target_link_libraries(openshot-test openshot ${UNITTEST++_LIBRARY}) - #################### MAKE TEST ###################### + ##### RUNNING TESTS (make os_test / make test) ##### # Hook up the 'make os_test' target to the 'openshot-test' executable ADD_CUSTOM_TARGET(os_test COMMAND openshot-test) -ENDIF (NOT DISABLE_TESTS) + list(APPEND OS_TEST_CMDS "'make os_test'") + + # Also hook up 'make test', if possible + # This requires CMake 3.11+, where the CMP0037 policy + # configured to 'NEW' mode will not reserve target names + # unless the corresponding feature is actually used + if (POLICY CMP0037) + cmake_policy(SET CMP0037 NEW) + endif() + if (CMAKE_VERSION VERSION_GREATER 3.11) + message(STATUS "Cmake 3.11+ detected, enabling 'test' target") + add_custom_target(test COMMAND openshot-test) + list(APPEND OS_TEST_CMDS " or " "'make test'") + endif() + + string(CONCAT t ${OS_TEST_CMDS}) + message("\nTo run unit tests, use: ${t}") +endif()