Skip to content

Commit

Permalink
CMake: Use GNUInstallDirs for install paths (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Mar 12, 2020
1 parent e19291a commit 816118b
Showing 1 changed file with 49 additions and 48 deletions.
97 changes: 49 additions & 48 deletions src/CMakeLists.txt
Expand Up @@ -27,23 +27,25 @@
# Collect and display summary of options/dependencies
include(FeatureSummary)

include(GNUInstallDirs)

################ WINDOWS ##################
# Set some compiler options for Windows
# required for libopenshot-audio headers
IF (WIN32)
if (WIN32)
add_definitions( -DIGNORE_JUCE_HYPOT=1 )
SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -include cmath")
ENDIF(WIN32)
IF (APPLE)
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -include cmath")
endif()

if (APPLE)
# If you still get errors compiling with GCC 4.8, mac headers need to be patched: http://hamelot.co.uk/programming/osx-gcc-dispatch_block_t-has-not-been-declared-invalid-typedef/
SET_PROPERTY(GLOBAL PROPERTY JUCE_MAC "JUCE_MAC")
ADD_DEFINITIONS(-DNDEBUG)
SET(EXTENSION "mm")
set_property(GLOBAL PROPERTY JUCE_MAC "JUCE_MAC")
add_definitions(-DNDEBUG)
set(EXTENSION "mm")

SET(JUCE_PLATFORM_SPECIFIC_DIR build/macosx/platform_specific_code)
SET(JUCE_PLATFORM_SPECIFIC_LIBRARIES "-framework Carbon -framework Cocoa -framework CoreFoundation -framework CoreAudio -framework CoreMidi -framework IOKit -framework AGL -framework AudioToolbox -framework QuartzCore -lobjc -framework Accelerate")
ENDIF(APPLE)
set(JUCE_PLATFORM_SPECIFIC_DIR build/macosx/platform_specific_code)
set(JUCE_PLATFORM_SPECIFIC_LIBRARIES "-framework Carbon -framework Cocoa -framework CoreFoundation -framework CoreAudio -framework CoreMidi -framework IOKit -framework AGL -framework AudioToolbox -framework QuartzCore -lobjc -framework Accelerate")
endif()

################ IMAGE MAGICK ##################
# Set the Quantum Depth that ImageMagick was built with (default to 16 bits)
Expand All @@ -64,39 +66,40 @@ ELSE (OPENSHOT_IMAGEMAGICK_COMPATIBILITY)
ENDIF (OPENSHOT_IMAGEMAGICK_COMPATIBILITY)

# Find the ImageMagick++ library
FIND_PACKAGE(ImageMagick COMPONENTS Magick++ MagickWand MagickCore)
IF (ImageMagick_FOUND)
find_package(ImageMagick COMPONENTS Magick++ MagickWand MagickCore)
if (ImageMagick_FOUND)
# Include ImageMagick++ headers (needed for compile)
include_directories(${ImageMagick_INCLUDE_DIRS})

# define a global var (used in the C++)
add_definitions( -DUSE_IMAGEMAGICK=1 )
SET(CMAKE_SWIG_FLAGS "-DUSE_IMAGEMAGICK=1")
set(CMAKE_SWIG_FLAGS "-DUSE_IMAGEMAGICK=1")

ENDIF (ImageMagick_FOUND)
endif()

################# LIBOPENSHOT-AUDIO ###################
# Find JUCE-based openshot Audio libraries
FIND_PACKAGE(OpenShotAudio 0.2.0 REQUIRED)
find_package(OpenShotAudio 0.2.0 REQUIRED)

# Include Juce headers (needed for compile)
include_directories(${LIBOPENSHOT_AUDIO_INCLUDE_DIRS})

################# BLACKMAGIC DECKLINK ###################
# Find BlackMagic DeckLinkAPI libraries
IF (ENABLE_BLACKMAGIC)
FIND_PACKAGE(BlackMagic)
if (ENABLE_BLACKMAGIC)

find_package(BlackMagic)

IF (BLACKMAGIC_FOUND)
if (BLACKMAGIC_FOUND)
# Include Blackmagic headers (needed for compile)
include_directories(${BLACKMAGIC_INCLUDE_DIR})

# define a global var (used in the C++)
add_definitions( -DUSE_BLACKMAGIC=1 )
SET(CMAKE_SWIG_FLAGS "-DUSE_BLACKMAGIC=1")
set(CMAKE_SWIG_FLAGS "-DUSE_BLACKMAGIC=1")
endif()

ENDIF (BLACKMAGIC_FOUND)
ENDIF (ENABLE_BLACKMAGIC)
endif()

############### PROFILING #################
#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")
Expand Down Expand Up @@ -193,7 +196,7 @@ set(QT_PLAYER_SOURCES
file(GLOB_RECURSE OPENSHOT_QT_HEADERS ${CMAKE_SOURCE_DIR}/include/Qt/*.h)

# Disable RPATH
SET(CMAKE_MACOSX_RPATH 0)
set(CMAKE_MACOSX_RPATH 0)

############### CREATE LIBRARY #################
# Create shared openshot library
Expand Down Expand Up @@ -293,7 +296,7 @@ endforeach()

################### FFMPEG #####################
# Find FFmpeg libraries (used for video encoding / decoding)
FIND_PACKAGE(FFmpeg REQUIRED COMPONENTS avcodec avdevice avformat avutil swscale)
find_package(FFmpeg REQUIRED COMPONENTS avcodec avdevice avformat avutil swscale)

foreach(ff_comp avcodec avdevice avformat avfilter avutil postproc swscale swresample avresample)
if(TARGET FFmpeg::${ff_comp})
Expand Down Expand Up @@ -389,9 +392,9 @@ add_executable(openshot-example examples/Example.cpp)

# Define path to test input files
SET(TEST_MEDIA_PATH "${PROJECT_SOURCE_DIR}/src/examples/")
IF (WIN32)
if (WIN32)
STRING(REPLACE "/" "\\\\" TEST_MEDIA_PATH TEST_MEDIA_PATH)
ENDIF(WIN32)
endif()
target_compile_definitions(openshot-example PRIVATE
-DTEST_MEDIA_PATH="${TEST_MEDIA_PATH}" )

Expand All @@ -409,42 +412,40 @@ add_executable(openshot-player Qt/demo/main.cpp)
target_link_libraries(openshot-player openshot)

############### TEST BLACKMAGIC CAPTURE APP ################
IF (BLACKMAGIC_FOUND)
if (BLACKMAGIC_FOUND)
# Create test executable
add_executable(openshot-blackmagic
examples/ExampleBlackmagic.cpp)

# Link test executable to the new library
target_link_libraries(openshot-blackmagic openshot)
ENDIF (BLACKMAGIC_FOUND)
endif()

############### INCLUDE SWIG BINDINGS ################
add_subdirectory(bindings)

############### INSTALL HEADERS & LIBRARY ################
set(LIB_INSTALL_DIR lib${LIB_SUFFIX}) # determine correct lib folder

# Install primary library
INSTALL(TARGETS openshot
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
RUNTIME DESTINATION ${LIB_INSTALL_DIR}
COMPONENT library )
install(TARGETS openshot
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})

INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/libopenshot
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot
FILES_MATCHING PATTERN "*.h")

############### CPACK PACKAGING ##############
IF(MINGW)
SET(CPACK_GENERATOR "NSIS")
ENDIF(MINGW)
IF(UNIX AND NOT APPLE)
SET(CPACK_GENERATOR "DEB")
ENDIF(UNIX AND NOT APPLE)
#IF(UNIX AND APPLE)
# SET(CPACK_GENERATOR "DragNDrop")
#ENDIF(UNIX AND APPLE)
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Jonathan Thomas") #required

INCLUDE(CPack)
if(MINGW)
set(CPACK_GENERATOR "NSIS")
endif()
if(UNIX AND NOT APPLE)
set(CPACK_GENERATOR "DEB")
endif()
#if(UNIX AND APPLE)
# set(CPACK_GENERATOR "DragNDrop")
#endif()
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Jonathan Thomas") #required

include(CPack)

0 comments on commit 816118b

Please sign in to comment.