cmake: Remove support for generators besides Xcode on macOS

This commit is contained in:
PatTheMav
2023-10-05 18:31:19 +02:00
committed by Ryan Foster
parent eae4673071
commit 7dbde70de1
8 changed files with 57 additions and 93 deletions
-4
View File
@@ -1,7 +1,3 @@
if(NOT XCODE)
target_add_resource(obs-studio "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/Assets.xcassets")
endif()
target_sources(obs-studio PRIVATE platform-osx.mm forms/OBSPermissions.ui window-permissions.cpp window-permissions.hpp)
target_compile_options(obs-studio PRIVATE -Wno-quoted-include-in-framework-header -Wno-comma)
+54 -65
View File
@@ -2,6 +2,13 @@
include_guard(GLOBAL)
option(ENABLE_COMPILER_TRACE "Enable clang time-trace" OFF)
mark_as_advanced(ENABLE_COMPILER_TRACE)
if(NOT XCODE)
message(FATAL_ERROR "Building OBS Studio on macOS requires Xcode generator.")
endif()
include(ccache)
include(compiler_common)
@@ -15,77 +22,59 @@ if(NOT CMAKE_OSX_ARCHITECTURES)
endif()
set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS arm64 x86_64)
# Make sure the macOS SDK is recent enough for OBS
set(OBS_MACOS_MINIMUM_SDK "13.1") # Keep in sync with Xcode
set(OBS_MACOS_MINIMUM_XCODE "14.2") # Keep in sync with SDK
# Ensure recent enough Xcode and platform SDK
set(_obs_macos_minimum_sdk 13.1) # Keep in sync with Xcode
set(_obs_macos_minimum_xcode 14.2) # Keep in sync with SDK
message(DEBUG "macOS SDK Path: ${CMAKE_OSX_SYSROOT}")
string(REGEX MATCH ".+/MacOSX.platform/Developer/SDKs/MacOSX([0-9]+\.[0-9])+\.sdk$" _ ${CMAKE_OSX_SYSROOT})
set(OBS_MACOS_CURRENT_SDK ${CMAKE_MATCH_1})
string(REGEX MATCH ".+/MacOSX.platform/Developer/SDKs/MacOSX([0-9]+\\.[0-9])+\\.sdk$" _ ${CMAKE_OSX_SYSROOT})
set(_obs_macos_current_sdk ${CMAKE_MATCH_1})
message(DEBUG "macOS SDK version: ${OBS_MACOS_CURRENT_SDK}")
if(OBS_MACOS_CURRENT_SDK VERSION_LESS OBS_MACOS_MINIMUM_SDK)
if(_obs_macos_current_sdk VERSION_LESS _obs_macos_minimum_sdk)
message(
FATAL_ERROR
"Your macOS SDK version (${OBS_MACOS_CURRENT_SDK}) is too low. The macOS ${OBS_MACOS_MINIMUM_SDK} SDK (Xcode ${OBS_MACOS_MINIMUM_XCODE}) is required to build OBS."
)
FATAL_ERROR "Your macOS SDK version (${OBS_MACOS_CURRENT_SDK}) is too low. "
"The macOS ${OBS_MACOS_MINIMUM_SDK} SDK (Xcode ${OBS_MACOS_MINIMUM_XCODE}) is required to build OBS.")
endif()
unset(_obs_macos_current_sdk)
unset(_obs_macos_minimum_sdk)
unset(_obs_macos_minimum_xcode)
if(XCODE)
# Enable dSYM generator for release builds
string(APPEND CMAKE_C_FLAGS_RELEASE " -g")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g")
else()
option(ENABLE_COMPILER_TRACE "Enable clang time-trace (requires Ninja)" OFF)
mark_as_advanced(ENABLE_COMPILER_TRACE)
# Enable dSYM generator for release builds
string(APPEND CMAKE_C_FLAGS_RELEASE " -g")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g")
string(APPEND CMAKE_OBJC_FLAGS_RELEASE " -g")
string(APPEND CMAKE_OBJCXX_FLAGS_RELEASE " -g")
# clang options for ObjC
set(_obs_clang_objc_options
${_obs_clang_common_options}
-Wno-implicit-atomic-properties
-Wno-objc-interface-ivars
-Warc-repeated-use-of-weak
-Wno-arc-maybe-repeated-use-of-weak
-Wimplicit-retain-self
-Wduplicate-method-match
-Wshadow
-Wfloat-conversion
-Wobjc-literal-conversion
-Wno-selector
-Wno-strict-selector-match
-Wundeclared-selector
-Wdeprecated-implementations
-Wprotocol
-Werror=block-capture-autoreleasing
-Wrange-loop-analysis)
# Default ObjC compiler options used by Xcode:
#
# * -Wno-implicit-atomic-properties
# * -Wno-objc-interface-ivars
# * -Warc-repeated-use-of-weak
# * -Wno-arc-maybe-repeated-use-of-weak
# * -Wimplicit-retain-self
# * -Wduplicate-method-match
# * -Wshadow
# * -Wfloat-conversion
# * -Wobjc-literal-conversion
# * -Wno-selector
# * -Wno-strict-selector-match
# * -Wundeclared-selector
# * -Wdeprecated-implementations
# * -Wprotocol
# * -Werror=block-capture-autoreleasing
# * -Wrange-loop-analysis
# clang options for ObjC++
set(_obs_clang_objcxx_options ${_obs_clang_objc_options} -Wno-non-virtual-dtor)
# cmake-format: off
add_compile_options(
"$<$<COMPILE_LANGUAGE:C>:${_obs_clang_c_options}>"
"$<$<COMPILE_LANGUAGE:CXX>:${_obs_clang_cxx_options}>"
"$<$<COMPILE_LANGUAGE:OBJC>:${_obs_clang_objc_options}>"
"$<$<COMPILE_LANGUAGE:OBJCXX>:${_obs_clang_objcxx_options}>")
# cmake-format: on
# Enable stripping of dead symbols when not building for Debug configuration
set(_release_configs RelWithDebInfo Release MinSizeRel)
if(CMAKE_BUILD_TYPE IN_LIST _release_configs)
add_link_options(LINKER:-dead_strip)
endif()
# Enable color diagnostics for AppleClang
set(CMAKE_COLOR_DIAGNOSTICS ON)
# Add time trace option to compiler, if enabled.
if(ENABLE_COMPILER_TRACE AND CMAKE_GENERATOR STREQUAL "Ninja")
add_compile_options($<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-ftime-trace>)
else()
set(ENABLE_COMPILER_TRACE
OFF
CACHE BOOL "Enable clang time-trace (requires Ninja)" FORCE)
endif()
endif()
# Default ObjC++ compiler options used by Xcode:
#
# * -Wno-non-virtual-dtor
add_compile_definitions(
"$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:$<$<CONFIG:DEBUG>:DEBUG>;$<$<CONFIG:DEBUG>:_DEBUG>;SIMDE_ENABLE_OPENMP>")
$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:$<$<CONFIG:DEBUG>:DEBUG>>
$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:$<$<CONFIG:DEBUG>:_DEBUG>> $<$<NOT:$<COMPILE_LANGUAGE:Swift>>:SIMDE_ENABLE_OPENMP>)
if(ENABLE_COMPILER_TRACE)
add_compile_options(
$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-ftime-trace>
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -debug-time-expression-type-checking>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -debug-time-function-bodies>")
add_link_options(LINKER:-print_statistics)
endif()
+1 -3
View File
@@ -16,9 +16,7 @@ if(NOT OBS_CODESIGN_TEAM)
endif()
endif()
if(XCODE)
include(xcode)
endif()
include(xcode)
include(buildspec)
-4
View File
@@ -80,10 +80,6 @@ function(set_target_properties_obs target)
get_property(obs_dependencies GLOBAL PROPERTY _OBS_DEPENDENCIES)
add_dependencies(${target} ${obs_dependencies})
if(NOT XCODE)
return()
endif()
get_property(obs_frameworks GLOBAL PROPERTY _OBS_FRAMEWORKS)
set_property(
TARGET ${target}
+2 -5
View File
@@ -91,9 +91,6 @@ set(CMAKE_XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES)
# Strip unused code
set(CMAKE_XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING YES)
# Display mangled names in Debug configuration
set(CMAKE_XCODE_ATTRIBUTE_LINKER_DISPLAYS_MANGLED_NAMES[variant=Debug] YES)
# Build active architecture only in Debug configuration
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] YES)
@@ -120,9 +117,9 @@ set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)
#
# set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD c++17)
# Enable support for module imports in ObjC
# Disable support for module imports in ObjC
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES NO)
# Enable automatic linking of imported modules in ObjC
# Disable automatic linking of imported modules in ObjC
set(CMAKE_XCODE_ATTRIBUTE_CLANG_MODULES_AUTOLINK NO)
# Enable strict msg_send rules for ObjC
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_STRICT_OBJC_MSGSEND YES)
-4
View File
@@ -5,10 +5,6 @@ add_library(OBS::avcapture ALIAS mac-avcapture)
target_sources(mac-avcapture PRIVATE av-capture.mm left-right.hpp scope-guard.hpp)
if(NOT XCODE)
set_source_files_properties(av-capture.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
endif()
target_link_libraries(
mac-avcapture
PRIVATE OBS::libobs
@@ -24,10 +24,6 @@ target_sources(
OBSDALStream.h
OBSDALStream.mm)
if(NOT XCODE)
target_compile_options(obs-dal-plugin PRIVATE -fobjc-arc -fobjc-weak)
endif()
set(_placeholder_location "${CMAKE_CURRENT_SOURCE_DIR}/../common/data/placeholder.png")
set_property(SOURCE "${_placeholder_location}" PROPERTY MACOSX_PACKAGE_LOCATION "Resources")
@@ -6,10 +6,6 @@ add_library(OBS::virtualcam ALIAS mac-virtualcam)
target_sources(mac-virtualcam PRIVATE Defines.h plugin-main.mm OBSDALMachServer.mm OBSDALMachServer.h)
target_compile_options(mac-virtualcam PRIVATE -fmodules -fcxx-modules)
if(NOT XCODE)
target_compile_options(mac-virtualcam PRIVATE -fobjc-arc -fobjc-weak)
endif()
target_link_libraries(mac-virtualcam PRIVATE OBS::mach-protocol OBS::libobs OBS::frontend-api)
# cmake-format: off