obs-scripting: Fix swig runtime header generation for macOS

Due to swig using a hardcoded swig library path in self-compiled
variants, we need to pass our custom swig library path with every
invocation of swig on macOS.

CMake's `add_custom_command` function does _not_ inherit the environment
variables used during configuration, hence why it needs to be passed
explicitly on invocation.

Usage of CMake's "-E env" command module should allow for cross-platform
compatible invocation.
master
PatTheMav 2022-07-07 13:28:12 +02:00 committed by Ryan Foster
parent 5898df70fa
commit 64efcd155d
1 changed files with 4 additions and 2 deletions

View File

@ -95,7 +95,8 @@ if(TARGET Luajit::Luajit)
OUTPUT swig/swigluarun.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
PRE_BUILD
COMMAND ${SWIG_EXECUTABLE} -lua -external-runtime swig/swigluarun.h
COMMAND ${CMAKE_COMMAND} -E env "SWIG_LIB=${SWIG_DIR}" ${SWIG_EXECUTABLE}
-lua -external-runtime swig/swigluarun.h
COMMENT "obs-scripting - generating Luajit SWIG interface headers")
set_source_files_properties(swig/swigluarun.h PROPERTIES GENERATED ON)
@ -124,7 +125,8 @@ if(TARGET Python::Python)
OUTPUT swig/swigpyrun.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
PRE_BUILD
COMMAND ${SWIG_EXECUTABLE} -python -external-runtime swig/swigpyrun.h
COMMAND ${CMAKE_COMMAND} -E env "SWIG_LIB=${SWIG_DIR}" ${SWIG_EXECUTABLE}
-python -external-runtime swig/swigpyrun.h
COMMENT "obs-scripting - generating Python 3 SWIG interface headers")
set_source_files_properties(swig/swigpyrun.h PROPERTIES GENERATED ON)