diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 374e5889..56f47e15 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -68,20 +68,37 @@ if(NOT BUILD_TESTING) return() endif() -# Create object library for test executable main(), -# to avoid recompiling for every test -add_library(catch-main OBJECT catch_main.cpp) -target_link_libraries(catch-main PUBLIC Catch2::Catch2) +add_library(openshot_catch2 INTERFACE) +target_include_directories(openshot_catch2 INTERFACE + "${CMAKE_CURRENT_BINARY_DIR}" +) +target_compile_definitions(openshot_catch2 INTERFACE + TEST_MEDIA_PATH="${TEST_MEDIA_PATH}") + +if(TARGET Catch2::Catch2WithMain) + # Catch2 v3 works a bit differently + configure_file(catch2v3.h.in openshot_catch.h) + target_link_libraries(openshot_catch2 INTERFACE Catch2::Catch2WithMain) +else() + configure_file(catch2v2.h.in openshot_catch.h) + # Create object library for test executable main(), + # to avoid recompiling for every test + add_library(catch-main OBJECT catch_main.cpp) + target_link_libraries(catch-main PUBLIC Catch2::Catch2) + target_include_directories(catch-main PUBLIC + "${CMAKE_CURRENT_BINARY_DIR}") + target_link_libraries(openshot_catch2 INTERFACE Catch2::Catch2) + target_sources(openshot_catch2 INTERFACE $) +endif() foreach(tname ${OPENSHOT_TESTS}) add_executable(openshot-${tname}-test ${tname}.cpp - $ ) - target_compile_definitions(openshot-${tname}-test PRIVATE - TEST_MEDIA_PATH="${TEST_MEDIA_PATH}" + target_link_libraries(openshot-${tname}-test + openshot_catch2 + openshot ) - target_link_libraries(openshot-${tname}-test Catch2::Catch2 openshot) # Automatically configure CTest targets from Catch2 test cases catch_discover_tests( diff --git a/tests/CVObjectDetection.cpp b/tests/CVObjectDetection.cpp index 939fc967..4d5b4b29 100644 --- a/tests/CVObjectDetection.cpp +++ b/tests/CVObjectDetection.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include "openshot_catch.h" #include "Clip.h" #include "CVObjectDetection.h" diff --git a/tests/CVStabilizer.cpp b/tests/CVStabilizer.cpp index 1c0d5990..401062d9 100644 --- a/tests/CVStabilizer.cpp +++ b/tests/CVStabilizer.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include "openshot_catch.h" #include "Clip.h" #include "CVStabilization.h" // for TransformParam, CamTrajectory, CVStabilization diff --git a/tests/CVTracker.cpp b/tests/CVTracker.cpp index e485d15f..95bcc6c8 100644 --- a/tests/CVTracker.cpp +++ b/tests/CVTracker.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include "openshot_catch.h" #include "Clip.h" #include "CVTracker.h" // for FrameData, CVTracker diff --git a/tests/CacheDisk.cpp b/tests/CacheDisk.cpp index b69c218f..6f18fb76 100644 --- a/tests/CacheDisk.cpp +++ b/tests/CacheDisk.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "openshot_catch.h" #include "CacheDisk.h" #include "Frame.h" diff --git a/tests/CacheMemory.cpp b/tests/CacheMemory.cpp index dc6917b6..6338cac8 100644 --- a/tests/CacheMemory.cpp +++ b/tests/CacheMemory.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "openshot_catch.h" #include "CacheMemory.h" #include "Frame.h" diff --git a/tests/ChromaKey.cpp b/tests/ChromaKey.cpp index 8aadde27..c478bcba 100644 --- a/tests/ChromaKey.cpp +++ b/tests/ChromaKey.cpp @@ -28,7 +28,7 @@ std::ostream& operator << ( std::ostream& os, QColor const& value ) { return os; } -#include +#include "openshot_catch.h" using namespace openshot; diff --git a/tests/Clip.cpp b/tests/Clip.cpp index 46b60d74..c0d47695 100644 --- a/tests/Clip.cpp +++ b/tests/Clip.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "openshot_catch.h" #include #include diff --git a/tests/Color.cpp b/tests/Color.cpp index 5dc16d4f..032cc949 100644 --- a/tests/Color.cpp +++ b/tests/Color.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "openshot_catch.h" #include diff --git a/tests/Coordinate.cpp b/tests/Coordinate.cpp index 68a20ab5..c043dcff 100644 --- a/tests/Coordinate.cpp +++ b/tests/Coordinate.cpp @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include +#include "openshot_catch.h" #include "Coordinate.h" #include "Exceptions.h" diff --git a/tests/Crop.cpp b/tests/Crop.cpp index 250b087a..5632be74 100644 --- a/tests/Crop.cpp +++ b/tests/Crop.cpp @@ -13,7 +13,7 @@ #include -#include +#include "openshot_catch.h" #include "Frame.h" #include "effects/Crop.h" diff --git a/tests/DummyReader.cpp b/tests/DummyReader.cpp index 7cc075b9..7d459392 100644 --- a/tests/DummyReader.cpp +++ b/tests/DummyReader.cpp @@ -12,7 +12,7 @@ #include -#include +#include "openshot_catch.h" #include "DummyReader.h" #include "Exceptions.h" diff --git a/tests/FFmpegReader.cpp b/tests/FFmpegReader.cpp index d46b7c79..c397fc0a 100644 --- a/tests/FFmpegReader.cpp +++ b/tests/FFmpegReader.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "openshot_catch.h" #include "FFmpegReader.h" #include "Exceptions.h" diff --git a/tests/FFmpegWriter.cpp b/tests/FFmpegWriter.cpp index 40c0cc69..cce3c89d 100644 --- a/tests/FFmpegWriter.cpp +++ b/tests/FFmpegWriter.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "openshot_catch.h" #include "FFmpegWriter.h" #include "Exceptions.h" diff --git a/tests/Fraction.cpp b/tests/Fraction.cpp index 4b466d2d..a730593c 100644 --- a/tests/Fraction.cpp +++ b/tests/Fraction.cpp @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include +#include "openshot_catch.h" #include #include diff --git a/tests/Frame.cpp b/tests/Frame.cpp index 5a54a668..ffe4d84d 100644 --- a/tests/Frame.cpp +++ b/tests/Frame.cpp @@ -24,7 +24,7 @@ #undef uint64 #endif -#include +#include "openshot_catch.h" #include "Clip.h" #include "Fraction.h" diff --git a/tests/FrameMapper.cpp b/tests/FrameMapper.cpp index 7cf0e88a..3571d384 100644 --- a/tests/FrameMapper.cpp +++ b/tests/FrameMapper.cpp @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include +#include "openshot_catch.h" #include "CacheMemory.h" #include "Clip.h" diff --git a/tests/ImageWriter.cpp b/tests/ImageWriter.cpp index 4056a9ab..5c7edc1e 100644 --- a/tests/ImageWriter.cpp +++ b/tests/ImageWriter.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include "openshot_catch.h" #include "ImageWriter.h" #include "Exceptions.h" diff --git a/tests/KeyFrame.cpp b/tests/KeyFrame.cpp index 1826befb..a09bdd92 100644 --- a/tests/KeyFrame.cpp +++ b/tests/KeyFrame.cpp @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include +#include "openshot_catch.h" #include #include diff --git a/tests/Point.cpp b/tests/Point.cpp index 1e57d153..bd54fecf 100644 --- a/tests/Point.cpp +++ b/tests/Point.cpp @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include +#include "openshot_catch.h" #include #include "Point.h" diff --git a/tests/QtImageReader.cpp b/tests/QtImageReader.cpp index a5189125..1db67e05 100644 --- a/tests/QtImageReader.cpp +++ b/tests/QtImageReader.cpp @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include +#include "openshot_catch.h" #include diff --git a/tests/ReaderBase.cpp b/tests/ReaderBase.cpp index 06fa77fa..506da944 100644 --- a/tests/ReaderBase.cpp +++ b/tests/ReaderBase.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "openshot_catch.h" #include "ReaderBase.h" #include "CacheBase.h" diff --git a/tests/Settings.cpp b/tests/Settings.cpp index f55e005f..f4717b37 100644 --- a/tests/Settings.cpp +++ b/tests/Settings.cpp @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include +#include "openshot_catch.h" #include "Settings.h" diff --git a/tests/Timeline.cpp b/tests/Timeline.cpp index 1c545d6a..d2d9d458 100644 --- a/tests/Timeline.cpp +++ b/tests/Timeline.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include "openshot_catch.h" #include "Timeline.h" #include "Clip.h" diff --git a/tests/catch2v2.h.in b/tests/catch2v2.h.in new file mode 100644 index 00000000..39b82264 --- /dev/null +++ b/tests/catch2v2.h.in @@ -0,0 +1,19 @@ +/** + * @file + * @brief Header (template) for tests built with Catch2 v2 + * @author Jonathan Thomas + * @author FeRD (Frank Dana) + * + * @ref License + */ + +// Copyright (c) 2008-2022 OpenShot Studios, LLC +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef OPENSHOT_CATCH2_H +#define OPENSHOT_CATCH2_H + +#include + +#endif diff --git a/tests/catch2v3.h.in b/tests/catch2v3.h.in new file mode 100644 index 00000000..2df0cb03 --- /dev/null +++ b/tests/catch2v3.h.in @@ -0,0 +1,20 @@ +/** + * @file + * @brief Header (template) for tests built with Catch2 v3.0 or later + * @author Jonathan Thomas + * @author FeRD (Frank Dana) + * + * @ref License + */ + +// Copyright (c) 2008-2022 OpenShot Studios, LLC +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef OPENSHOT_CATCH2_H +#define OPENSHOT_CATCH2_H + +#include +using namespace Catch; + +#endif diff --git a/tests/catch_main.cpp b/tests/catch_main.cpp index 1a548c5b..d4cf752d 100644 --- a/tests/catch_main.cpp +++ b/tests/catch_main.cpp @@ -11,5 +11,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #define CATCH_CONFIG_MAIN -#include +#include "openshot_catch.h"