2023-08-03 19:22:24 -04:00
|
|
|
cmake_minimum_required(VERSION 3.22...3.25)
|
2023-03-26 03:55:25 +02:00
|
|
|
|
|
|
|
|
legacy_check()
|
|
|
|
|
|
2019-08-16 12:23:53 -04:00
|
|
|
if(POLICY CMP0078)
|
2022-02-14 18:46:40 +01:00
|
|
|
cmake_policy(SET CMP0078 NEW)
|
2019-08-16 12:23:53 -04:00
|
|
|
endif()
|
2022-02-14 18:46:40 +01:00
|
|
|
|
2019-10-15 21:08:30 -07:00
|
|
|
if(POLICY CMP0086)
|
2022-02-14 18:46:40 +01:00
|
|
|
cmake_policy(SET CMP0086 NEW)
|
2019-10-15 21:08:30 -07:00
|
|
|
endif()
|
2019-08-16 12:23:53 -04:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
if(POLICY CMP0094)
|
|
|
|
|
cmake_policy(SET CMP0094 NEW)
|
2017-12-25 14:09:11 -08:00
|
|
|
endif()
|
2023-03-26 03:55:25 +02:00
|
|
|
|
|
|
|
|
find_package(Python 3.8...<3.11 REQUIRED Interpreter Development)
|
|
|
|
|
find_package(SWIG 4 REQUIRED)
|
|
|
|
|
|
2022-02-14 18:46:40 +01:00
|
|
|
include(UseSWIG)
|
|
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
set_source_files_properties(obspython.i PROPERTIES USE_TARGET_INCLUDE_DIRECTORIES TRUE
|
|
|
|
|
SWIG_FLAGS "$<IF:$<BOOL:${OS_LINUX}>,-py3,-py3-stable-abi>")
|
2017-12-25 14:09:11 -08:00
|
|
|
|
2022-02-14 18:46:40 +01:00
|
|
|
swig_add_library(
|
|
|
|
|
obspython
|
|
|
|
|
LANGUAGE python
|
|
|
|
|
TYPE MODULE
|
2023-03-26 03:55:25 +02:00
|
|
|
SOURCES obspython.i)
|
2017-12-25 14:09:11 -08:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
add_library(OBS::python ALIAS obspython)
|
2017-12-25 14:09:11 -08:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
file(
|
|
|
|
|
GENERATE
|
|
|
|
|
OUTPUT $<$<PLATFORM_ID:Windows>:$<CONFIG>/>obspython.h
|
|
|
|
|
CONTENT "#pragma once\n\n#define PYTHON_LIB \"$<TARGET_LINKER_FILE_NAME:Python::Python>\"\n")
|
2022-02-14 18:46:40 +01:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
target_include_directories(obspython PRIVATE "$<$<PLATFORM_ID:Windows>:${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>>")
|
2022-02-14 18:46:40 +01:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
list(APPEND _SWIG_DEFINITIONS "SWIG_TYPE_TABLE=obspython" "Py_ENABLE_SHARED=1" "SWIG_PYTHON_INTERPRETER_NO_DEBUG")
|
2022-02-14 18:46:40 +01:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
target_compile_definitions(obspython PRIVATE SWIG_TYPE_TABLE=obspython Py_ENABLE_SHARED=1
|
|
|
|
|
SWIG_PYTHON_INTERPRETER_NO_DEBUG $<$<BOOL:${ENABLE_UI}>:ENABLE_UI>)
|
2022-02-14 18:46:40 +01:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
target_link_libraries(obspython PRIVATE OBS::scripting OBS::cstrcache OBS::libobs
|
|
|
|
|
$<$<BOOL:${ENABLE_UI}>:OBS::frontend-api>)
|
2022-05-28 18:22:53 +02:00
|
|
|
|
2022-02-14 18:46:40 +01:00
|
|
|
if(OS_WINDOWS)
|
|
|
|
|
target_link_libraries(obspython PRIVATE Python::Python)
|
2022-06-26 00:26:29 -07:00
|
|
|
target_compile_options(obspython PRIVATE /wd4100 /wd4197)
|
2022-02-14 18:46:40 +01:00
|
|
|
elseif(OS_MACOS)
|
2023-03-26 03:55:25 +02:00
|
|
|
get_target_property(_python_include_directory Python::Python INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
|
target_include_directories(obspython PRIVATE ${_python_include_directory})
|
2023-04-06 01:13:30 +02:00
|
|
|
target_compile_options(obspython PRIVATE -Wno-unused-parameter -Wno-macro-redefined -Wno-unreachable-code)
|
2023-03-26 03:55:25 +02:00
|
|
|
target_link_options(obspython PUBLIC LINKER:-undefined,dynamic_lookup)
|
2022-02-14 18:46:40 +01:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
set_property(TARGET obspython PROPERTY XCODE_ATTRIBUTE_STRIP_STYLE non-global)
|
|
|
|
|
elseif(OS_LINUX OR OS_FREEBSD)
|
2022-02-14 18:46:40 +01:00
|
|
|
target_link_libraries(obspython PRIVATE Python::Python)
|
2023-03-26 03:55:25 +02:00
|
|
|
endif()
|
2022-02-14 18:46:40 +01:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
if(MSVC OR XCODE)
|
|
|
|
|
add_custom_command(
|
|
|
|
|
TARGET obspython
|
|
|
|
|
POST_BUILD
|
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_BINARY_DIR}/obspython.py"
|
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/obspython.py"
|
|
|
|
|
VERBATIM)
|
2019-08-16 12:23:53 -04:00
|
|
|
endif()
|
2019-09-26 23:42:33 +02:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
set_property(
|
|
|
|
|
TARGET obspython
|
|
|
|
|
APPEND
|
|
|
|
|
PROPERTY SWIG_COMPILE_DEFINITIONS "SWIG_TYPE_TABLE=obspython" "Py_ENABLE_SHARED=1" "SWIG_PYTHON_INTERPRETER_NO_DEBUG"
|
|
|
|
|
"$<$<BOOL:${ENABLE_UI}>:ENABLE_UI>" "$<$<PLATFORM_ID:Windows>:MS_NO_COREDLL>")
|
2022-02-14 18:46:40 +01:00
|
|
|
|
2023-03-26 03:55:25 +02:00
|
|
|
set_target_properties_obs(obspython PROPERTIES FOLDER scripting PREFIX "_")
|