Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindings: Remove relative header paths #469

Merged
merged 3 commits into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ IF (WIN32)
SET_PROPERTY(GLOBAL PROPERTY WIN32 "WIN32")
ENDIF(WIN32)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include)

############## Code Coverage #########################
if (DISABLE_TESTS AND ENABLE_COVERAGE)
message(WARNING "ENABLE_COVERAGE requires tests, overriding DISABLE_TESTS")
Expand Down
136 changes: 73 additions & 63 deletions src/bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,78 +37,88 @@ if (POLICY CMP0086)
cmake_policy(SET CMP0086 OLD)
endif()

FIND_PACKAGE(PythonInterp 3)
FIND_PACKAGE(PythonLibs 3)
if (PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)

### Include Python header files
include_directories(${PYTHON_INCLUDE_PATH})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

### Enable C++ support in SWIG
set_property(SOURCE openshot.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot)

### 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 \
-Wno-unused-parameter -Wno-catch-value -Wno-sign-compare -Wno-ignored-qualifiers")
separate_arguments(sw_flags UNIX_COMMAND ${SWIG_CXX_FLAGS})
set_property(SOURCE openshot.i PROPERTY GENERATED_COMPILE_OPTIONS ${sw_flags})

### Take include dirs from target, automatically if possible
if (CMAKE_VERSION VERSION_GREATER 3.13)
set_property(SOURCE openshot.i PROPERTY USE_TARGET_INCLUDE_DIRECTORIES True)
else ()
set_property(SOURCE openshot.i PROPERTY INCLUDE_DIRECTORIES $<TARGET_PROPERTY:openshot,INCLUDE_DIRECTORIES>)
endif ()

### Add the SWIG interface file (which defines all the SWIG methods)
if (CMAKE_VERSION VERSION_LESS 3.8.0)
swig_add_module(pyopenshot python openshot.i)
else()
swig_add_library(pyopenshot LANGUAGE python SOURCES openshot.i)
endif()
find_package(PythonInterp 3)
find_package(PythonLibs 3)

### Set output name of target
set_target_properties(${SWIG_MODULE_pyopenshot_REAL_NAME} PROPERTIES
PREFIX "_" OUTPUT_NAME "openshot")
if (NOT PYTHONLIBS_FOUND OR NOT PYTHONINTERP_FOUND)
return()
endif()

### Link the new python wrapper library with libopenshot
target_link_libraries(${SWIG_MODULE_pyopenshot_REAL_NAME} PUBLIC
${PYTHON_LIBRARIES} openshot)
### Include Python header files
include_directories(${PYTHON_INCLUDE_PATH})

######### INSTALL PATH ########
if (NOT DEFINED PYTHON_MODULE_PATH AND DEFINED $ENV{PYTHON_MODULE_PATH})
set(PYTHON_MODULE_PATH $ENV{PYTHON_MODULE_PATH})
endif()
if (CMAKE_VERSION VERSION_LESS 3.12)
### Include project headers
include_directories(
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include")
endif()

if (NOT DEFINED PYTHON_MODULE_PATH)
if (WIN32 OR APPLE)
set (PYTHON_MODULE_PATH "python")
endif()
### Enable C++ support in SWIG
set_property(SOURCE openshot.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot)

### 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 \
-Wno-unused-parameter -Wno-catch-value -Wno-sign-compare -Wno-ignored-qualifiers")
separate_arguments(sw_flags UNIX_COMMAND ${SWIG_CXX_FLAGS})
set_property(SOURCE openshot.i PROPERTY GENERATED_COMPILE_OPTIONS ${sw_flags})

### Take include dirs from target, automatically if possible
if (CMAKE_VERSION VERSION_GREATER 3.13)
set_property(SOURCE openshot.i PROPERTY USE_TARGET_INCLUDE_DIRECTORIES True)
elseif (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(SOURCE openshot.i PROPERTY
INCLUDE_DIRECTORIES $<TARGET_PROPERTY:openshot,INCLUDE_DIRECTORIES>)
endif ()

### Add the SWIG interface file (which defines all the SWIG methods)
if (CMAKE_VERSION VERSION_LESS 3.8.0)
swig_add_module(pyopenshot python openshot.i)
else()
swig_add_library(pyopenshot LANGUAGE python SOURCES openshot.i)
endif()

### Set output name of target
set_target_properties(${SWIG_MODULE_pyopenshot_REAL_NAME} PROPERTIES
PREFIX "_" OUTPUT_NAME "openshot")

if (UNIX AND NOT APPLE)
### Check if the following Debian-friendly python module path exists
set(PYTHON_MODULE_PATH "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages")
if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}")
### Link the new python wrapper library with libopenshot
target_link_libraries(${SWIG_MODULE_pyopenshot_REAL_NAME} PUBLIC
${PYTHON_LIBRARIES} openshot)

### Calculate the python module path (using distutils)
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "\
######### INSTALL PATH ########
if (NOT DEFINED PYTHON_MODULE_PATH AND DEFINED $ENV{PYTHON_MODULE_PATH})
set(PYTHON_MODULE_PATH $ENV{PYTHON_MODULE_PATH})
endif()

if (NOT DEFINED PYTHON_MODULE_PATH)
if (WIN32 OR APPLE)
set (PYTHON_MODULE_PATH "python")
endif()

if (UNIX AND NOT APPLE)
### Check if the following Debian-friendly python module path exists
set(PYTHON_MODULE_PATH
"lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages")

if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}")
### Calculate the python module path (using distutils)
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "\
from distutils.sysconfig import get_python_lib; \
print( get_python_lib( plat_specific=True, prefix='' ) )"
OUTPUT_VARIABLE PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE )
endif()
OUTPUT_VARIABLE PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE )
endif()
endif()
endif()

message(STATUS "PYTHON_MODULE_PATH: ${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}")

############### INSTALL HEADERS & LIBRARY ################
### Install Python bindings
install(TARGETS ${SWIG_MODULE_pyopenshot_REAL_NAME}
DESTINATION ${PYTHON_MODULE_PATH} )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openshot.py
DESTINATION ${PYTHON_MODULE_PATH} )
message(STATUS "PYTHON_MODULE_PATH: ${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}")

endif ()
############### INSTALL HEADERS & LIBRARY ################
### Install Python bindings
install(TARGETS ${SWIG_MODULE_pyopenshot_REAL_NAME}
DESTINATION ${PYTHON_MODULE_PATH} )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openshot.py
DESTINATION ${PYTHON_MODULE_PATH} )
192 changes: 96 additions & 96 deletions src/bindings/python/openshot.i
Original file line number Diff line number Diff line change
Expand Up @@ -59,57 +59,57 @@

%{
#include "OpenShotVersion.h"
#include "../../../include/ReaderBase.h"
#include "../../../include/WriterBase.h"
#include "../../../include/CacheBase.h"
#include "../../../include/CacheDisk.h"
#include "../../../include/CacheMemory.h"
#include "../../../include/ChannelLayouts.h"
#include "../../../include/ChunkReader.h"
#include "../../../include/ChunkWriter.h"
#include "../../../include/ClipBase.h"
#include "../../../include/Clip.h"
#include "../../../include/Coordinate.h"
#include "../../../include/Color.h"
#include "../../../include/DummyReader.h"
#include "../../../include/EffectBase.h"
#include "../../../include/Effects.h"
#include "../../../include/EffectInfo.h"
#include "../../../include/Enums.h"
#include "../../../include/Exceptions.h"
#include "../../../include/FFmpegReader.h"
#include "../../../include/FFmpegWriter.h"
#include "../../../include/Fraction.h"
#include "../../../include/Frame.h"
#include "../../../include/FrameMapper.h"
#include "../../../include/PlayerBase.h"
#include "../../../include/Point.h"
#include "../../../include/Profiles.h"
#include "../../../include/QtHtmlReader.h"
#include "../../../include/QtImageReader.h"
#include "../../../include/QtPlayer.h"
#include "../../../include/QtTextReader.h"
#include "../../../include/KeyFrame.h"
#include "../../../include/RendererBase.h"
#include "../../../include/Settings.h"
#include "../../../include/Timeline.h"
#include "../../../include/ZmqLogger.h"
#include "../../../include/AudioDeviceInfo.h"
#include "ReaderBase.h"
#include "WriterBase.h"
#include "CacheBase.h"
#include "CacheDisk.h"
#include "CacheMemory.h"
#include "ChannelLayouts.h"
#include "ChunkReader.h"
#include "ChunkWriter.h"
#include "ClipBase.h"
#include "Clip.h"
#include "Coordinate.h"
#include "Color.h"
#include "DummyReader.h"
#include "EffectBase.h"
#include "Effects.h"
#include "EffectInfo.h"
#include "Enums.h"
#include "Exceptions.h"
#include "FFmpegReader.h"
#include "FFmpegWriter.h"
#include "Fraction.h"
#include "Frame.h"
#include "FrameMapper.h"
#include "PlayerBase.h"
#include "Point.h"
#include "Profiles.h"
#include "QtHtmlReader.h"
#include "QtImageReader.h"
#include "QtPlayer.h"
#include "QtTextReader.h"
#include "KeyFrame.h"
#include "RendererBase.h"
#include "Settings.h"
#include "Timeline.h"
#include "ZmqLogger.h"
#include "AudioDeviceInfo.h"

%}

#ifdef USE_BLACKMAGIC
%{
#include "../../../include/DecklinkReader.h"
#include "../../../include/DecklinkWriter.h"
#include "DecklinkReader.h"
#include "DecklinkWriter.h"
%}
#endif

#ifdef USE_IMAGEMAGICK
%{
#include "../../../include/ImageReader.h"
#include "../../../include/ImageWriter.h"
#include "../../../include/TextReader.h"
#include "ImageReader.h"
#include "ImageWriter.h"
#include "TextReader.h"
%}
#endif

Expand Down Expand Up @@ -166,68 +166,68 @@
}

%include "OpenShotVersion.h"
%include "../../../include/ReaderBase.h"
%include "../../../include/WriterBase.h"
%include "../../../include/CacheBase.h"
%include "../../../include/CacheDisk.h"
%include "../../../include/CacheMemory.h"
%include "../../../include/ChannelLayouts.h"
%include "../../../include/ChunkReader.h"
%include "../../../include/ChunkWriter.h"
%include "../../../include/ClipBase.h"
%include "../../../include/Clip.h"
%include "../../../include/Coordinate.h"
%include "../../../include/Color.h"
%include "ReaderBase.h"
%include "WriterBase.h"
%include "CacheBase.h"
%include "CacheDisk.h"
%include "CacheMemory.h"
%include "ChannelLayouts.h"
%include "ChunkReader.h"
%include "ChunkWriter.h"
%include "ClipBase.h"
%include "Clip.h"
%include "Coordinate.h"
%include "Color.h"
#ifdef USE_BLACKMAGIC
%include "../../../include/DecklinkReader.h"
%include "../../../include/DecklinkWriter.h"
%include "DecklinkReader.h"
%include "DecklinkWriter.h"
#endif
%include "../../../include/DummyReader.h"
%include "../../../include/EffectBase.h"
%include "../../../include/Effects.h"
%include "../../../include/EffectInfo.h"
%include "../../../include/Enums.h"
%include "../../../include/Exceptions.h"
%include "../../../include/FFmpegReader.h"
%include "../../../include/FFmpegWriter.h"
%include "../../../include/Fraction.h"
%include "../../../include/Frame.h"
%include "../../../include/FrameMapper.h"
%include "../../../include/PlayerBase.h"
%include "../../../include/Point.h"
%include "../../../include/Profiles.h"
%include "../../../include/QtHtmlReader.h"
%include "../../../include/QtImageReader.h"
%include "../../../include/QtPlayer.h"
%include "../../../include/QtTextReader.h"
%include "../../../include/KeyFrame.h"
%include "../../../include/RendererBase.h"
%include "../../../include/Settings.h"
%include "../../../include/Timeline.h"
%include "../../../include/ZmqLogger.h"
%include "../../../include/AudioDeviceInfo.h"
%include "DummyReader.h"
%include "EffectBase.h"
%include "Effects.h"
%include "EffectInfo.h"
%include "Enums.h"
%include "Exceptions.h"
%include "FFmpegReader.h"
%include "FFmpegWriter.h"
%include "Fraction.h"
%include "Frame.h"
%include "FrameMapper.h"
%include "PlayerBase.h"
%include "Point.h"
%include "Profiles.h"
%include "QtHtmlReader.h"
%include "QtImageReader.h"
%include "QtPlayer.h"
%include "QtTextReader.h"
%include "KeyFrame.h"
%include "RendererBase.h"
%include "Settings.h"
%include "Timeline.h"
%include "ZmqLogger.h"
%include "AudioDeviceInfo.h"

#ifdef USE_IMAGEMAGICK
%include "../../../include/ImageReader.h"
%include "../../../include/ImageWriter.h"
%include "../../../include/TextReader.h"
%include "ImageReader.h"
%include "ImageWriter.h"
%include "TextReader.h"
#endif

/* Effects */
%include "../../../include/effects/Bars.h"
%include "../../../include/effects/Blur.h"
%include "../../../include/effects/Brightness.h"
%include "../../../include/effects/ChromaKey.h"
%include "../../../include/effects/ColorShift.h"
%include "../../../include/effects/Crop.h"
%include "../../../include/effects/Deinterlace.h"
%include "../../../include/effects/Hue.h"
%include "../../../include/effects/Mask.h"
%include "../../../include/effects/Negate.h"
%include "../../../include/effects/Pixelate.h"
%include "../../../include/effects/Saturation.h"
%include "../../../include/effects/Shift.h"
%include "../../../include/effects/Wave.h"
%include "effects/Bars.h"
%include "effects/Blur.h"
%include "effects/Brightness.h"
%include "effects/ChromaKey.h"
%include "effects/ColorShift.h"
%include "effects/Crop.h"
%include "effects/Deinterlace.h"
%include "effects/Hue.h"
%include "effects/Mask.h"
%include "effects/Negate.h"
%include "effects/Pixelate.h"
%include "effects/Saturation.h"
%include "effects/Shift.h"
%include "effects/Wave.h"


/* Wrap std templates (list, vector, etc...) */
Expand Down