Skip to content

Commit

Permalink
cmake: reworked everything and add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Apr 22, 2021
1 parent 46e457f commit 3929004
Show file tree
Hide file tree
Showing 11 changed files with 540 additions and 217 deletions.
93 changes: 88 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(olive-editor VERSION 0.2.0 LANGUAGES CXX)

option(BUILD_DOXYGEN "Build Doxygen documentation" OFF)
option(BUILD_TESTS "Build unit tests" ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -28,22 +29,64 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Set compiler options
if(MSVC)
set(OLIVE_COMPILE_OPTIONS
/WX
/wd4267
/wd4244
/experimental:external
/external:anglebrackets
/external:W0
"$<$<CONFIG:RELEASE>:/O2>"
"$<$<COMPILE_LANGUAGE:CXX>:/MP>"
)
else()
set(OLIVE_COMPILE_OPTIONS
"$<$<CONFIG:RELEASE>:-O2>"
-Werror
-Wuninitialized
-pedantic-errors
-Wall
-Wextra
-Wno-unused-parameter
-Wshadow
)
endif()

set(OLIVE_DEFINITIONS -DAPPVERSION="${PROJECT_VERSION}" -DQT_DEPRECATED_WARNINGS)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# Link OpenGL
if(UNIX AND NOT APPLE AND NOT DEFINED OpenGL_GL_PREFERENCE)
set(OpenGL_GL_PREFERENCE LEGACY)
endif()

find_package(OpenGL REQUIRED)
list(APPEND OLIVE_LIBRARIES OpenGL::GL)

# Link OpenColorIO
find_package(OpenColorIO 2.0.0 REQUIRED)
list(APPEND OLIVE_LIBRARIES ${OCIO_LIBRARIES})
list(APPEND OLIVE_INCLUDE_DIRS ${OCIO_INCLUDE_DIRS})

# Link OpenImageIO
find_package(OpenImageIO 2.1.12 REQUIRED)
list(APPEND OLIVE_LIBRARIES ${OIIO_LIBRARIES})
list(APPEND OLIVE_INCLUDE_DIRS ${OIIO_INCLUDE_DIRS})

# Link OpenEXR
find_package(OpenEXR REQUIRED)
list(APPEND OLIVE_LIBRARIES ${OPENEXR_LIBRARIES})
list(APPEND OLIVE_INCLUDE_DIRS ${OPENEXR_INCLUDES})
if (APPLE)
# HACK: Brew on macOS separates OpenEXR and IlmBase into two folders even though they seem to
# expect to be in one. This includes the IlmBase files as if they were in the same folders
# as the OpenEXR headers. This would be better rolled into FindOpenEXR.cmake.
list(APPEND OLIVE_INCLUDE_DIRS ${ILMBASE_INCLUDES}/OpenEXR)
endif()

# Link Qt 5
find_package(Qt5 5.6 REQUIRED
COMPONENTS
Core
Expand All @@ -55,7 +98,17 @@ find_package(Qt5 5.6 REQUIRED
LinguistTools
Concurrent
)
list(APPEND OLIVE_LIBRARIES
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Multimedia
Qt5::OpenGL
Qt5::Svg
Qt5::Concurrent
)

# Link FFmpeg
find_package(FFMPEG 3.0 REQUIRED
COMPONENTS
avutil
Expand All @@ -65,19 +118,43 @@ find_package(FFMPEG 3.0 REQUIRED
swscale
swresample
)
list(APPEND OLIVE_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS})
list(APPEND OLIVE_LIBRARIES
FFMPEG::avutil
FFMPEG::avcodec
FFMPEG::avformat
FFMPEG::avfilter
FFMPEG::swscale
FFMPEG::swresample
)

# Optional: Link OpenTimelineIO
find_package(OpenTimelineIO)

if (NOT OpenTimelineIO_FOUND)
if (OpenTimelineIO_FOUND)
list(APPEND OLIVE_DEFINITIONS USE_OTIO)
list(APPEND OLIVE_INCLUDE_DIRS ${OTIO_INCLUDE_DIRS})
list(APPEND OLIVE_LIBRARIES ${OTIO_LIBRARIES})
else()
message(" OpenTimelineIO interchange will be disabled.")
endif()

# Optional: Link Google Crashpad
find_package(GoogleCrashpad)

if (NOT GoogleCrashpad_FOUND)
if (GoogleCrashpad_FOUND)
list(APPEND OLIVE_DEFINITIONS USE_CRASHPAD)
list(APPEND OLIVE_INCLUDE_DIRS ${CRASHPAD_INCLUDE_DIRS})
list(APPEND OLIVE_LIBRARIES ${CRASHPAD_LIBRARIES})
else()
message(" Automatic crash reporting will be disabled.")

if (APPLE)
# Enables use of special functions for slider dragging, only linked if Crashpad isn't found
# because Crashpad links it itself and will cause duplicate references if we also link it
list(APPEND OLIVE_LIBRARIES "-framework ApplicationServices")
endif()
endif()

# Generate Git hash
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
find_package(Git)
if(GIT_FOUND)
Expand All @@ -95,10 +172,16 @@ else()
message("Olive: No Git hash defined!")
endif()

# Optional: Find Doxygen if requested
if(BUILD_DOXYGEN)
find_package(Doxygen)
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_subdirectory(app)

if (BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
Loading

0 comments on commit 3929004

Please sign in to comment.