2424# along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
2525################################################################################
2626
27- SET (TEST_MEDIA_PATH "${PROJECT_SOURCE_DIR} /src/examples/" )
27+ # Test media path, used by unit tests for input data
28+ file (TO_NATIVE_PATH "${PROJECT_SOURCE_DIR} /src/examples/" TEST_MEDIA_PATH)
29+ add_definitions ( -DTEST_MEDIA_PATH="${TEST_MEDIA_PATH} " )
2830
2931################ WINDOWS ##################
3032# Set some compiler options for Windows
3133# required for libopenshot-audio headers
32- IF (WIN32 )
33- STRING (REPLACE "/" "\\\\ " TEST_MEDIA_PATH TEST_MEDIA_PATH)
34+ if (WIN32 )
3435 add_definitions ( -DIGNORE_JUCE_HYPOT=1 )
35- SET (CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -include cmath" )
36- ENDIF (WIN32 )
37-
38- add_definitions ( -DTEST_MEDIA_PATH="${TEST_MEDIA_PATH} " )
36+ set (CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -include cmath" )
37+ endif ()
3938
4039################### UNITTEST++ #####################
4140# Find UnitTest++ libraries (used for unit testing)
42- FIND_PACKAGE (UnitTest++ REQUIRED)
41+ find_package (UnitTest++)
42+
43+ if (NOT UnitTest++_FOUND)
44+ set (TESTS_ENABLED OFF PARENT_SCOPE)
45+ return ()
46+ endif ()
4347
4448# Include UnitTest++ headers (needed for compile)
45- include_directories (${UNITTEST++_INCLUDE_DIR})
49+ include_directories (${UnitTest++_INCLUDE_DIRS})
50+
51+ set_package_properties(UnitTest++ PROPERTIES
52+ TYPE RECOMMENDED
53+ PURPOSE "Unit testing framework" )
4654
4755################ IMAGE MAGICK ##################
4856# Set the Quantum Depth that ImageMagick was built with (default to 16 bits)
49- IF (MAGICKCORE_QUANTUM_DEPTH)
57+ if (MAGICKCORE_QUANTUM_DEPTH)
5058 add_definitions ( -DMAGICKCORE_QUANTUM_DEPTH=${MAGICKCORE_QUANTUM_DEPTH} )
51- ELSE (MAGICKCORE_QUANTUM_DEPTH )
59+ else ( )
5260 add_definitions ( -DMAGICKCORE_QUANTUM_DEPTH=16 )
53- ENDIF (MAGICKCORE_QUANTUM_DEPTH)
54- IF (MAGICKCORE_HDRI_ENABLE)
61+ endif ()
62+
63+ if (MAGICKCORE_HDRI_ENABLE)
5564 add_definitions ( -DMAGICKCORE_HDRI_ENABLE=${MAGICKCORE_HDRI_ENABLE} )
56- ELSE (MAGICKCORE_HDRI_ENABLE )
65+ else ( )
5766 add_definitions ( -DMAGICKCORE_HDRI_ENABLE=0 )
58- ENDIF (MAGICKCORE_HDRI_ENABLE)
59- IF (OPENSHOT_IMAGEMAGICK_COMPATIBILITY)
67+ endif ()
68+
69+ if (OPENSHOT_IMAGEMAGICK_COMPATIBILITY)
6070 add_definitions ( -DOPENSHOT_IMAGEMAGICK_COMPATIBILITY=${OPENSHOT_IMAGEMAGICK_COMPATIBILITY} )
61- ELSE (OPENSHOT_IMAGEMAGICK_COMPATIBILITY )
71+ else ( )
6272 add_definitions ( -DOPENSHOT_IMAGEMAGICK_COMPATIBILITY=0 )
63- ENDIF (OPENSHOT_IMAGEMAGICK_COMPATIBILITY )
73+ endif ( )
6474
6575# Find the ImageMagick++ library
66- FIND_PACKAGE (ImageMagick COMPONENTS Magick++ MagickWand MagickCore)
67- IF (ImageMagick_FOUND)
76+ find_package (ImageMagick COMPONENTS Magick++ MagickWand MagickCore)
77+ if (ImageMagick_FOUND)
6878 # Include ImageMagick++ headers (needed for compile)
6979 include_directories (${ImageMagick_INCLUDE_DIRS} )
7080
7181 # define a global var (used in the C++)
7282 add_definitions ( -DUSE_IMAGEMAGICK=1 )
73- SET (CMAKE_SWIG_FLAGS "-DUSE_IMAGEMAGICK=1" )
74-
75- ENDIF (ImageMagick_FOUND)
83+ set (CMAKE_SWIG_FLAGS "-DUSE_IMAGEMAGICK=1" )
84+ endif ()
7685
7786################# LIBOPENSHOT-AUDIO ###################
7887# Find JUCE-based openshot Audio libraries
79- FIND_PACKAGE (OpenShotAudio 0.2.0 REQUIRED)
88+ find_package (OpenShotAudio 0.2.0 REQUIRED)
8089
8190# Include Juce headers (needed for compile)
8291include_directories (${LIBOPENSHOT_AUDIO_INCLUDE_DIRS} )
8392
8493
8594################# BLACKMAGIC DECKLINK ###################
86- IF (ENABLE_BLACKMAGIC)
95+ if (ENABLE_BLACKMAGIC)
8796 # Find BlackMagic DeckLinkAPI libraries
88- FIND_PACKAGE (BlackMagic)
97+ find_package (BlackMagic)
8998
90- IF (BLACKMAGIC_FOUND)
99+ if (BLACKMAGIC_FOUND)
91100 # Include Blackmagic headers (needed for compile)
92101 include_directories (${BLACKMAGIC_INCLUDE_DIR} )
93- ENDIF (BLACKMAGIC_FOUND )
94- ENDIF (ENABLE_BLACKMAGIC )
102+ endif ( )
103+ endif ( )
95104
96105
97106############### SET TEST SOURCE FILES #################
98- SET ( OPENSHOT_TEST_FILES
99- Cache_Tests.cpp
100- Clip_Tests.cpp
101- Color_Tests.cpp
102- Coordinate_Tests.cpp
103- ReaderBase_Tests.cpp
104- ImageWriter_Tests.cpp
105- FFmpegReader_Tests.cpp
106- FFmpegWriter_Tests.cpp
107- Fraction_Tests.cpp
108- Frame_Tests.cpp
109- FrameMapper_Tests.cpp
110- KeyFrame_Tests.cpp
111- Point_Tests.cpp
112- Settings_Tests.cpp
113- Timeline_Tests.cpp )
107+ set ( OPENSHOT_TEST_FILES
108+ Cache_Tests.cpp
109+ Clip_Tests.cpp
110+ Color_Tests.cpp
111+ Coordinate_Tests.cpp
112+ ReaderBase_Tests.cpp
113+ ImageWriter_Tests.cpp
114+ FFmpegReader_Tests.cpp
115+ FFmpegWriter_Tests.cpp
116+ Fraction_Tests.cpp
117+ Frame_Tests.cpp
118+ FrameMapper_Tests.cpp
119+ KeyFrame_Tests.cpp
120+ Point_Tests.cpp
121+ Settings_Tests.cpp
122+ Timeline_Tests.cpp )
114123
115124################ TESTER EXECUTABLE #################
116125# Create unit test executable (openshot-test)
117126message (STATUS "Tests enabled, test executable will be built as tests/openshot-test" )
118127add_executable (openshot-test
119- tests.cpp
120- ${OPENSHOT_TEST_FILES} )
128+ tests.cpp
129+ ${OPENSHOT_TEST_FILES} )
121130
122131# Link libraries to the new executable
123- target_link_libraries (openshot-test openshot ${UNITTEST++_LIBRARY })
132+ target_link_libraries (openshot-test openshot ${UnitTest++_LIBRARIES })
124133
125134##### RUNNING TESTS (make os_test / make test) #####
126135# Hook up the 'make os_test' target to the 'openshot-test' executable
127- ADD_CUSTOM_TARGET (os_test COMMAND openshot-test )
128- list (APPEND OS_TEST_CMDS "'make os_test'" )
136+ add_custom_target (os_test COMMAND openshot-test )
129137
130138# Also hook up 'make test', if possible
131139# This requires CMake 3.11+, where the CMP0037 policy
@@ -137,8 +145,8 @@ endif()
137145if (CMAKE_VERSION VERSION_GREATER 3.11)
138146 message (STATUS "Cmake 3.11+ detected, enabling 'test' target" )
139147 add_custom_target (test COMMAND openshot-test )
140- list (APPEND OS_TEST_CMDS " or " "'make test'" )
148+ set (TEST_TARGET_NAME "test" )
149+ else ()
150+ set (TEST_TARGET_NAME "os_test" )
141151endif ()
142-
143- string (CONCAT t ${OS_TEST_CMDS} )
144- message ("\n To run unit tests, use: ${t} " )
152+ add_feature_info("Testrunner" ENABLE_TESTS "Run unit tests with 'make ${TEST_TARGET_NAME} '" )
0 commit comments