This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cmake modules from github.com/obsproject/obs-studio/blob/master/c…
…make/external
- Loading branch information
1 parent
7fbbfe1
commit af72a88
Showing
2 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# This module can be copied and used by external plugins for OBS | ||
# | ||
# Once done these will be defined: | ||
# | ||
# LIBOBS_FOUND | ||
# LIBOBS_INCLUDE_DIRS | ||
# LIBOBS_LIBRARIES | ||
|
||
find_package(PkgConfig QUIET) | ||
if (PKG_CONFIG_FOUND) | ||
pkg_check_modules(_OBS QUIET obs libobs) | ||
endif() | ||
|
||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(_lib_suffix 64) | ||
else() | ||
set(_lib_suffix 32) | ||
endif() | ||
|
||
if(DEFINED CMAKE_BUILD_TYPE) | ||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(_build_type_base "debug") | ||
else() | ||
set(_build_type_base "release") | ||
endif() | ||
endif() | ||
|
||
find_path(LIBOBS_INCLUDE_DIR | ||
NAMES obs.h | ||
HINTS | ||
ENV obsPath${_lib_suffix} | ||
ENV obsPath | ||
${obsPath} | ||
PATHS | ||
/usr/include /usr/local/include /opt/local/include /sw/include | ||
PATH_SUFFIXES | ||
libobs | ||
) | ||
|
||
function(find_obs_lib base_name repo_build_path lib_name) | ||
string(TOUPPER "${base_name}" base_name_u) | ||
|
||
if(DEFINED _build_type_base) | ||
set(_build_type_${repo_build_path} "${_build_type_base}/${repo_build_path}") | ||
set(_build_type_${repo_build_path}${_lib_suffix} "${_build_type_base}${_lib_suffix}/${repo_build_path}") | ||
endif() | ||
|
||
find_library(${base_name_u}_LIB | ||
NAMES ${_${base_name_u}_LIBRARIES} ${lib_name} lib${lib_name} | ||
HINTS | ||
ENV obsPath${_lib_suffix} | ||
ENV obsPath | ||
${obsPath} | ||
${_${base_name_u}_LIBRARY_DIRS} | ||
PATHS | ||
/usr/lib /usr/local/lib /opt/local/lib /sw/lib | ||
PATH_SUFFIXES | ||
lib${_lib_suffix} lib | ||
libs${_lib_suffix} libs | ||
bin${_lib_suffix} bin | ||
../lib${_lib_suffix} ../lib | ||
../libs${_lib_suffix} ../libs | ||
../bin${_lib_suffix} ../bin | ||
# base repo non-msvc-specific search paths | ||
${_build_type_${repo_build_path}} | ||
${_build_type_${repo_build_path}${_lib_suffix}} | ||
build/${repo_build_path} | ||
build${_lib_suffix}/${repo_build_path} | ||
# base repo msvc-specific search paths on windows | ||
build${_lib_suffix}/${repo_build_path}/Debug | ||
build${_lib_suffix}/${repo_build_path}/RelWithDebInfo | ||
build/${repo_build_path}/Debug | ||
build/${repo_build_path}/RelWithDebInfo | ||
) | ||
endfunction() | ||
|
||
find_obs_lib(LIBOBS libobs obs) | ||
|
||
if(MSVC) | ||
find_obs_lib(W32_PTHREADS deps/w32-pthreads w32-pthreads) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Libobs DEFAULT_MSG LIBOBS_LIB LIBOBS_INCLUDE_DIR) | ||
mark_as_advanced(LIBOBS_INCLUDE_DIR LIBOBS_LIB) | ||
|
||
if(LIBOBS_FOUND) | ||
if(MSVC) | ||
if (NOT DEFINED W32_PTHREADS_LIB) | ||
message(FATAL_ERROR "Could not find the w32-pthreads library" ) | ||
endif() | ||
|
||
set(W32_PTHREADS_INCLUDE_DIR ${LIBOBS_INCLUDE_DIR}/../deps/w32-pthreads) | ||
endif() | ||
|
||
set(LIBOBS_INCLUDE_DIRS ${LIBOBS_INCLUDE_DIR} ${W32_PTHREADS_INCLUDE_DIR}) | ||
set(LIBOBS_LIBRARIES ${LIBOBS_LIB} ${W32_PTHREADS_LIB}) | ||
include(${LIBOBS_INCLUDE_DIR}/../cmake/external/ObsPluginHelpers.cmake) | ||
|
||
# allows external plugins to easily use/share common dependencies that are often included with libobs (such as FFmpeg) | ||
if(NOT DEFINED INCLUDED_LIBOBS_CMAKE_MODULES) | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LIBOBS_INCLUDE_DIR}/../cmake/Modules/") | ||
set(INCLUDED_LIBOBS_CMAKE_MODULES true) | ||
endif() | ||
else() | ||
message(FATAL_ERROR "Could not find the libobs library" ) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# Functions for generating external plugins | ||
|
||
set(EXTERNAL_PLUGIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/rundir") | ||
|
||
# Fix XCode includes to ignore warnings on system includes | ||
function(target_include_directories_system _target) | ||
if(XCODE) | ||
foreach(_arg ${ARGN}) | ||
if("${_arg}" STREQUAL "PRIVATE" OR "${_arg}" STREQUAL "PUBLIC" OR "${_arg}" STREQUAL "INTERFACE") | ||
set(_scope ${_arg}) | ||
else() | ||
target_compile_options(${_target} ${_scope} -isystem${_arg}) | ||
endif() | ||
endforeach() | ||
else() | ||
target_include_directories(${_target} SYSTEM ${_scope} ${ARGN}) | ||
endif() | ||
endfunction() | ||
|
||
function(install_external_plugin_data_internal target source_dir target_dir) | ||
install(DIRECTORY ${source_dir}/ | ||
DESTINATION "${target}/${target_dir}" | ||
USE_SOURCE_PERMISSIONS) | ||
add_custom_command(TARGET ${target} POST_BUILD | ||
COMMAND "${CMAKE_COMMAND}" -E copy_directory | ||
"${CMAKE_CURRENT_SOURCE_DIR}/${source_dir}" "${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/${target_dir}" | ||
VERBATIM) | ||
endfunction() | ||
|
||
# Installs data | ||
# 'target' is the destination target project being installed to | ||
# 'data_loc' specifies the directory of the data | ||
function(install_external_plugin_data target data_loc) | ||
install_external_plugin_data_internal(${target} ${data_loc} "data") | ||
endfunction() | ||
|
||
# Installs data in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac. | ||
# 'target' is the destination target project being installed to | ||
# 'data_loc' specifies the directory of the data being installed | ||
function(install_external_plugin_arch_data target data_loc) | ||
if(APPLE) | ||
set(_bit_suffix "") | ||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(_bit_suffix "/64bit") | ||
else() | ||
set(_bit_suffix "/32bit") | ||
endif() | ||
|
||
install_external_plugin_data_internal(${target} ${data_loc} "data${_bit_suffix}") | ||
endfunction() | ||
|
||
# Installs data in the target's bin directory | ||
# 'target' is the destination target project being installed to | ||
# 'data_loc' specifies the directory of the data being installed | ||
function(install_external_plugin_data_to_bin target data_loc) | ||
if(APPLE) | ||
set(_bit_suffix "") | ||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(_bit_suffix "/64bit") | ||
else() | ||
set(_bit_suffix "/32bit") | ||
endif() | ||
|
||
install_external_plugin_data_internal(${target} ${data_loc} "bin${_bit_suffix}") | ||
endfunction() | ||
|
||
# Installs an additional binary to a target | ||
# 'target' is the destination target project being installed to | ||
# 'additional_target' specifies the additional binary | ||
function(install_external_plugin_additional target additional_target) | ||
if(APPLE) | ||
set(_bit_suffix "") | ||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(_bit_suffix "64bit/") | ||
else() | ||
set(_bit_suffix "32bit/") | ||
endif() | ||
|
||
set_target_properties(${additional_target} PROPERTIES | ||
PREFIX "") | ||
|
||
install(TARGETS ${additional_target} | ||
LIBRARY DESTINATION "bin" | ||
RUNTIME DESTINATION "bin") | ||
add_custom_command(TARGET ${additional_target} POST_BUILD | ||
COMMAND "${CMAKE_COMMAND}" -E copy | ||
"$<TARGET_FILE:${additional_target}>" | ||
"${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/bin/${_bit_suffix}$<TARGET_FILE_NAME:${additional_target}>" | ||
VERBATIM) | ||
endfunction() | ||
|
||
# Installs the binary of the target | ||
# 'target' is the target project being installed | ||
function(install_external_plugin target) | ||
install_external_plugin_additional(${target} ${target}) | ||
endfunction() | ||
|
||
# Installs the binary and data of the target | ||
# 'target' is the destination target project being installed to | ||
function(install_external_plugin_with_data target data_loc) | ||
install_external_plugin(${target}) | ||
install_external_plugin_data(${target} ${data_loc}) | ||
endfunction() | ||
|
||
# Installs an additional binary to the data of a target | ||
# 'target' is the destination target project being installed to | ||
# 'additional_target' specifies the additional binary | ||
function(install_external_plugin_bin_to_data target additional_target) | ||
install(TARGETS ${additional_target} | ||
LIBRARY DESTINATION "data" | ||
RUNTIME DESTINATION "data") | ||
add_custom_command(TARGET ${additional_target} POST_BUILD | ||
COMMAND "${CMAKE_COMMAND}" -E copy | ||
"$<TARGET_FILE:${additional_target}>" | ||
"${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/data/$<TARGET_FILE_NAME:${additional_target}>" | ||
VERBATIM) | ||
endfunction() | ||
|
||
# Installs an additional binary in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac. | ||
# 'target' is the destination target project being installed to | ||
# 'additional_target' specifies the additional binary | ||
function(install_external_plugin_bin_to_arch_data target additional_target) | ||
if(APPLE) | ||
set(_bit_suffix "") | ||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(_bit_suffix "/64bit") | ||
else() | ||
set(_bit_suffix "/32bit") | ||
endif() | ||
|
||
install(TARGETS ${additional_target} | ||
LIBRARY DESTINATION "data${_bit_suffix}" | ||
RUNTIME DESTINATION "data${_bit_suffix}") | ||
add_custom_command(TARGET ${additional_target} POST_BUILD | ||
COMMAND "${CMAKE_COMMAND}" -E copy | ||
"$<TARGET_FILE:${additional_target}>" | ||
"${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/data${_bit_suffix}/$<TARGET_FILE_NAME:${additional_target}>" | ||
VERBATIM) | ||
endfunction() | ||
|
||
# Installs an additional file in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac. | ||
# 'target' is the destination target project being installed to | ||
# 'additional_target' specifies the additional binary | ||
function(install_external_plugin_data_file_to_arch_data target additional_target file_target) | ||
if(APPLE) | ||
set(_bit_suffix "") | ||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(_bit_suffix "/64bit") | ||
else() | ||
set(_bit_suffix "/32bit") | ||
endif() | ||
|
||
get_filename_component(file_target_name ${file_target} NAME) | ||
|
||
install(TARGETS ${additional_target} | ||
LIBRARY DESTINATION "data${_bit_suffix}" | ||
RUNTIME DESTINATION "data${_bit_suffix}") | ||
add_custom_command(TARGET ${additional_target} POST_BUILD | ||
COMMAND "${CMAKE_COMMAND}" -E copy | ||
"${file_target}" | ||
"${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/data${_bit_suffix}/${file_target_name}" | ||
VERBATIM) | ||
endfunction() |