Skip to content

Commit c8c92b5

Browse files
committed
Merge branch 'develop' into effect-parenting
2 parents c55efd1 + 8cefd49 commit c8c92b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+3235
-2212
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI Build
1+
name: libopenshot CI Build
22
on: [push, pull_request]
33
jobs:
44
build:
@@ -13,6 +13,10 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v2
16+
# Work around a codecov issue detecting commit SHAs
17+
# see: https://community.codecov.io/t/issue-detecting-commit-sha-please-run-actions-checkout-with-fetch-depth-1-or-set-to-0/2571
18+
with:
19+
fetch-depth: 0
1620

1721
- uses: haya14busa/action-cond@v1
1822
id: coverage
@@ -31,8 +35,13 @@ jobs:
3135
libopenshot-audio-dev \
3236
qtbase5-dev qtbase5-dev-tools \
3337
libfdk-aac-dev libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libavfilter-dev libswscale-dev libpostproc-dev libswresample-dev \
34-
libzmq3-dev libmagick++-dev libunittest++-dev \
38+
libzmq3-dev libmagick++-dev \
3539
libopencv-dev libprotobuf-dev protobuf-compiler
40+
# Install catch2 package from Ubuntu 20.10, since for some reason
41+
# even 20.04 only has Catch 1.12.1 available.
42+
wget https://launchpad.net/ubuntu/+archive/primary/+files/catch2_2.13.0-1_all.deb
43+
sudo dpkg -i catch2_2.13.0-1_all.deb
44+
3645
3746
- name: Build libopenshot
3847
shell: bash
@@ -47,7 +56,7 @@ jobs:
4756
shell: bash
4857
run: |
4958
pushd build
50-
cmake --build . --target os_test -- VERBOSE=1
59+
cmake --build . --target coverage -- VERBOSE=1
5160
popd
5261
5362
- name: Install libopenshot
@@ -61,4 +70,3 @@ jobs:
6170
if: ${{ matrix.compiler == 'clang' }}
6271
with:
6372
file: build/coverage.info
64-

CMakeLists.txt

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,15 @@ include(FeatureSummary)
7373
# Optional build settings for libopenshot
7474
option(USE_SYSTEM_JSONCPP "Use system installed JsonCpp, if found" ON)
7575
option(DISABLE_BUNDLED_JSONCPP "Don't fall back to bundled JsonCpp" OFF)
76+
7677
option(ENABLE_IWYU "Enable 'Include What You Use' scanner (CMake 3.3+)" OFF)
77-
option(ENABLE_TESTS "Build unit tests (requires UnitTest++)" ON)
78+
79+
option(ENABLE_TESTS "Build unit tests (requires Catch2)" ON)
80+
option(ENABLE_PARALLEL_CTEST "Run CTest using multiple processors" ON)
7881
option(ENABLE_COVERAGE "Scan test coverage using gcov and report" OFF)
82+
7983
option(ENABLE_DOCS "Build API documentation (requires Doxygen)" ON)
84+
8085
option(APPIMAGE_BUILD "Build to install in an AppImage (Linux only)" OFF)
8186
option(ENABLE_MAGICK "Use ImageMagick, if available" ON)
8287
option(ENABLE_OPENCV "Build with OpenCV algorithms (requires Boost, Protobuf 3)" ON)
@@ -87,7 +92,7 @@ if (DISABLE_TESTS)
8792
endif()
8893

8994
if(DEFINED ENABLE_TESTS)
90-
set(ENABLE_TESTS ${ENABLE_TESTS} CACHE BOOL "Build unit tests (requires UnitTest++)" FORCE)
95+
set(ENABLE_TESTS ${ENABLE_TESTS} CACHE BOOL "Build unit tests (requires Catch2)" FORCE)
9196
endif()
9297

9398
#### Work around a GCC < 9 bug with handling of _Pragma() in macros
@@ -109,7 +114,7 @@ ENDIF(WIN32)
109114
############## Code Coverage #########################
110115
if (ENABLE_COVERAGE AND NOT ENABLE_TESTS)
111116
message(WARNING "ENABLE_COVERAGE requires unit tests, forcing ENABLE_TESTS")
112-
set(ENABLE_TESTS ON CACHE BOOL "Don't build unit tests" FORCE)
117+
set(ENABLE_TESTS ON CACHE BOOL "Build unit tests (requires Catch2 or UnitTest++)" FORCE)
113118
endif()
114119

115120
if (ENABLE_COVERAGE)
@@ -166,55 +171,87 @@ if (ENABLE_DOCS)
166171
OPTIONAL ) # No error if the docs aren't found
167172
endif()
168173
endif()
169-
add_feature_info("Documentation" DOCS_ENABLED "Build API documentation with 'make doc'")
170174

171175
############# PROCESS tests/ DIRECTORY ##############
172176
if(ENABLE_TESTS)
173177
set(TESTS_ENABLED TRUE) # May be overridden by tests/CMakeLists.txt
178+
find_package(Catch2 REQUIRED)
179+
if(ENABLE_PARALLEL_CTEST)
180+
# Figure out the amount of parallelism for CTest
181+
include(ProcessorCount)
182+
ProcessorCount(CPU_COUNT)
183+
if(NOT CPU_COUNT EQUAL 0)
184+
message(STATUS "Setting up unit tests to use ${CPU_COUNT} processors")
185+
set(CTEST_OPTIONS "-j${CPU_COUNT}")
186+
endif()
187+
endif()
188+
include(CTest)
189+
include(Catch)
174190
add_subdirectory(tests)
175191
endif()
176192
add_feature_info("Unit tests" TESTS_ENABLED "Compile unit tests for library functions")
177193

178194
############## COVERAGE REPORTING #################
179-
if (ENABLE_COVERAGE)
195+
if (ENABLE_COVERAGE AND DEFINED UNIT_TEST_TARGETS)
180196
setup_target_for_coverage_lcov(
181197
NAME coverage
182198
LCOV_ARGS "--no-external"
183-
EXECUTABLE openshot-test
184-
DEPENDENCIES openshot openshot-test
199+
EXECUTABLE ctest
200+
EXECUTABLE_ARGS ${CTEST_OPTIONS}
201+
DEPENDENCIES openshot ${UNIT_TEST_TARGETS}
185202
EXCLUDE
186203
"bindings/*"
187204
"examples/*"
188205
"${CMAKE_CURRENT_BINARY_DIR}/bindings/*"
189206
"${CMAKE_CURRENT_BINARY_DIR}/src/*_autogen/*"
190207
)
191-
if(NOT TARGET os_test)
192-
add_custom_target(os_test)
193-
add_dependencies(os_test coverage)
194-
endif()
195208
endif()
196209

197-
# Also hook up 'test' as an alias for the 'os_test' target, if possible
198-
# This requires CMake 3.11+, where the CMP0037 policy
199-
# configured to 'NEW' mode will not reserve target names
200-
# unless the corresponding feature is actually used
201-
if (POLICY CMP0037)
202-
cmake_policy(SET CMP0037 NEW)
210+
if(TESTS_ENABLED AND NOT TARGET coverage)
211+
add_custom_target(coverage
212+
COMMAND ctest ${CTEST_OPTIONS}
213+
DEPENDS openshot ${UNIT_TEST_TARGETS}
214+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
215+
COMMENT "Running unit tests (coverage disabled)"
216+
)
203217
endif()
204-
if(TARGET os_test)
205-
if (CMAKE_VERSION VERSION_GREATER 3.11)
206-
message(STATUS "Cmake 3.11+ detected, enabling 'test' target")
207-
add_custom_target(test)
208-
add_dependencies(test os_test)
209-
set(TEST_TARGET_NAME "test")
210-
else()
211-
set(TEST_TARGET_NAME "os_test")
218+
219+
if(TARGET test AND NOT TARGET os_test)
220+
add_custom_target(os_test)
221+
add_dependencies(os_test coverage)
222+
endif()
223+
224+
if(TARGET os_test AND NOT TARGET test AND CMAKE_VERSION VERSION_GREATER 3.11)
225+
# Also hook up 'test' as an alias for the 'os_test' target, if possible
226+
# This requires CMake 3.11+, where the CMP0037 policy
227+
# configured to 'NEW' mode will not reserve target names
228+
# unless the corresponding feature is actually used
229+
if (POLICY CMP0037)
230+
cmake_policy(SET CMP0037 NEW)
212231
endif()
213-
add_feature_info("Testrunner" ENABLE_TESTS "Run unit tests with 'make ${TEST_TARGET_NAME}'")
232+
message(STATUS "Cmake 3.11+ detected, enabling 'test' target")
233+
add_custom_target(test)
234+
add_dependencies(test os_test)
214235
endif()
215236

237+
###
238+
### Add feature-summary details on non-default built targets
239+
###
240+
set(optional_targets test os_test coverage doc)
241+
set(target_test_description "Build and execute unit tests")
242+
set(target_os_test_description "Build and execute unit tests (legacy target)")
243+
set(target_coverage_description "Run unit tests and (if enabled) collect coverage data")
244+
set(target_doc_description "Build formatted API documentation (HTML+SVG)")
245+
foreach(_tname IN LISTS optional_targets)
246+
if(TARGET ${_tname})
247+
add_feature_info("Non-default target '${_tname}'" TRUE ${target_${_tname}_description})
248+
else()
249+
message(DEBUG "No target ${_tname}")
250+
endif()
251+
endforeach()
252+
216253
########### PRINT FEATURE SUMMARY ##############
217254
feature_summary(WHAT ALL
218255
INCLUDE_QUIET_PACKAGES
219256
FATAL_ON_MISSING_REQUIRED_PACKAGES
220-
DESCRIPTION "Displaying feature summary\n\nBuild configuration:")
257+
DESCRIPTION "Build configuration:")

0 commit comments

Comments
 (0)