From 7dbde70de121952edb4d7f4b62c2172e5b6db446 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Thu, 5 Oct 2023 18:31:19 +0200 Subject: [PATCH] cmake: Remove support for generators besides Xcode on macOS --- UI/cmake/os-macos.cmake | 4 - cmake/macos/compilerconfig.cmake | 119 ++++++++---------- cmake/macos/defaults.cmake | 4 +- cmake/macos/helpers.cmake | 4 - cmake/macos/xcode.cmake | 7 +- plugins/mac-avcapture/CMakeLists.txt | 4 - .../src/dal-plugin/CMakeLists.txt | 4 - .../src/obs-plugin/CMakeLists.txt | 4 - 8 files changed, 57 insertions(+), 93 deletions(-) diff --git a/UI/cmake/os-macos.cmake b/UI/cmake/os-macos.cmake index d67d82c01..0c74c683d 100644 --- a/UI/cmake/os-macos.cmake +++ b/UI/cmake/os-macos.cmake @@ -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) diff --git a/cmake/macos/compilerconfig.cmake b/cmake/macos/compilerconfig.cmake index 4cca6bfe4..32e77bdc7 100644 --- a/cmake/macos/compilerconfig.cmake +++ b/cmake/macos/compilerconfig.cmake @@ -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( - "$<$:${_obs_clang_c_options}>" - "$<$:${_obs_clang_cxx_options}>" - "$<$:${_obs_clang_objc_options}>" - "$<$:${_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($<$>:-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( - "$<$>:$<$:DEBUG>;$<$:_DEBUG>;SIMDE_ENABLE_OPENMP>") + $<$>:$<$:DEBUG>> + $<$>:$<$:_DEBUG>> $<$>:SIMDE_ENABLE_OPENMP>) + +if(ENABLE_COMPILER_TRACE) + add_compile_options( + $<$>:-ftime-trace> + "$<$:SHELL:-Xfrontend -debug-time-expression-type-checking>" + "$<$:SHELL:-Xfrontend -debug-time-function-bodies>") + add_link_options(LINKER:-print_statistics) +endif() diff --git a/cmake/macos/defaults.cmake b/cmake/macos/defaults.cmake index 3f8a512be..8bc947e16 100644 --- a/cmake/macos/defaults.cmake +++ b/cmake/macos/defaults.cmake @@ -16,9 +16,7 @@ if(NOT OBS_CODESIGN_TEAM) endif() endif() -if(XCODE) - include(xcode) -endif() +include(xcode) include(buildspec) diff --git a/cmake/macos/helpers.cmake b/cmake/macos/helpers.cmake index a74c1525a..1088429c8 100644 --- a/cmake/macos/helpers.cmake +++ b/cmake/macos/helpers.cmake @@ -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} diff --git a/cmake/macos/xcode.cmake b/cmake/macos/xcode.cmake index f4148d86a..708935c5d 100644 --- a/cmake/macos/xcode.cmake +++ b/cmake/macos/xcode.cmake @@ -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) diff --git a/plugins/mac-avcapture/CMakeLists.txt b/plugins/mac-avcapture/CMakeLists.txt index 14ed84bc2..472934273 100644 --- a/plugins/mac-avcapture/CMakeLists.txt +++ b/plugins/mac-avcapture/CMakeLists.txt @@ -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 diff --git a/plugins/mac-virtualcam/src/dal-plugin/CMakeLists.txt b/plugins/mac-virtualcam/src/dal-plugin/CMakeLists.txt index 4cfbff670..5c9258d43 100644 --- a/plugins/mac-virtualcam/src/dal-plugin/CMakeLists.txt +++ b/plugins/mac-virtualcam/src/dal-plugin/CMakeLists.txt @@ -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") diff --git a/plugins/mac-virtualcam/src/obs-plugin/CMakeLists.txt b/plugins/mac-virtualcam/src/obs-plugin/CMakeLists.txt index a17df8dc2..d6236fe3b 100644 --- a/plugins/mac-virtualcam/src/obs-plugin/CMakeLists.txt +++ b/plugins/mac-virtualcam/src/obs-plugin/CMakeLists.txt @@ -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