CMake: Code and Find module tweaks

- FindOpenShotAudio takes over -DDEBUG, -DHAVE_ISFINITE logic
  (now set on OpenShot::Audio target when appropriate)
- Tweaks to BlackMagic dependency discovery
- Reverse the test-disabling logic, `DISABLE_TESTS FALSE` cache
  variable changed to `ENABLE_TESTS TRUE`
This commit is contained in:
FeRD (Frank Dana)
2020-10-18 11:04:28 -04:00
parent 1ae52808c7
commit d910949189
3 changed files with 26 additions and 38 deletions

View File

@@ -107,8 +107,8 @@ ENDIF(WIN32)
############## Code Coverage #########################
if (ENABLE_COVERAGE AND NOT ENABLE_TESTS)
message(WARNING "ENABLE_COVERAGE requires tests, overriding DISABLE_TESTS")
set(DISABLE_TESTS OFF CACHE BOOL "Don't build unit tests" FORCE)
message(WARNING "ENABLE_COVERAGE requires unit tests, forcing ENABLE_TESTS")
set(ENABLE_TESTS ON CACHE BOOL "Don't build unit tests" FORCE)
endif()
if (ENABLE_COVERAGE)
@@ -121,11 +121,6 @@ if (ENABLE_COVERAGE)
endif()
add_feature_info("Coverage" ENABLE_COVERAGE "analyze test coverage and generate report")
# 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.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
# Make sure we've picked some build type, default to release
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
@@ -138,12 +133,17 @@ add_subdirectory(src)
add_subdirectory(examples)
add_subdirectory(bindings)
########## Configure Version.h header ##############
###
### Configure Version.h header
###
# (Note: This comes after the subdirectories, because it needs variables
# set during the dependency discovery in src/CMakeLists.txt)
configure_file(src/OpenShotVersion.h.in src/OpenShotVersion.h @ONLY)
# We'll want that installed later
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/OpenShotVersion.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot)
################### DOCUMENTATION ###################
# Find Doxygen (used for documentation)
set(DOCS_ENABLED FALSE) # Only set true if Doxygen is found and configured
@@ -180,8 +180,10 @@ if (ENABLE_COVERAGE)
NAME coverage
LCOV_ARGS "--no-external"
EXECUTABLE openshot-test
DEPENDENCIES openshot-test)
message("Generate coverage report with 'make coverage'")
DEPENDENCIES openshot-test
EXCLUDE "bindings" "examples" "${CMAKE_CURRENT_BINARY_DIR}/bindings"
)
message("Generate coverage report with 'make coverage'")
endif()
########### PRINT FEATURE SUMMARY ##############

View File

@@ -74,9 +74,6 @@ endif()
set_property(SOURCE openshot.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot)
### Unbreak std::isfinite()
add_definitions(-DHAVE_ISFINITE=1)
### Suppress a ton of warnings in the generated SWIG C++ code
set(SWIG_CXX_FLAGS "-Wno-unused-variable -Wno-unused-function \
-Wno-deprecated-copy -Wno-class-memaccess -Wno-cast-function-type \

View File

@@ -34,15 +34,6 @@ if (POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()
# 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.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
# Make sure we've picked some build type, default to debug
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Debug")
endif()
############### PROFILING #################
#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")
#set(PROFILER "/usr/lib/libtcmalloc.so.4")
@@ -155,16 +146,6 @@ set_target_properties(openshot PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
)
# BlackMagic related files
if(BLACKMAGIC_FOUND)
target_sources(openshot PRIVATE
DecklinkInput.cpp
DecklinkReader.cpp
DecklinkOutput.cpp
DecklinkWriter.cpp)
endif()
# Location of our includes, both internally and when installed
target_include_directories(openshot
PRIVATE
@@ -320,7 +301,10 @@ endif()
target_link_libraries(openshot PUBLIC OpenMP::OpenMP_CXX)
################### ZEROMQ #####################
###
### ZeroMQ
###
# Find ZeroMQ library (used for socket communication & logging)
find_package(ZeroMQ REQUIRED) # Creates libzmq target
@@ -370,9 +354,19 @@ if (ENABLE_BLACKMAGIC)
find_package(BlackMagic)
if (BLACKMAGIC_FOUND)
# BlackMagic related files
target_sources(openshot PRIVATE
DecklinkInput.cpp
DecklinkReader.cpp
DecklinkOutput.cpp
DecklinkWriter.cpp)
# Include Blackmagic headers (needed for compile)
target_include_directories(openshot PRIVATE ${BLACKMAGIC_INCLUDE_DIR})
# Link libopenshot with BlackMagic libs
target_link_libraries(openshot PUBLIC ${BLACKMAGIC_LIBRARY_DIR})
# define a preprocessor macro (used in the C++)
target_compile_definitions(openshot PUBLIC -DUSE_BLACKMAGIC=1)
list(APPEND CMAKE_SWIG_FLAGS -DUSE_BLACKMAGIC=1)
@@ -385,11 +379,6 @@ if(DEFINED PROFILER)
target_link_libraries(openshot PUBLIC ${PROFILER})
endif()
if(BLACKMAGIC_FOUND)
target_link_libraries(openshot PUBLIC ${BLACKMAGIC_LIBRARY_DIR})
endif()
if(WIN32)
# Required for exception handling on Windows
target_link_libraries(openshot PUBLIC "imagehlp" "dbghelp" )