|
| 1 | +####################### CMakeLists.txt (libopenshot) ######################### |
| 2 | +# @brief CMake build file for libopenshot (used to generate Python SWIG bindings) |
| 3 | +# @author Jonathan Thomas < [email protected]> |
| 4 | +# |
| 5 | +# @section LICENSE |
| 6 | +# |
| 7 | +# Copyright (c) 2008-2014 OpenShot Studios, LLC |
| 8 | +# <http://www.openshotstudios.com/>. This file is part of |
| 9 | +# OpenShot Library (libopenshot), an open-source project dedicated to |
| 10 | +# delivering high quality video editing and animation solutions to the |
| 11 | +# world. For more information visit <http://www.openshot.org/>. |
| 12 | +# |
| 13 | +# OpenShot Library (libopenshot) is free software: you can redistribute it |
| 14 | +# and/or modify it under the terms of the GNU Lesser General Public License |
| 15 | +# as published by the Free Software Foundation, either version 3 of the |
| 16 | +# License, or (at your option) any later version. |
| 17 | +# |
| 18 | +# OpenShot Library (libopenshot) is distributed in the hope that it will be |
| 19 | +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | +# GNU Lesser General Public License for more details. |
| 22 | +# |
| 23 | +# You should have received a copy of the GNU Lesser General Public License |
| 24 | +# along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>. |
| 25 | +################################################################################ |
| 26 | + |
| 27 | + |
| 28 | +############### SWIG PYTHON BINDINGS ################ |
| 29 | +FIND_PACKAGE(SWIG 2.0 REQUIRED) |
| 30 | +INCLUDE(${SWIG_USE_FILE}) |
| 31 | + |
| 32 | +FIND_PACKAGE(PythonLibs 3) |
| 33 | +FIND_PACKAGE(PythonInterp 3) |
| 34 | +if (PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND) |
| 35 | + |
| 36 | + ### Include Python header files |
| 37 | + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) |
| 38 | + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) |
| 39 | + |
| 40 | + ### Enable C++ support in SWIG |
| 41 | + set_property(SOURCE openshot.i PROPERTY CPLUSPLUS ON) |
| 42 | + set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot) |
| 43 | + SET(CMAKE_SWIG_FLAGS "") |
| 44 | + |
| 45 | + ### Add the SWIG interface file (which defines all the SWIG methods) |
| 46 | + swig_add_library(pyopenshot LANGUAGE python SOURCES openshot.i) |
| 47 | + |
| 48 | + ### Set output name of target |
| 49 | + set_target_properties(${SWIG_MODULE_pyopenshot_REAL_NAME} PROPERTIES |
| 50 | + PREFIX "_" OUTPUT_NAME "openshot") |
| 51 | + |
| 52 | + ### Link the new python wrapper library with libopenshot |
| 53 | + target_link_libraries(${SWIG_MODULE_pyopenshot_REAL_NAME} ${PYTHON_LIBRARIES} openshot) |
| 54 | + |
| 55 | + ### FIND THE PYTHON INTERPRETER (AND THE SITE PACKAGES FOLDER) |
| 56 | + execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c |
| 57 | + "from distutils.sysconfig import get_python_lib; print( get_python_lib( plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}' ) )" |
| 58 | + OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH |
| 59 | + OUTPUT_STRIP_TRAILING_WHITESPACE ) |
| 60 | + |
| 61 | + GET_FILENAME_COMPONENT(_ABS_PYTHON_MODULE_PATH "${_ABS_PYTHON_MODULE_PATH}" ABSOLUTE) |
| 62 | + FILE(RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) |
| 63 | + SET(PYTHON_MODULE_PATH ${_REL_PYTHON_MODULE_PATH}) |
| 64 | + |
| 65 | + ############### INSTALL HEADERS & LIBRARY ################ |
| 66 | + ### Install Python bindings |
| 67 | + INSTALL(TARGETS ${SWIG_MODULE_pyopenshot_REAL_NAME} |
| 68 | + LIBRARY DESTINATION ${PYTHON_MODULE_PATH} ) |
| 69 | + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/openshot.py |
| 70 | + DESTINATION ${PYTHON_MODULE_PATH} ) |
| 71 | + |
| 72 | +endif () |
0 commit comments