From 4e4a95c64840bca38440027c66ebce4705a45429 Mon Sep 17 00:00:00 2001 From: Frank Dana Date: Mon, 19 Apr 2021 15:59:52 -0400 Subject: [PATCH] Gitlab-CI: Update Windows builder configs, OpenShotAudio linking; enable Windows unit tests (#657) * Remove no-longer-used cmake Modules * Don't use OpenShot.h in ExampleHtml.cpp When `#include`-ing the whole mess, building the file was leading to what looked like out-of-memory errors. Replacing the monolithic header with just the necessary ones cleared it up. * .gitlab-ci.yml: Update for new Windows setup * Make unit tests work under Windows - Copying the built and depended (libopenshot-audio) DLLs into the unit test dir before building the tests ensures that when the test executables are run by the Catch.cmake module to discover their contents, the executables will find the DLLs they need in order to run. * Gitlab-ci: Run unit tests on Windows * Rename openshot-html-example (The former name, openshot-html-test, was too close to the new name format for all of our unit test executables, making things unnecessarily confusing.) * Rename JuceHeader.h to OpenShotAudio.h * Github Actions: Install ALSA libs With the switch to an EXPORTED CMake configuration for libopenshot-audio, its dependencies become our dependencies. Which means that CMake now correctly requires that the ALSA libs be installed. --- .github/workflows/ci.yml | 2 +- .gitlab-ci.yml | 44 +++--- CMakeLists.txt | 1 + cmake/Modules/FindJack.cmake | 33 ----- cmake/Modules/FindOpenShotAudio.cmake | 188 ------------------------ cmake/Modules/FindUnitTest++.cmake | 85 ----------- cmake/Modules/UnitTest++_CMakeLists.txt | 35 ----- examples/CMakeLists.txt | 4 +- examples/ExampleHtml.cpp | 5 +- src/AudioBufferSource.h | 2 +- src/AudioReaderSource.h | 2 +- src/AudioResampler.h | 2 +- src/CMakeLists.txt | 37 ++++- src/Clip.h | 2 +- src/Frame.cpp | 2 +- src/Frame.h | 2 +- src/Settings.h | 2 +- src/ZmqLogger.h | 2 +- src/protobuf_messages/CMakeLists.txt | 17 +++ tests/CMakeLists.txt | 47 +++--- 20 files changed, 109 insertions(+), 405 deletions(-) delete mode 100644 cmake/Modules/FindJack.cmake delete mode 100644 cmake/Modules/FindOpenShotAudio.cmake delete mode 100644 cmake/Modules/FindUnitTest++.cmake delete mode 100644 cmake/Modules/UnitTest++_CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16bb0327..94017862 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: sudo apt update sudo apt install \ cmake swig doxygen graphviz curl lcov \ - libopenshot-audio-dev \ + libopenshot-audio-dev libasound2-dev \ qtbase5-dev qtbase5-dev-tools \ libfdk-aac-dev libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libavfilter-dev libswscale-dev libpostproc-dev libswresample-dev \ libzmq3-dev libmagick++-dev \ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61e9defc..ed8925ec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -71,19 +71,17 @@ windows-builder-x64: - try { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } catch { $_.Exception.Response.StatusCode.Value__ } - if (-not (Test-Path "artifacts.zip")) { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } - Expand-Archive -Path artifacts.zip -DestinationPath . - - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x64" - - $env:UNITTEST_DIR = "C:\msys64\usr" - - $env:RESVGDIR = "C:\msys64\usr" - - $env:Path = "C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\usr\lib\cmake\UnitTest++;C:\msys64\home\jonathan\depot_tools;C:\msys64\usr;C:\msys64\usr\lib;C:\msys64\usr\local\x64\mingw\bin;C:\msys64\usr\local;" + $env:Path; - - New-Item -ItemType Directory -Force -Path build - - cd build - - cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x64" -D"PYTHON_MODULE_PATH=python" -D"RUBY_MODULE_PATH=ruby" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" ../ - - mingw32-make install - - $PROJECT_VERSION = (Select-String -Path "../CMakeLists.txt" -Pattern '^set\(PROJECT_VERSION_FULL "(.*)\"' | %{$_.Matches.Groups[1].value}) - - $PROJECT_SO = (Select-String -Path "../CMakeLists.txt" -Pattern '^set\(PROJECT_SO_VERSION (.*)\)' | %{$_.Matches.Groups[1].value}) - - New-Item -path "install-x64/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID`nCI_PIPELINE_ID:$CI_PIPELINE_ID`nVERSION:$PROJECT_VERSION`nSO:$PROJECT_SO" -ItemType file -force + - $env:Path = "C:\msys64\mingw64\bin;C:\msys64\usr\bin;C:\msys64\usr\local\bin;" + $env:Path; + - $env:MSYSTEM = "MINGW64" + - cmake -B build -S . -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x64" -D"OpenShotAudio_ROOT=$CI_PROJECT_DIR\build\install-x64" -D"PYTHON_MODULE_PATH=python" -D"RUBY_MODULE_PATH=ruby" -G "MinGW Makefiles" -D"CMAKE_BUILD_TYPE:STRING=Release" + - cmake --build build + - cmake --build build --target coverage + - cmake --install build + - $PROJECT_VERSION = (Select-String -Path "CMakeLists.txt" -Pattern '^set\(PROJECT_VERSION_FULL "(.*)\"' | %{$_.Matches.Groups[1].value}) + - $PROJECT_SO = (Select-String -Path "CMakeLists.txt" -Pattern '^set\(PROJECT_SO_VERSION (.*)\)' | %{$_.Matches.Groups[1].value}) + - New-Item -path "build/install-x64/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID`nCI_PIPELINE_ID:$CI_PIPELINE_ID`nVERSION:$PROJECT_VERSION`nSO:$PROJECT_SO" -ItemType file -force - $PREV_GIT_LABEL=(git describe --tags --abbrev=0 '@^') - - git log "$PREV_GIT_LABEL..@" --oneline --pretty=format:"- %C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(25,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D" --date=short > "install-x64/share/$CI_PROJECT_NAME.log" + - git log "$PREV_GIT_LABEL..@" --oneline --pretty=format:"- %C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(25,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D" --date=short > "build/install-x64/share/$CI_PROJECT_NAME.log" when: always except: - tags @@ -100,19 +98,17 @@ windows-builder-x86: - try { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } catch { $_.Exception.Response.StatusCode.Value__ } - if (-not (Test-Path "artifacts.zip")) { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } - Expand-Archive -Path artifacts.zip -DestinationPath . - - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x86" - - $env:UNITTEST_DIR = "C:\msys32\usr" - - $env:RESVGDIR = "C:\msys32\usr" - - $env:Path = "C:\msys32\mingw32\bin;C:\msys32\mingw32\lib;C:\msys32\usr\lib\cmake\UnitTest++;C:\msys32\home\jonathan\depot_tools;C:\msys32\usr;C:\msys32\usr\lib;C:\msys32\usr\local\x64\mingw\bin;C:\msys32\usr\local;" + $env:Path; - - New-Item -ItemType Directory -Force -Path build - - cd build - - cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -D"PYTHON_MODULE_PATH=python" -D"RUBY_MODULE_PATH=ruby" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" ../ - - mingw32-make install - - $PROJECT_VERSION = (Select-String -Path "../CMakeLists.txt" -Pattern '^set\(PROJECT_VERSION_FULL "(.*)\"' | %{$_.Matches.Groups[1].value}) - - $PROJECT_SO = (Select-String -Path "../CMakeLists.txt" -Pattern '^set\(PROJECT_SO_VERSION (.*)\)' | %{$_.Matches.Groups[1].value}) - - New-Item -path "install-x86/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID`nCI_PIPELINE_ID:$CI_PIPELINE_ID`nVERSION:$PROJECT_VERSION`nSO:$PROJECT_SO" -ItemType file -force + - $env:Path = "C:\msys64\mingw32\bin;C:\msys64\usr\bin;C:\msys64\usr\local\bin;" + $env:Path; + - $env:MSYSTEM = "MINGW32" + - cmake -B build -S . -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -D"OpenShotAudio_ROOT=$CI_PROJECT_DIR\build\install-x86" -D"PYTHON_MODULE_PATH=python" -D"RUBY_MODULE_PATH=ruby" -G "MinGW Makefiles" -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" + - cmake --build build + - cmake --build build --target coverage + - cmake --install build + - $PROJECT_VERSION = (Select-String -Path "CMakeLists.txt" -Pattern '^set\(PROJECT_VERSION_FULL "(.*)\"' | %{$_.Matches.Groups[1].value}) + - $PROJECT_SO = (Select-String -Path "CMakeLists.txt" -Pattern '^set\(PROJECT_SO_VERSION (.*)\)' | %{$_.Matches.Groups[1].value}) + - New-Item -path "build/install-x86/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID`nCI_PIPELINE_ID:$CI_PIPELINE_ID`nVERSION:$PROJECT_VERSION`nSO:$PROJECT_SO" -ItemType file -force - $PREV_GIT_LABEL=(git describe --tags --abbrev=0 '@^') - - git log "$PREV_GIT_LABEL..@" --oneline --pretty=format:"- %C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(25,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D" --date=short > "install-x86/share/$CI_PROJECT_NAME.log" + - git log "$PREV_GIT_LABEL..@" --oneline --pretty=format:"- %C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(25,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D" --date=short > "build/install-x86/share/$CI_PROJECT_NAME.log" when: always except: - tags diff --git a/CMakeLists.txt b/CMakeLists.txt index f88cf7d2..97d05b44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,6 +179,7 @@ if(NOT Catch2_FOUND) set(CAN_BUILD_TESTS FALSE) endif() if(CAN_BUILD_TESTS) + enable_testing() if(ENABLE_PARALLEL_CTEST) # Figure out the amount of parallelism for CTest include(ProcessorCount) diff --git a/cmake/Modules/FindJack.cmake b/cmake/Modules/FindJack.cmake deleted file mode 100644 index 910f450d..00000000 --- a/cmake/Modules/FindJack.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# - Try to find Jack Audio Libraries -# libjack; libjackserver; -# Once done this will define -# LIBJACK_FOUND - System has libjack.so -# LIBJACK_INCLUDE_DIRS - The jack.h include directories -# LIBJACK_LIBRARIES - The libraries needed to use jack - -find_path(LIBJACK_INCLUDE_DIR jack/jack.h - PATHS /usr/include/ - $ENV{JACK_DIR}/include/ - $ENV{JACK_DIR}/includes/ ) - -find_library(LIBJACK_libjack_LIBRARY - NAMES libjack jack - HINTS /usr/lib/ - /usr/lib/jack/ - $ENV{JACK_DIR}/lib/ ) - -find_library(LIBJACK_libjackserver_LIBRARY - NAMES libjackserver jackserver - HINTS /usr/lib/ - /usr/lib/jack/ - $ENV{JACK_DIR}/lib/ ) - -set(LIBJACK_LIBRARIES ${LIBJACK_libjack_LIBRARY} ${LIBJACK_libjackserver_LIBRARY} ) -set(LIBJACK_LIBRARY ${LIBJACK_LIBRARIES}) -set(LIBJACK_INCLUDE_DIRS ${LIBJACK_INCLUDE_DIR} ) - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set LIBJACK_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(LIBJACK DEFAULT_MSG - LIBJACK_LIBRARY LIBJACK_INCLUDE_DIR) diff --git a/cmake/Modules/FindOpenShotAudio.cmake b/cmake/Modules/FindOpenShotAudio.cmake deleted file mode 100644 index 4716112e..00000000 --- a/cmake/Modules/FindOpenShotAudio.cmake +++ /dev/null @@ -1,188 +0,0 @@ -# - Try to find JUCE-based OpenShot Audio Library -# libopenshot-audio; -# Once done this will define -# LIBOPENSHOT_AUDIO_FOUND - System has libjuce.so -# LIBOPENSHOT_AUDIO_INCLUDE_DIRS - The juce.h include directories -# LIBOPENSHOT_AUDIO_LIBRARIES - The libraries needed to use juce - -if("$ENV{LIBOPENSHOT_AUDIO_DIR}" AND NOT "${OpenShotAudio_FIND_QUIETLY}") - message(STATUS "Looking for OpenShotAudio in: $ENV{LIBOPENSHOT_AUDIO_DIR}") -endif() - -# Find the libopenshot-audio header files (check env/cache vars first) -find_path( - OpenShotAudio_INCLUDE_DIR - JuceHeader.h - HINTS - ENV LIBOPENSHOT_AUDIO_DIR - PATHS - ${LIBOPENSHOT_AUDIO_DIR} - ${OpenShotAudio_ROOT} - ${OpenShotAudio_INCLUDE_DIR} - PATH_SUFFIXES - include/libopenshot-audio - libopenshot-audio - include - NO_DEFAULT_PATH -) - -# Find the libopenshot-audio header files (fallback to std. paths) -find_path( - OpenShotAudio_INCLUDE_DIR - JuceHeader.h - HINTS - ENV LIBOPENSHOT_AUDIO_DIR - PATHS - ${LIBOPENSHOT_AUDIO_DIR} - ${OpenShotAudio_ROOT} - ${OpenShotAudio_INCLUDE_DIR} - PATH_SUFFIXES - include/libopenshot-audio - libopenshot-audio - include -) - -# Find libopenshot-audio.so / libopenshot-audio.dll (check env/cache vars first) -find_library( - OpenShotAudio_LIBRARY - NAMES - libopenshot-audio - openshot-audio - HINTS - ENV LIBOPENSHOT_AUDIO_DIR - PATHS - ${LIBOPENSHOT_AUDIO_DIR} - ${OpenShotAudio_ROOT} - ${OpenShotAudio_LIBRARY} - PATH_SUFFIXES - lib/libopenshot-audio - libopenshot-audio - lib - NO_DEFAULT_PATH -) - -# Find libopenshot-audio.so / libopenshot-audio.dll (fallback) -find_library( - OpenShotAudio_LIBRARY - NAMES - libopenshot-audio - openshot-audio - HINTS - ENV LIBOPENSHOT_AUDIO_DIR - PATHS - ${LIBOPENSHOT_AUDIO_DIR} - ${OpenShotAudio_ROOT} - ${OpenShotAudio_LIBRARY} - PATH_SUFFIXES - lib/libopenshot-audio - libopenshot-audio - lib -) - -set(OpenShotAudio_LIBRARIES "${OpenShotAudio_LIBRARY}") -set(OpenShotAudio_LIBRARY "${OpenShotAudio_LIBRARIES}") -set(OpenShotAudio_INCLUDE_DIRS "${OpenShotAudio_INCLUDE_DIR}") - -if(OpenShotAudio_INCLUDE_DIR AND EXISTS "${OpenShotAudio_INCLUDE_DIR}/JuceHeader.h") - file(STRINGS "${OpenShotAudio_INCLUDE_DIR}/JuceHeader.h" libosa_version_str - REGEX "versionString.*=.*\"[^\"]+\"") - if(libosa_version_str MATCHES "versionString.*=.*\"([^\"]+)\"") - set(OpenShotAudio_VERSION_STRING ${CMAKE_MATCH_1}) - endif() - unset(libosa_version_str) - string(REGEX REPLACE "^([0-9]+\.[0-9]+\.[0-9]+).*$" "\\1" - OpenShotAudio_VERSION "${OpenShotAudio_VERSION_STRING}") -endif() - -# If we couldn't parse M.N.B version, don't keep any of it -if(NOT OpenShotAudio_VERSION) - unset(OpenShotAudio_VERSION) - unset(OpenShotAudio_VERSION_STRING) -endif() - -# Determine compatibility with requested version in find_package() -if(OpenShotAudio_FIND_VERSION AND OpenShotAudio_VERSION) - if("${OpenShotAudio_FIND_VERSION}" STREQUAL "${OpenShotAudio_VERSION}") - set(OpenShotAudio_VERSION_EXACT TRUE) - endif() - if("${OpenShotAudio_FIND_VERSION}" VERSION_GREATER "${OpenShotAudio_VERSION}") - set(OpenShotAudio_VERSION_COMPATIBLE FALSE) - else() - set(OpenShotAudio_VERSION_COMPATIBLE TRUE) - endif() -endif() - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set OpenShotAudio_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(OpenShotAudio - REQUIRED_VARS - OpenShotAudio_LIBRARIES - OpenShotAudio_INCLUDE_DIRS - VERSION_VAR - OpenShotAudio_VERSION_STRING -) - -if(OpenShotAudio_FOUND) - set(OpenShotAudio_INCLUDE_DIRS "${OpenShotAudio_INCLUDE_DIRS}" - CACHE PATH "The paths to libopenshot-audio's header files" FORCE) - set(OpenShotAudio_LIBRARIES "${OpenShotAudio_LIBRARIES}" - CACHE STRING "The libopenshot-audio library to link with" FORCE) - if(DEFINED OpenShotAudio_VERSION) - set(OpenShotAudio_VERSION ${OpenShotAudio_VERSION} - CACHE STRING "The version of libopenshot-audio detected" FORCE) - endif() -endif() - -if(OpenShotAudio_FOUND AND NOT TARGET OpenShot::Audio) - message(STATUS "Creating IMPORTED target OpenShot::Audio") - if(WIN32) - add_library(OpenShot::Audio UNKNOWN IMPORTED) - else() - add_library(OpenShot::Audio SHARED IMPORTED) - endif() - - set_property(TARGET OpenShot::Audio APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${OpenShotAudio_INCLUDE_DIRS}") - - # Juce requires either DEBUG or NDEBUG to be defined on MacOS. - # -DNDEBUG is set by cmake for all release configs, so add - # -DDEBUG for debug builds. We'll do this for all OSes, even - # though only MacOS requires it. - # The generator expression translates to: - # CONFIG == "DEBUG" ? "DEBUG" : "" - set_property(TARGET OpenShot::Audio APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS $<$:DEBUG>) - - # For the Ruby bindings - set_property(TARGET OpenShot::Audio APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS HAVE_ISFINITE=1) - - if(WIN32) - set_property(TARGET OpenShot::Audio APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS IGNORE_JUCE_HYPOT=1) - set_property(TARGET OpenShot::Audio APPEND PROPERTY - INTERFACE_COMPILE_OPTIONS -include cmath) - elseif(APPLE) - # Prevent compiling with __cxx11 - set_property(TARGET OpenShot::Audio APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS _GLIBCXX_USE_CXX11_ABI=0) - list(APPEND framework_deps - "-framework Carbon" - "-framework Cocoa" - "-framework CoreFoundation" - "-framework CoreAudio" - "-framework CoreMidi" - "-framework IOKit" - "-framework AGL" - "-framework AudioToolbox" - "-framework QuartzCore" - "-lobjc" - "-framework Accelerate" - ) - target_link_libraries(OpenShot::Audio INTERFACE ${framework_deps}) - endif() - - set_property(TARGET OpenShot::Audio APPEND PROPERTY - IMPORTED_LOCATION "${OpenShotAudio_LIBRARIES}") -endif() diff --git a/cmake/Modules/FindUnitTest++.cmake b/cmake/Modules/FindUnitTest++.cmake deleted file mode 100644 index ce1bdc45..00000000 --- a/cmake/Modules/FindUnitTest++.cmake +++ /dev/null @@ -1,85 +0,0 @@ -# Locate UnitTest++ -# This module defines -# UnitTest++_FOUND, if successful -# UnitTest++_LIBRARIES, the library path -# UnitTest++_INCLUDE_DIRS, where to find the headers - -find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_UnitTest QUIET UnitTest++) - set(UnitTest++_VERSION ${PC_UnitTest_VERSION}) -endif() - - -FIND_PATH(UnitTest++_INCLUDE_DIRS UnitTest++.h - DOC - "Location of UnitTest++ header files" - PATH_SUFFIXES - unittest++ - UnitTest++ # Fedora, Arch - unittest-cpp # openSUSE - HINTS - ${PC_UnitTest++_INCLUDEDIR} - ${PC_UnitTest++_INCLUDE_DIRS} - PATHS - ${UnitTest++_ROOT} - ${UNITTEST_DIR} - $ENV{UNITTEST_DIR}/src - $ENV{UNITTEST_DIR} - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /sw # Fink - /opt - /opt/local # DarwinPorts - /opt/csw # Blastwave - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment]/include - /usr/freeware -) - -FIND_LIBRARY(UnitTest++_LIBRARIES - NAMES unittest++ UnitTest++ - DOC - "Location of UnitTest++ shared library" - HINTS - ${PC_UnitTest++_LIBDIR} - ${PC_UnitTest++_LIBRARY_DIRS} - PATHS - ${UnitTest++_ROOT} - ${UnitTest++_ROOT}/lib - ${UNITTEST_DIR} - $ENV{UNITTEST_DIR} - $ENV{UNITTEST_DIR}/lib - $ENV{UNITTEST_DIR}/build - ~/Library/Frameworks - /Library/Frameworks - /usr/local/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment]/lib - /usr/freeware/lib64 -) - -if(UnitTest++_LIBRARIES AND UnitTest++_INCLUDE_DIRS) - set(UnitTest++_FOUND TRUE) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(UnitTest++ - REQUIRED_VARS - UnitTest++_LIBRARIES - UnitTest++_INCLUDE_DIRS - VERSION_VAR - UnitTest++_VERSION -) - -# Excessive backwards-compatibility paranoia -set(UnitTest++_LIBRARY "${UnitTest++_LIBRARIES}" PARENT_SCOPE) -set(UnitTest++_INCLUDE_DIR "${UnitTest++_INCLUDE_DIRS}" PARENT_SCOPE) -# Even more excessive backwards-compatibility paranoia -set(UNITTEST++_FOUND "${UnitTest++_FOUND}" PARENT_SCOPE) -set(UNITTEST++_LIBRARY "${UnitTest++_LIBRARIES}" PARENT_SCOPE) -set(UNITTEST++_INCLUDE_DIR "${UnitTest++_INCLUDE_DIRS}" PARENT_SCOPE) - diff --git a/cmake/Modules/UnitTest++_CMakeLists.txt b/cmake/Modules/UnitTest++_CMakeLists.txt deleted file mode 100644 index e1bdae3c..00000000 --- a/cmake/Modules/UnitTest++_CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -cmake_minimum_required(VERSION 2.8.1) -project(UnitTest++) - -# get the main sources -file(GLOB SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp src/*.h) -source_group("" FILES ${SRCS}) - -# get platform specific sources -if (WIN32) - set(PLAT_DIR Win32) -else() - set(PLAT_DIR Posix) -endif(WIN32) -file(GLOB PLAT_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/${PLAT_DIR}/*.cpp src/${PLAT_DIR}/*.h) -source_group(${PLAT_DIR} FILES ${PLAT_SRCS}) - -# create the lib -add_library(UnitTestPP SHARED ${SRCS} ${PLAT_SRCS}) -set_target_properties(UnitTestPP PROPERTIES OUTPUT_NAME UnitTest++) -include_directories(src) - -# build the test runner -file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/tests/*.cpp src/tests/*.h) -source_group( "" FILES ${TEST_SRCS}) -add_executable(TestUnitTestPP ${TEST_SRCS}) -set_target_properties(TestUnitTestPP PROPERTIES OUTPUT_NAME TestUnitTest++) -target_link_libraries(TestUnitTestPP UnitTestPP) - -# turn on testing -enable_testing() -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V) - -# add the test runner as a test -add_test(NAME TestUnitTestPP COMMAND TestUnitTest++ ${CONFIG_PATH} ${CONFIG_TASKS_PATH} ${SOUND_LOG_PATH}) -add_dependencies(check TestUnitTestPP) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 87475128..3328e111 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -42,8 +42,8 @@ target_compile_definitions(openshot-example PRIVATE # Link test executable to the new library target_link_libraries(openshot-example openshot) -add_executable(openshot-html-test ExampleHtml.cpp) -target_link_libraries(openshot-html-test openshot Qt5::Gui) +add_executable(openshot-html-example ExampleHtml.cpp) +target_link_libraries(openshot-html-example openshot Qt5::Gui) ############### PLAYER EXECUTABLE ################ # Create test executable diff --git a/examples/ExampleHtml.cpp b/examples/ExampleHtml.cpp index 928a05fe..852543ae 100644 --- a/examples/ExampleHtml.cpp +++ b/examples/ExampleHtml.cpp @@ -35,7 +35,10 @@ #include #include -#include "OpenShot.h" +#include "QtHtmlReader.h" +#include "FFmpegWriter.h" +#include "Fraction.h" +#include "Enums.h" // for GRAVITY_BOTTOM_RIGHT #include "CrashHandler.h" using namespace openshot; diff --git a/src/AudioBufferSource.h b/src/AudioBufferSource.h index ae5ce014..a899d8da 100644 --- a/src/AudioBufferSource.h +++ b/src/AudioBufferSource.h @@ -32,7 +32,7 @@ #define OPENSHOT_AUDIOBUFFERSOURCE_H #include -#include "JuceHeader.h" +#include /// This namespace is the default namespace for all code in the openshot library namespace openshot diff --git a/src/AudioReaderSource.h b/src/AudioReaderSource.h index d049e1b3..2b0cc0ea 100644 --- a/src/AudioReaderSource.h +++ b/src/AudioReaderSource.h @@ -33,7 +33,7 @@ #include #include "ReaderBase.h" -#include "JuceHeader.h" +#include /// This namespace is the default namespace for all code in the openshot library namespace openshot diff --git a/src/AudioResampler.h b/src/AudioResampler.h index 02c5cec1..f9f94d83 100644 --- a/src/AudioResampler.h +++ b/src/AudioResampler.h @@ -32,7 +32,7 @@ #define OPENSHOT_RESAMPLER_H #include "AudioBufferSource.h" -#include "JuceHeader.h" +#include namespace openshot { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 85f1c460..434f869a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -432,19 +432,46 @@ endif() # Install primary library install(TARGETS openshot + COMPONENT runtime ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot) -install( - DIRECTORY . +install(DIRECTORY . + COMPONENT devel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot FILES_MATCHING PATTERN "*.h" ) -install(FILES ${ProtobufHeaders} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot -) + +# On Windows, we copy project output DLLs into the tests dir +# so that the unit test executables can find them +if(CMAKE_VERSION VERSION_GREATER 3.13 AND WIN32) + # Copy the DLLs immediately after they're built + add_custom_command(TARGET openshot POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E copy_if_different + "$" + "${PROJECT_BINARY_DIR}/tests/" + BYPRODUCTS + "${PROJECT_BINARY_DIR}/tests/libopenshot.dll" + COMMENT + "Copying libopenshot DLL to unit test directory" + ) + # Also copy libopenshot-audio DLL + get_target_property(AUDIO_LIB_PATH OpenShot::Audio LOCATION) + add_custom_target(test-install-audio-dll ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${AUDIO_LIB_PATH}" + "${PROJECT_BINARY_DIR}/tests/" + BYPRODUCTS + "${PROJECT_BINARY_DIR}/tests/libopenshot-audio.dll" + COMMENT + "Copying OpenShotAudio library DLL to unit test directory" + ) + add_dependencies(test-install-audio-dll OpenShot::Audio) +endif() + ############### CPACK PACKAGING ############## if(MINGW) diff --git a/src/Clip.h b/src/Clip.h index 5f12ff83..818d8f7c 100644 --- a/src/Clip.h +++ b/src/Clip.h @@ -54,7 +54,7 @@ #include "Frame.h" #include "KeyFrame.h" #include "ReaderBase.h" -#include "JuceHeader.h" +#include namespace openshot { diff --git a/src/Frame.cpp b/src/Frame.cpp index 5644db58..244b065f 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -29,7 +29,7 @@ */ #include "Frame.h" -#include "JuceHeader.h" +#include #include #include diff --git a/src/Frame.h b/src/Frame.h index 75976f17..18a22d11 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -52,7 +52,7 @@ #include "AudioBufferSource.h" #include "AudioResampler.h" #include "Fraction.h" -#include "JuceHeader.h" +#include #ifdef USE_IMAGEMAGICK #include "MagickUtilities.h" #endif diff --git a/src/Settings.h b/src/Settings.h index 4d16f6b1..36ba2917 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -42,7 +42,7 @@ #include #include #include -#include "JuceHeader.h" +#include namespace openshot { diff --git a/src/ZmqLogger.h b/src/ZmqLogger.h index deb87e35..da56a199 100644 --- a/src/ZmqLogger.h +++ b/src/ZmqLogger.h @@ -42,7 +42,7 @@ #include #include #include -#include "JuceHeader.h" +#include #include "Settings.h" diff --git a/src/protobuf_messages/CMakeLists.txt b/src/protobuf_messages/CMakeLists.txt index e62fca64..16df8a2b 100644 --- a/src/protobuf_messages/CMakeLists.txt +++ b/src/protobuf_messages/CMakeLists.txt @@ -55,11 +55,28 @@ set_target_properties(openshot_protobuf PROPERTIES # Install protobuf library and generated headers install(TARGETS openshot_protobuf + COMPONENT runtime RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot ) install(FILES ${ProtoHeaders} + COMPONENT devel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot/protobuf_messages ) + +# On Windows, we copy project output DLLs into the test dirs +# so that the unit test executables can find them +if(CMAKE_VERSION VERSION_GREATER 3.13 AND WIN32) + add_custom_command(TARGET openshot_protobuf POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E copy_if_different + "$" + "${PROJECT_BINARY_DIR}/tests/" + BYPRODUCTS + "${PROJECT_BINARY_DIR}/tests/libopenshot_protobuf.dll" + COMMENT + "Copying libopenshot_protobuf DLL to unit test directory" + ) +endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fff345e8..d39c416e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -80,28 +80,29 @@ endif() ### ### Catch2 unit tests ### -if (CAN_BUILD_TESTS) - include(Catch) - include(CTest) - - # Create object library for test executable main(), - # to avoid recompiling for every test - add_library(catch-main OBJECT catch_main.cpp) - - 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 Catch2::Catch2 openshot) - # Automatically configure CTest targets from Catch2 test cases - catch_discover_tests( - openshot-${tname}-test - TEST_PREFIX ${tname}: - ) - list(APPEND CATCH2_TEST_TARGETS openshot-${tname}-test) - endforeach() - # Export target list for coverage use - set(UNIT_TEST_TARGETS ${CATCH2_TEST_TARGETS} PARENT_SCOPE) +if (NOT CAN_BUILD_TESTS) + return() endif() +include(CTest) +include(Catch) + +# Create object library for test executable main(), +# to avoid recompiling for every test +add_library(catch-main OBJECT catch_main.cpp) + +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 Catch2::Catch2 openshot) + # Automatically configure CTest targets from Catch2 test cases + catch_discover_tests( + openshot-${tname}-test + TEST_PREFIX ${tname}: + ) + list(APPEND CATCH2_TEST_TARGETS openshot-${tname}-test) +endforeach() +# Export target list for coverage use +set(UNIT_TEST_TARGETS ${CATCH2_TEST_TARGETS} PARENT_SCOPE)