Skip to content

Commit f3c35da

Browse files
committed
Don't break older cmake with new policy
1 parent 268e72a commit f3c35da

File tree

4 files changed

+152
-6
lines changed

4 files changed

+152
-6
lines changed

src/bindings/python/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@
2929
FIND_PACKAGE(SWIG 2.0 REQUIRED)
3030
INCLUDE(${SWIG_USE_FILE})
3131

32-
### Enable some legacy SWIG behaviors, in newer CMAKE
33-
cmake_policy(SET CMP0078 OLD)
34-
cmake_policy(SET CMP0086 OLD)
32+
### Enable some legacy SWIG behaviors, in newer CMAKEs
33+
if (CMAKE_VERSION VERSION_GREATER 3.13)
34+
cmake_policy(SET CMP0078 OLD)
35+
endif()
36+
if (CMAKE_VERSION VERSION_GREATER 3.14)
37+
cmake_policy(SET CMP0086 OLD)
38+
endif()
3539

3640
FIND_PACKAGE(PythonLibs 3)
3741
FIND_PACKAGE(PythonInterp 3)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 ()

src/bindings/ruby/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@
2929
FIND_PACKAGE(SWIG 2.0 REQUIRED)
3030
INCLUDE(${SWIG_USE_FILE})
3131

32-
### Enable some legacy SWIG behaviors, in newer CMAKE
33-
cmake_policy(SET CMP0078 OLD)
34-
cmake_policy(SET CMP0086 OLD)
32+
### Enable some legacy SWIG behaviors, in newer CMAKEs
33+
if (CMAKE_VERSION VERSION_GREATER 3.13)
34+
cmake_policy(SET CMP0078 OLD)
35+
endif()
36+
if (CMAKE_VERSION VERSION_GREATER 3.14)
37+
cmake_policy(SET CMP0086 OLD)
38+
endif()
3539

3640
FIND_PACKAGE(Ruby)
3741
IF (RUBY_FOUND)

src/bindings/ruby/CMakeLists.txt~

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
####################### CMakeLists.txt (libopenshot) #########################
2+
# @brief CMake build file for libopenshot (used to generate Ruby 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+
############### RUBY BINDINGS ################
29+
FIND_PACKAGE(SWIG 2.0 REQUIRED)
30+
INCLUDE(${SWIG_USE_FILE})
31+
32+
FIND_PACKAGE(Ruby)
33+
IF (RUBY_FOUND)
34+
35+
### Include the Ruby header files
36+
INCLUDE_DIRECTORIES(${RUBY_INCLUDE_DIRS})
37+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
38+
39+
### Enable C++ in SWIG
40+
set_property(SOURCE openshot.i PROPERTY CPLUSPLUS ON)
41+
set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot)
42+
43+
SET(CMAKE_SWIG_FLAGS "")
44+
45+
### Add the SWIG interface file (which defines all the SWIG methods)
46+
swig_add_library(rbopenshot LANGUAGE ruby SOURCES openshot.i)
47+
48+
### Set name of target (with no prefix, since Ruby does not like that)
49+
SET_TARGET_PROPERTIES(${SWIG_MODULE_rbopenshot_REAL_NAME}
50+
PROPERTIES PREFIX "" OUTPUT_NAME "openshot")
51+
52+
### Link the new Ruby wrapper library with libopenshot
53+
target_link_libraries(${SWIG_MODULE_rbopenshot_REAL_NAME} ${RUBY_LIBRARY} openshot)
54+
55+
### FIND THE RUBY INTERPRETER (AND THE LOAD_PATH FOLDER)
56+
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['vendorarchdir']" OUTPUT_VARIABLE RUBY_VENDOR_ARCH_DIR)
57+
MESSAGE(STATUS "Ruby executable: ${RUBY_EXECUTABLE}")
58+
MESSAGE(STATUS "Ruby vendor arch dir: ${RUBY_VENDOR_ARCH_DIR}")
59+
MESSAGE(STATUS "Ruby include path: ${RUBY_INCLUDE_PATH}")
60+
61+
62+
############### INSTALL HEADERS & LIBRARY ################
63+
# Install Ruby bindings
64+
install(TARGETS ${SWIG_MODULE_rbopenshot_REAL_NAME} LIBRARY DESTINATION ${RUBY_VENDOR_ARCH_DIR} )
65+
66+
ENDIF (RUBY_FOUND)

0 commit comments

Comments
 (0)