mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-05 23:26:13 -05:00
cmake: Update CMake formatting with manual format choices
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
# OBS CMake 32-bit slice module
|
||||
|
||||
# cmake-format: off
|
||||
# cmake-lint: disable=C0103
|
||||
# cmake-lint: disable=E1121
|
||||
# cmake-format: on
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
include(compilerconfig)
|
||||
@@ -13,9 +18,11 @@ macro(legacy_check)
|
||||
endmacro()
|
||||
|
||||
# cmake-format: off
|
||||
# target_disable_feature: Stub macro for 32-bit projects
|
||||
macro(target_disable_feature)
|
||||
endmacro()
|
||||
|
||||
# target_disable: Stub macro for 32-bit projects
|
||||
macro(target_disable)
|
||||
endmacro()
|
||||
# cmake-format: on
|
||||
|
||||
@@ -2,34 +2,10 @@
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
# Enable automatic PUSH and POP of policies to parent scope
|
||||
if(POLICY CMP0011)
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
endif()
|
||||
|
||||
# Enable distinction between Clang and AppleClang
|
||||
if(POLICY CMP0025)
|
||||
cmake_policy(SET CMP0025 NEW)
|
||||
endif()
|
||||
|
||||
# Enable strict checking of "break()" usage
|
||||
if(POLICY CMP0055)
|
||||
cmake_policy(SET CMP0055 NEW)
|
||||
endif()
|
||||
|
||||
# Honor visibility presets for all target types (executable, shared, module, static)
|
||||
if(POLICY CMP0063)
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
endif()
|
||||
|
||||
# Disable export function calls to populate package registry by default
|
||||
if(POLICY CMP0090)
|
||||
cmake_policy(SET CMP0090 NEW)
|
||||
endif()
|
||||
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo Release MinSizeRel "")
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL MinSizeRel Release RelWithDebInfo "")
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release RelWithDebInfo MinSizeRel "")
|
||||
# Map fallback configurations for optimized build configurations
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo Release MinSizeRel None "")
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL MinSizeRel Release RelWithDebInfo None "")
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release RelWithDebInfo MinSizeRel None "")
|
||||
|
||||
# Prohibit in-source builds
|
||||
if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
@@ -57,19 +33,20 @@ set(_obs_beta 0)
|
||||
# Add common module directories to default search path
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/finders")
|
||||
|
||||
include(policies NO_POLICY_SCOPE)
|
||||
include(versionconfig)
|
||||
include(buildnumber)
|
||||
include(osconfig)
|
||||
|
||||
# Allow selection of common build types via UI
|
||||
if(NOT CMAKE_GENERATOR MATCHES "(Xcode|Visual Studio .+)")
|
||||
set(CMAKE_BUILD_TYPE
|
||||
"RelWithDebInfo"
|
||||
CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE
|
||||
"RelWithDebInfo"
|
||||
CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Disable exports automatically going into the CMake package registry
|
||||
set(CMAKE_EXPORT_PACKAGE_REGISTRY FALSE)
|
||||
# Enable default inclusion of targets' source and binary directory
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# OBS common build dependencies module
|
||||
|
||||
# cmake-format: off
|
||||
# cmake-lint: disable=C0103
|
||||
# cmake-lint: disable=E1121
|
||||
# cmake-lint: disable=E1126
|
||||
# cmake-lint: disable=R0912
|
||||
# cmake-lint: disable=R0915
|
||||
@@ -11,9 +11,9 @@ include_guard(GLOBAL)
|
||||
|
||||
# _check_deps_version: Checks for obs-deps VERSION file in prefix paths
|
||||
function(_check_deps_version version)
|
||||
# cmake-format: off
|
||||
set(found FALSE PARENT_SCOPE)
|
||||
# cmake-format: on
|
||||
set(found
|
||||
FALSE
|
||||
PARENT_SCOPE)
|
||||
|
||||
foreach(path IN LISTS CMAKE_PREFIX_PATH)
|
||||
if(EXISTS "${path}/share/obs-deps/VERSION")
|
||||
@@ -30,25 +30,25 @@ function(_check_deps_version version)
|
||||
string(REPLACE "-" "." version "${version}")
|
||||
|
||||
if(_check_version VERSION_EQUAL version)
|
||||
# cmake-format: off
|
||||
set(found TRUE PARENT_SCOPE)
|
||||
# cmake-format: on
|
||||
set(found
|
||||
TRUE
|
||||
PARENT_SCOPE)
|
||||
break()
|
||||
elseif(_check_version VERSION_LESS version)
|
||||
message(AUTHOR_WARNING "Older ${label} version detected in ${path}: \n"
|
||||
"Found ${_check_version}, require ${version}")
|
||||
list(REMOVE_ITEM CMAKE_PREFIX_PATH "${path}")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${path}")
|
||||
# cmake-format: off
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
|
||||
# cmake-format: on
|
||||
set(CMAKE_PREFIX_PATH
|
||||
${CMAKE_PREFIX_PATH}
|
||||
PARENT_SCOPE)
|
||||
continue()
|
||||
else()
|
||||
message(AUTHOR_WARNING "Newer ${label} version detected in ${path}: \n"
|
||||
"Found ${_check_version}, require ${version}")
|
||||
# cmake-format: off
|
||||
set(found TRUE PARENT_SCOPE)
|
||||
# cmake-format: on
|
||||
set(found
|
||||
TRUE
|
||||
PARENT_SCOPE)
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
@@ -59,9 +59,7 @@ endfunction()
|
||||
function(_check_dependencies)
|
||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
|
||||
|
||||
# cmake-format: off
|
||||
string(JSON dependency_data GET ${buildspec} dependencies)
|
||||
# cmake-format: on
|
||||
|
||||
foreach(dependency IN LISTS dependencies_list)
|
||||
if(dependency STREQUAL cef AND arch STREQUAL universal)
|
||||
@@ -72,12 +70,12 @@ function(_check_dependencies)
|
||||
set(platform macos-${arch})
|
||||
endif()
|
||||
|
||||
# cmake-format: off
|
||||
string(JSON data GET ${dependency_data} ${dependency})
|
||||
string(JSON version GET ${data} version)
|
||||
string(JSON hash GET ${data} hashes ${platform})
|
||||
string(JSON url GET ${data} baseUrl)
|
||||
string(JSON label GET ${data} label)
|
||||
# cmake-format: off
|
||||
string(JSON revision ERROR_VARIABLE error GET ${data} revision ${platform})
|
||||
# cmake-format: on
|
||||
|
||||
@@ -181,7 +179,7 @@ function(_check_dependencies)
|
||||
|
||||
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
|
||||
|
||||
# cmake-format: off
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE PATH "CMake prefix search path" FORCE)
|
||||
# cmake-format: on
|
||||
set(CMAKE_PREFIX_PATH
|
||||
${CMAKE_PREFIX_PATH}
|
||||
CACHE PATH "CMake prefix search path" FORCE)
|
||||
endfunction()
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
include_guard(GLOBAL)
|
||||
|
||||
if(NOT DEFINED CCACHE_PROGRAM)
|
||||
message(DEBUG "Trying to find ccache on build host...")
|
||||
message(DEBUG "Trying to find ccache on build host")
|
||||
find_program(CCACHE_PROGRAM "ccache")
|
||||
mark_as_advanced(CCACHE_PROGRAM)
|
||||
endif()
|
||||
|
||||
if(CCACHE_PROGRAM)
|
||||
message(DEBUG "Ccache found as ${CCACHE_PROGRAM}...")
|
||||
message(DEBUG "Trying to find ccache on build host - done")
|
||||
message(DEBUG "Ccache found as ${CCACHE_PROGRAM}")
|
||||
option(ENABLE_CCACHE "Enable compiler acceleration with ccache" ON)
|
||||
|
||||
if(ENABLE_CCACHE)
|
||||
@@ -19,4 +20,6 @@ if(CCACHE_PROGRAM)
|
||||
set(CMAKE_OBJCXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
endif()
|
||||
else()
|
||||
message(DEBUG "Trying to find ccache on build host - skipped")
|
||||
endif()
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
|
||||
# cmake-format: off
|
||||
# cmake-lint: disable=C0103
|
||||
# cmake-lint: disable=C0301
|
||||
# cmake-lint: disable=C0307
|
||||
# cmake-lint: disable=R0912
|
||||
# cmake-lint: disable=R0915
|
||||
# cmake-lint: disable=E1121
|
||||
# cmake-format: on
|
||||
|
||||
include_guard(GLOBAL)
|
||||
@@ -156,6 +153,74 @@ macro(find_qt)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# _handle_generator_expression_dependency: Helper function to yield dependency from a generator expression
|
||||
function(_handle_generator_expression_dependency library)
|
||||
set(oneValueArgs FOUND_VAR)
|
||||
set(multiValueArgs)
|
||||
cmake_parse_arguments(var "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
set(${var_FOUND_VAR} "${var_FOUND_VAR}-NOTFOUND")
|
||||
|
||||
message(DEBUG "Checking ${library}...")
|
||||
|
||||
if(library MATCHES "\\$<\\$<PLATFORM_ID:[^>]+>:.+>" OR library MATCHES "\\$<\\$<NOT:\\$<PLATFORM_ID:[^>]+>>:.+>")
|
||||
# Platform-dependent generator expression found. Platforms are a comma-separated list of CMake host OS identifiers.
|
||||
# Convert to CMake list and check if current host OS is contained in list.
|
||||
string(REGEX REPLACE "\\$<.*\\$<PLATFORM_ID:([^>]+)>>?:([^>]+)>" "\\1;\\2" gen_expression "${library}")
|
||||
list(GET gen_expression 0 gen_platform)
|
||||
list(GET gen_expression 1 gen_library)
|
||||
string(REPLACE "," ";" gen_platform "${gen_platform}")
|
||||
|
||||
set(${var_FOUND_VAR} "${var_FOUND_VAR}-SKIP")
|
||||
|
||||
if(library MATCHES "\\$<\\$<NOT:.+>.+>")
|
||||
if(NOT CMAKE_SYSTEM_NAME IN_LIST gen_platform)
|
||||
set(${var_FOUND_VAR} "${gen_library}")
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_SYSTEM_NAME IN_LIST gen_platform)
|
||||
set(${var_FOUND_VAR} "${gen_library}")
|
||||
endif()
|
||||
endif()
|
||||
elseif(library MATCHES "\\$<\\$<BOOL:[^>]+>:.+>")
|
||||
# Boolean generator expression found. Consider parameter a CMake variable that resolves into a CMake-like boolean
|
||||
# value for a simple conditional check.
|
||||
string(REGEX REPLACE "\\$<\\$<BOOL:([^>]+)>:([^>]+)>" "\\1;\\2" gen_expression "${library}")
|
||||
list(GET gen_expression 0 gen_boolean)
|
||||
list(GET gen_expression 1 gen_library)
|
||||
|
||||
set(${var_FOUND_VAR} "${var_FOUND_VAR}-SKIP")
|
||||
|
||||
if(${gen_boolean})
|
||||
set(${var_FOUND_VAR} "${gen_library}")
|
||||
endif()
|
||||
elseif(library MATCHES "\\$<TARGET_NAME_IF_EXISTS:[^>]+>")
|
||||
# Target-dependent generator expression found. Consider parameter to be a CMake target identifier and check for
|
||||
# target existence.
|
||||
string(REGEX REPLACE "\\$<TARGET_NAME_IF_EXISTS:([^>]+)>" "\\1" gen_target "${library}")
|
||||
|
||||
set(${var_FOUND_VAR} "${var_FOUND_VAR}-SKIP")
|
||||
|
||||
if(TARGET ${gen_target})
|
||||
set(${var_FOUND_VAR} "${gen_target}")
|
||||
endif()
|
||||
elseif(library MATCHES "\\$<.*Qt6::EntryPointPrivate>" OR library MATCHES "\\$<.*Qt6::QDarwin.+PermissionPlugin>")
|
||||
set(${var_FOUND_VAR} "${var_FOUND_VAR}-SKIP")
|
||||
else()
|
||||
# Unknown or unimplemented generator expression found. Abort script run to either add to ignore list or implement
|
||||
# detection.
|
||||
message(FATAL_ERROR "${library} is an unsupported generator expression for linked libraries.")
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.25)
|
||||
set(${var_FOUND_VAR}
|
||||
${var_FOUND_VAR}
|
||||
PARENT_SCOPE)
|
||||
else()
|
||||
return(PROPAGATE ${var_FOUND_VAR})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# find_dependencies: Check linked interface and direct dependencies of target
|
||||
function(find_dependencies)
|
||||
set(oneValueArgs TARGET FOUND_VAR)
|
||||
@@ -188,45 +253,11 @@ function(find_dependencies)
|
||||
continue()
|
||||
elseif(library MATCHES "\\$<.*:[^>]+>")
|
||||
# Generator expression found
|
||||
if(library MATCHES "\\$<\\$<PLATFORM_ID:[^>]+>:.+>")
|
||||
# Platform-dependent generator expression found - platforms are a comma-separated list of CMake host OS
|
||||
# identifiers. Convert to CMake list and check if current host os is contained in list.
|
||||
string(REGEX REPLACE "\\$<\\$<PLATFORM_ID:([^>]+)>:([^>]+)>" "\\1;\\2" gen_expression "${library}")
|
||||
list(GET gen_expression 0 gen_platform)
|
||||
list(GET gen_expression 1 gen_library)
|
||||
string(REPLACE "," ";" gen_platform "${gen_platform}")
|
||||
if(CMAKE_SYSTEM_NAME IN_LIST platform)
|
||||
set(library "${gen_library}")
|
||||
else()
|
||||
continue()
|
||||
endif()
|
||||
elseif(library MATCHES "\\$<\\$<BOOL:[^>]+>:.+>")
|
||||
# Boolean generator expression found - consider parameter a CMake variable that resolves into a CMake-like
|
||||
# boolean value for a simple conditional check.
|
||||
string(REGEX REPLACE "\\$<\\$<BOOL:([^>]+)>:([^>]+)>" "\\1;\\2" gen_expression "${library}")
|
||||
list(GET gen_expression 0 gen_boolean)
|
||||
list(GET gen_expression 1 gen_library)
|
||||
if(${gen_boolean})
|
||||
set(library "${gen_library}")
|
||||
else()
|
||||
continue()
|
||||
endif()
|
||||
elseif(library MATCHES "\\$<TARGET_NAME_IF_EXISTS:[^>]+>")
|
||||
# Target-dependent generator expression found - consider parameter to be a CMake target identifier and check for
|
||||
# target existence.
|
||||
string(REGEX REPLACE "\\$<TARGET_NAME_IF_EXISTS:([^>]+)>" "\\1" gen_target "${library}")
|
||||
if(TARGET ${gen_target})
|
||||
set(library "${gen_target}")
|
||||
else()
|
||||
continue()
|
||||
endif()
|
||||
elseif(library MATCHES "\\$<.*Qt6::EntryPointPrivate>" OR library MATCHES "\\$<.*Qt6::QDarwin.+PermissionPlugin>")
|
||||
# Known Qt6-specific generator expression, ignored.
|
||||
_handle_generator_expression_dependency(${library} FOUND_VAR found_library)
|
||||
if(found_library STREQUAL found_library-SKIP)
|
||||
continue()
|
||||
else()
|
||||
# Unknown or unimplemented generator expression found - abort script run to either add to ignore list or
|
||||
# implement detection.
|
||||
message(FATAL_ERROR "${library} is an unsupported generator expression for linked libraries.")
|
||||
elseif(found_library)
|
||||
set(library ${found_library})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -240,18 +271,18 @@ function(find_dependencies)
|
||||
endforeach()
|
||||
|
||||
if(NOT is_root)
|
||||
set(found_libraries
|
||||
${found_libraries}
|
||||
PARENT_SCOPE)
|
||||
# cmake-format: off
|
||||
set(found_libraries ${found_libraries} PARENT_SCOPE)
|
||||
# cmake-format: on
|
||||
# Exit recursive branch
|
||||
return()
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES found_libraries)
|
||||
list(APPEND ${var_FOUND_VAR} ${found_libraries})
|
||||
set(${var_FOUND_VAR}
|
||||
${${var_FOUND_VAR}}
|
||||
PARENT_SCOPE)
|
||||
# cmake-format: off
|
||||
set(${var_FOUND_VAR} ${${var_FOUND_VAR}} PARENT_SCOPE)
|
||||
# cmake-format: on
|
||||
endfunction()
|
||||
|
||||
# find_qt_plugins: Find and add Qt plugin libraries associated with Qt component to target
|
||||
@@ -267,14 +298,9 @@ function(find_qt_plugins)
|
||||
message(FATAL_ERROR "'find_qt_plugins' has to be called with a valid target from the Qt or Qt6 namespace.")
|
||||
endif()
|
||||
|
||||
list(
|
||||
APPEND
|
||||
qt_plugins_Core
|
||||
platforms
|
||||
printsupport
|
||||
styles
|
||||
imageformats
|
||||
iconengines)
|
||||
# cmake-format: off
|
||||
list(APPEND qt_plugins_Core platforms printsupport styles imageformats iconengines)
|
||||
# cmake-format: on
|
||||
list(APPEND qt_plugins_Gui platforminputcontexts virtualkeyboard)
|
||||
list(APPEND qt_plugins_Network bearer)
|
||||
list(APPEND qt_plugins_Sql sqldrivers)
|
||||
@@ -318,9 +344,9 @@ function(find_qt_plugins)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(${var_FOUND_VAR}
|
||||
${plugins_list}
|
||||
PARENT_SCOPE)
|
||||
# cmake-format: off
|
||||
set(${var_FOUND_VAR} ${plugins_list} PARENT_SCOPE)
|
||||
# cmake-format: on
|
||||
endfunction()
|
||||
|
||||
# target_export: Helper function to export target as CMake package
|
||||
@@ -400,15 +426,19 @@ function(target_export target)
|
||||
${exclude_variant})
|
||||
endif()
|
||||
|
||||
message(DEBUG "Generating export header for target ${target} as ${target}_EXPORT.h...")
|
||||
include(GenerateExportHeader)
|
||||
generate_export_header(${target} EXPORT_FILE_NAME "${target}_EXPORT.h")
|
||||
target_sources(${target} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${target}_EXPORT.h>)
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
|
||||
set_property(
|
||||
TARGET ${target}
|
||||
APPEND
|
||||
PROPERTY PUBLIC_HEADER "${target}_EXPORT.h")
|
||||
if(NOT target_type STREQUAL INTERFACE_LIBRARY)
|
||||
message(DEBUG "Generating export header for target ${target} as ${target}_EXPORT.h...")
|
||||
include(GenerateExportHeader)
|
||||
generate_export_header(${target} EXPORT_FILE_NAME "${target}_EXPORT.h")
|
||||
target_sources(${target} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${target}_EXPORT.h>)
|
||||
|
||||
set_property(
|
||||
TARGET ${target}
|
||||
APPEND
|
||||
PROPERTY PUBLIC_HEADER "${target}_EXPORT.h")
|
||||
endif()
|
||||
|
||||
set(TARGETS_EXPORT_NAME ${target}Targets)
|
||||
message(
|
||||
@@ -476,14 +506,44 @@ function(check_uuid uuid_string return_value)
|
||||
set(valid_uuid FALSE)
|
||||
endif()
|
||||
message(DEBUG "UUID ${uuid_string} valid: ${valid_uuid}")
|
||||
set(${return_value}
|
||||
${valid_uuid}
|
||||
PARENT_SCOPE)
|
||||
# cmake-format: off
|
||||
set(${return_value} ${valid_uuid} PARENT_SCOPE)
|
||||
# cmake-format: on
|
||||
endfunction()
|
||||
|
||||
# legacy_check: Checks if new CMake framework was not enabled and load legacy rules instead
|
||||
# legacy_check: Check if new CMake framework was not enabled and load legacy rules instead
|
||||
macro(legacy_check)
|
||||
if(OBS_CMAKE_VERSION VERSION_LESS 3.0.0)
|
||||
message(FATAL_ERROR "CMake version changed between CMakeLists.txt.")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# add_obs_plugin: Add plugin subdirectory if host platform is in specified list of supported platforms
|
||||
function(add_obs_plugin target)
|
||||
set(options WITH_MESSAGE)
|
||||
set(oneValueArgs "")
|
||||
set(multiValueArgs PLATFORMS)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 _AOP "${options}" "${oneValueArgs}" "${multiValueArgs}")
|
||||
|
||||
set(found_platform FALSE)
|
||||
list(LENGTH _AOP_PLATFORMS _AOP_NUM_PLATFORMS)
|
||||
|
||||
if(_AOP_NUM_PLATFORMS EQUAL 0)
|
||||
set(found_platform TRUE)
|
||||
else()
|
||||
foreach(platform IN LISTS _AOP_PLATFORMS)
|
||||
set(check_var_name "OS_${platform}")
|
||||
if(${${check_var_name}})
|
||||
set(found_platform TRUE)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(found_platform)
|
||||
add_subdirectory(${target})
|
||||
elseif(_AOP_WITH_MESSAGE)
|
||||
add_custom_target(${target} COMMENT "Dummy target for unavailable module ${target}")
|
||||
target_disable(${target})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
3
cmake/common/policies.cmake
Normal file
3
cmake/common/policies.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
# OBS CMake policies module
|
||||
|
||||
include_guard(GLOBAL)
|
||||
@@ -1,9 +1,5 @@
|
||||
# OBS CMake common version helper module
|
||||
|
||||
# cmake-format: off
|
||||
# cmake-lint: disable=C0301
|
||||
# cmake-format: on
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
set(_obs_version ${_obs_default_version})
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# OBS CMake macOS helper functions module
|
||||
|
||||
# cmake-format: off
|
||||
# cmake-lint: disable=C0301
|
||||
# cmake-lint: disable=C0307
|
||||
# cmake-lint: disable=E1126
|
||||
# cmake-lint: disable=R0912
|
||||
# cmake-lint: disable=R0915
|
||||
# cmake-lint: disable=E1126
|
||||
# cmake-format: on
|
||||
|
||||
include_guard(GLOBAL)
|
||||
@@ -22,9 +23,7 @@ function(set_target_xcode_properties target)
|
||||
|
||||
while(_STXP_PROPERTIES)
|
||||
list(POP_FRONT _STXP_PROPERTIES key value)
|
||||
# cmake-format: off
|
||||
set_property(TARGET ${target} PROPERTY XCODE_ATTRIBUTE_${key} "${value}")
|
||||
# cmake-format: on
|
||||
endwhile()
|
||||
endfunction()
|
||||
|
||||
@@ -41,6 +40,7 @@ function(set_target_properties_obs target)
|
||||
list(POP_FRONT _STPO_PROPERTIES key value)
|
||||
set_property(TARGET ${target} PROPERTY ${key} "${value}")
|
||||
endwhile()
|
||||
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
|
||||
string(TIMESTAMP CURRENT_YEAR "%Y")
|
||||
@@ -107,11 +107,8 @@ function(set_target_properties_obs target)
|
||||
get_property(obs_executables GLOBAL PROPERTY _OBS_EXECUTABLES)
|
||||
add_dependencies(${target} ${obs_executables})
|
||||
foreach(executable IN LISTS obs_executables)
|
||||
# cmake-format: off
|
||||
set_target_xcode_properties(
|
||||
${executable}
|
||||
PROPERTIES INSTALL_PATH "$(LOCAL_APPS_DIR)/$<TARGET_BUNDLE_DIR_NAME:${target}>/Contents/MacOS")
|
||||
# cmake-format: on
|
||||
set_target_xcode_properties(${executable} PROPERTIES INSTALL_PATH
|
||||
"$(LOCAL_APPS_DIR)/$<TARGET_BUNDLE_DIR_NAME:${target}>/Contents/MacOS")
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# OBS CMake Windows compiler configuration module
|
||||
|
||||
# cmake-format: off
|
||||
# cmake-lint: disable=E1126
|
||||
# cmake-format: on
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
include(ccache)
|
||||
@@ -10,6 +14,7 @@ if(ENABLE_CCACHE AND CCACHE_PROGRAM)
|
||||
file(COPY_FILE ${CCACHE_PROGRAM} "${CMAKE_CURRENT_BINARY_DIR}/cl.exe")
|
||||
set(CMAKE_VS_GLOBALS "CLToolExe=cl.exe" "CLToolPath=${CMAKE_BINARY_DIR}" "TrackFileAccess=false"
|
||||
"UseMultiToolTask=true")
|
||||
# Ccache does not support debug information stored in program database (PDB) files
|
||||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded)
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
file(COPY_FILE ${CCACHE_PROGRAM} "${CMAKE_CURRENT_BINARY_DIR}/clang-cl.exe")
|
||||
@@ -42,9 +47,8 @@ if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348)
|
||||
"Please download and install the most recent Windows SDK.")
|
||||
endif()
|
||||
|
||||
set(_obs_msvc_c_options /Brepro /MP /permissive- /Zc:__cplusplus /Zc:preprocessor)
|
||||
|
||||
set(_obs_msvc_cpp_options /Brepro /MP /permissive- /Zc:__cplusplus /Zc:preprocessor)
|
||||
set(_obs_msvc_c_options /MP /Zc:__cplusplus /Zc:preprocessor)
|
||||
set(_obs_msvc_cpp_options /MP /Zc:__cplusplus /Zc:preprocessor)
|
||||
|
||||
if(CMAKE_CXX_STANDARD GREATER_EQUAL 20)
|
||||
list(APPEND _obs_msvc_cpp_options /Zc:char8_t-)
|
||||
@@ -53,6 +57,8 @@ endif()
|
||||
add_compile_options(
|
||||
/W3
|
||||
/utf-8
|
||||
/Brepro
|
||||
/permissive-
|
||||
"$<$<COMPILE_LANG_AND_ID:C,MSVC>:${_obs_msvc_c_options}>"
|
||||
"$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:${_obs_msvc_cpp_options}>"
|
||||
"$<$<COMPILE_LANG_AND_ID:C,Clang>:${_obs_clang_c_options}>"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# OBS CMake Windows helper functions module
|
||||
|
||||
# cmake-format: off
|
||||
# cmake-lint: disable=C0301
|
||||
# cmake-lint: disable=C0103
|
||||
# cmake-lint: disable=R0912
|
||||
# cmake-lint: disable=R0915
|
||||
# cmake-format: on
|
||||
|
||||
@@ -98,10 +99,11 @@ function(set_target_properties_obs target)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E echo "Add obspython import module"
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_SCRIPT_PLUGIN_DESTINATION}/"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE_DIR:obspython>/obspython.py"
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_SCRIPT_PLUGIN_DESTINATION}/"
|
||||
COMMENT "Add obspython import module")
|
||||
COMMENT "")
|
||||
|
||||
install(
|
||||
FILES "$<TARGET_FILE_DIR:obspython>/obspython.py"
|
||||
@@ -118,6 +120,7 @@ function(set_target_properties_obs target)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E echo "Add Chromium Embedded Framework to library directory"
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${target_destination}"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E copy_if_different "${imported_location}" "${cef_location}/chrome_elf.dll"
|
||||
@@ -129,7 +132,7 @@ function(set_target_properties_obs target)
|
||||
"${cef_root_location}/Resources/resources.pak" "${OBS_OUTPUT_DIR}/$<CONFIG>/${target_destination}/"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${cef_root_location}/Resources/locales"
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIG>/${target_destination}/locales"
|
||||
COMMENT "Add Chromium Embedded Framework to library directory")
|
||||
COMMENT "")
|
||||
|
||||
install(
|
||||
FILES "${imported_location}"
|
||||
@@ -249,11 +252,12 @@ function(_target_install_obs target)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E echo "${comment}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${_TIO_DESTINATION}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy ${target_file} "${OBS_OUTPUT_DIR}/$<CONFIG>/${_TIO_DESTINATION}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E $<IF:$<CONFIG:Debug,RelWithDebInfo,Release>,copy,true> ${target_pdb_file}
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIG>/${_TIO_DESTINATION}"
|
||||
COMMENT "${comment}"
|
||||
COMMENT ""
|
||||
VERBATIM)
|
||||
|
||||
install(
|
||||
@@ -309,17 +313,17 @@ function(target_install_resources target)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E echo "Copy ${target} resources to data directory"
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${target_destination}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/data"
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIG>/${target_destination}"
|
||||
COMMENT "Copy ${target} resources to data directory"
|
||||
COMMENT ""
|
||||
VERBATIM)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Helper function to add a specific resource to a bundle
|
||||
function(target_add_resource target resource)
|
||||
|
||||
get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
|
||||
if(ARGN)
|
||||
set(target_destination "${ARGN}")
|
||||
@@ -341,9 +345,10 @@ function(target_add_resource target resource)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E echo "Copy ${target} resource ${resource} to library directory"
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${target_destination}/"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${resource}" "${OBS_OUTPUT_DIR}/$<CONFIG>/${target_destination}/"
|
||||
COMMENT "Copy ${target} resource ${resource} to library directory"
|
||||
COMMENT ""
|
||||
VERBATIM)
|
||||
|
||||
source_group("Resources" FILES "${resource}")
|
||||
@@ -407,6 +412,7 @@ function(_bundle_dependencies target)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E echo "Copy dependencies to binary directory (${OBS_EXECUTABLE_DESTINATION})..."
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_EXECUTABLE_DESTINATION}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E "$<IF:$<CONFIG:Debug>,copy_if_different,true>"
|
||||
"$<$<CONFIG:Debug>:${library_paths_DEBUG}>" "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_EXECUTABLE_DESTINATION}"
|
||||
@@ -419,7 +425,7 @@ function(_bundle_dependencies target)
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E "$<IF:$<CONFIG:MinSizeRel>,copy_if_different,true>"
|
||||
"$<$<CONFIG:MinSizeRel>:${library_paths_MINSIZEREL}>" "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_EXECUTABLE_DESTINATION}"
|
||||
COMMENT "Copy dependencies to binary directory (${OBS_EXECUTABLE_DESTINATION})..."
|
||||
COMMENT "."
|
||||
VERBATIM COMMAND_EXPAND_LISTS)
|
||||
|
||||
install(
|
||||
@@ -469,12 +475,14 @@ function(_bundle_dependencies target)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E echo
|
||||
"Copy Qt plugins ${stem} to binary directory (${OBS_EXECUTABLE_DESTINATION}/${stem})"
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_EXECUTABLE_DESTINATION}/${stem}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E "$<IF:$<CONFIG:Debug>,copy_if_different,true>" "${plugin_list_debug}"
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_EXECUTABLE_DESTINATION}/${stem}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E "$<IF:$<CONFIG:Debug>,true,copy_if_different>" "${plugin_list}"
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_EXECUTABLE_DESTINATION}/${stem}"
|
||||
COMMENT "Copy Qt plugins ${stem} to binary directory (${OBS_EXECUTABLE_DESTINATION}/${stem})"
|
||||
COMMENT ""
|
||||
VERBATIM COMMAND_EXPAND_LISTS)
|
||||
|
||||
install(
|
||||
|
||||
Reference in New Issue
Block a user