Skip to content

Commit

Permalink
cmake: Update CMake files to current state found on obs-studio
Browse files Browse the repository at this point in the history
  • Loading branch information
PatTheMav committed Oct 31, 2024
1 parent 1359eb6 commit b16a53a
Show file tree
Hide file tree
Showing 28 changed files with 625 additions and 703 deletions.
8 changes: 0 additions & 8 deletions .github/scripts/build-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,6 @@ ${_usage_host:-}"
local cmake_version
read -r _ _ cmake_version <<< "$(cmake --version)"
if [[ ${CPUTYPE} != ${target##*-} ]] {
if is-at-least 3.21.0 ${cmake_version}; then
cmake_args+=(--toolchain "${project_root}/cmake/linux/toolchains/${target##*-}-linux-gcc.cmake")
else
cmake_args+=(-D"CMAKE_TOOLCHAIN_FILE=${project_root}/cmake/linux/toolchains/${target##*-}-linux-gcc.cmake")
fi
}
cmake_build_args+=(--preset ${_preset}-${target##*-} --config ${config})
if [[ ${generator} == 'Unix Makefiles' ]] {
cmake_build_args+=(--parallel $(( $(nproc) + 1 )))
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16...3.26)
cmake_minimum_required(VERSION 3.28...3.30)

include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)

Expand All @@ -25,13 +25,13 @@ if(ENABLE_QT)
find_package(Qt6 COMPONENTS Widgets Core)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets)
target_compile_options(
${CMAKE_PROJECT_NAME} PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang>:-Wno-quoted-include-in-framework-header
-Wno-comma>)
${CMAKE_PROJECT_NAME}
PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang>:-Wno-quoted-include-in-framework-header -Wno-comma>
)
set_target_properties(
${CMAKE_PROJECT_NAME}
PROPERTIES AUTOMOC ON
AUTOUIC ON
AUTORCC ON)
PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON
)
endif()

target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-main.c)
Expand Down
87 changes: 25 additions & 62 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 3,
"version": 8,
"cmakeMinimumRequired": {
"major": 3,
"minor": 22,
"minor": 28,
"patch": 0
},
"configurePresets": [
Expand All @@ -29,6 +29,7 @@
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"CMAKE_OSX_DEPLOYMENT_TARGET": "11.0",
"CMAKE_OSX_ARCHITECTURES": "arm64;x86_64",
"CODESIGN_IDENTITY": "$penv{CODESIGN_IDENT}",
"CODESIGN_TEAM": "$penv{CODESIGN_TEAM}"
}
Expand All @@ -40,7 +41,8 @@
"description": "Build for macOS 11.0+ (Universal binary) for CI",
"generator": "Xcode",
"cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": true
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
"ENABLE_CCACHE": true
}
},
{
Expand All @@ -55,7 +57,7 @@
"rhs": "Windows"
},
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"architecture": "x64,version=10.0.22621",
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"CMAKE_SYSTEM_VERSION": "10.0.18363.657"
Expand All @@ -71,9 +73,9 @@
}
},
{
"name": "linux-x86_64",
"displayName": "Linux x86_64",
"description": "Build for Linux x86_64",
"name": "ubuntu-x86_64",
"displayName": "Ubuntu x86_64",
"description": "Build for Ubuntu x86_64",
"inherits": ["template"],
"binaryDir": "${sourceDir}/build_x86_64",
"condition": {
Expand All @@ -83,45 +85,20 @@
},
"generator": "Ninja",
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "linux-ci-x86_64",
"inherits": ["linux-x86_64"],
"displayName": "Linux x86_64 CI build",
"description": "Build for Linux x86_64 on CI",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
},
{
"name": "linux-aarch64",
"displayName": "Linux aarch64",
"description": "Build for Linux aarch64",
"inherits": ["template"],
"binaryDir": "${sourceDir}/build_aarch64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"generator": "Ninja",
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
"CMAKE_INSTALL_LIBDIR": "lib/CMAKE_SYSTEM_PROCESSOR-linux-gnu"
}
},
{
"name": "linux-ci-aarch64",
"inherits": ["linux-aarch64"],
"displayName": "Linux aarch64 CI build",
"description": "Build for Linux aarch64 on CI",
"name": "ubuntu-ci-x86_64",
"inherits": ["ubuntu-x86_64"],
"displayName": "Ubuntu x86_64 CI build",
"description": "Build for Ubuntu x86_64 on CI",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_COMPILE_WARNING_AS_ERROR": true
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
"ENABLE_CCACHE": true
}
}
],
Expand All @@ -131,7 +108,7 @@
"configurePreset": "macos",
"displayName": "macOS Universal",
"description": "macOS build for Universal architectures",
"configuration": "Release"
"configuration": "RelWithDebInfo"
},
{
"name": "macos-ci",
Expand All @@ -155,31 +132,17 @@
"configuration": "RelWithDebInfo"
},
{
"name": "linux-x86_64",
"configurePreset": "linux-x86_64",
"displayName": "Linux x86_64",
"description": "Linux build for x86_64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-ci-x86_64",
"configurePreset": "linux-ci-x86_64",
"displayName": "Linux x86_64 CI",
"description": "Linux CI build for x86_64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-aarch64",
"configurePreset": "linux-aarch64",
"displayName": "Linux aarch64",
"description": "Linux build for aarch64",
"name": "ubuntu-x86_64",
"configurePreset": "ubuntu-x86_64",
"displayName": "Ubuntu x86_64",
"description": "Ubuntu build for x86_64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-ci-aarch64",
"configurePreset": "linux-ci-aarch64",
"displayName": "Linux aarch64 CI",
"description": "Linux CI build for aarch64",
"name": "ubuntu-ci-x86_64",
"configurePreset": "ubuntu-ci-x86_64",
"displayName": "Ubuntu x86_64 CI",
"description": "Ubuntu CI build for x86_64",
"configuration": "RelWithDebInfo"
}
]
Expand Down
26 changes: 13 additions & 13 deletions buildspec.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
{
"dependencies": {
"obs-studio": {
"version": "30.1.2",
"version": "31.0.0-beta1",
"baseUrl": "https://github.com/obsproject/obs-studio/archive/refs/tags",
"label": "OBS sources",
"hashes": {
"macos": "490bae1c392b3b344b0270afd8cb887da4bc50bd92c0c426e96713c1ccb9701a",
"windows-x64": "c2dd03fa7fd01fad5beafce8f7156da11f9ed9a588373fd40b44a06f4c03b867"
"macos": "41d783ae8705717f07ea9a433c70f561bb3e18242b4b4c65bbfa68215d052bf9",
"windows-x64": "4d44b41f7a58b3c3df7bfc53ea4d20c7b480193511693b297ffc1018f048b276"
}
},
"prebuilt": {
"version": "2024-03-19",
"version": "2024-09-12",
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-Built obs-deps",
"hashes": {
"macos": "2e9bfb55a5e0e4c1086fa1fda4cf268debfead473089df2aaea80e1c7a3ca7ff",
"windows-x64": "6e86068371526a967e805f6f9903f9407adb683c21820db5f07da8f30d11e998"
"macos": "c857b211ee378772994b632036e1e5befe66b37e85286cb8e3cefc1435d5220a",
"windows-x64": "d4a4f194591766891ad3c0b267deec3c4b85239c8fe557273559927456aeedbb"
}
},
"qt6": {
"version": "2024-03-19",
"version": "2024-09-12",
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-Built Qt6",
"hashes": {
"macos": "694f1e639c017e3b1f456f735330dc5afae287cbea85757101af1368de3142c8",
"windows-x64": "72d1df34a0ef7413a681d5fcc88cae81da60adc03dcd23ef17862ab170bcc0dd"
"macos": "34a2de6b7f4d4d58fc5a15a4dba49a61d81a4045d0cedfc1a1f08c0dfb8047cf",
"windows-x64": "4d15ce13dbb0a8a2cabcce5ae0da5e80ee589b482a61b2025378465c1da32c4f"
},
"debugSymbols": {
"windows-x64": "fbddd1f659c360f2291911ac5709b67b6f8182e6bca519d24712e4f6fd3cc865"
"windows-x64": "dad2351a5c9cd438168e1ed8fb453a2534532252edb555f1001a5e8eb3f1bbd4"
}
}
},
"platformConfig": {
"macos": {
"bundleId": "com.example.obs-plugintemplate"
"bundleId": "com.example.plugintemplate-for-obs"
}
},
"name": "obs-plugintemplate",
"displayName": "OBS Plugin Template",
"name": "plugintemplate-for-obs",
"displayName": "Plugin Template for OBS",
"version": "1.0.0",
"author": "Your Name Here",
"website": "https://example.com",
Expand Down
88 changes: 52 additions & 36 deletions cmake/common/bootstrap.cmake
Original file line number Diff line number Diff line change
@@ -1,72 +1,88 @@
cmake_minimum_required(VERSION 3.16...3.26)
# Plugin bootstrap module

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()
# Map fallback configurations for optimized build configurations
# gersemi: off
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
""
)
# gersemi: on

# Prohibit in-source builds
if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds are not supported. "
"Specify a build directory via 'cmake -S <SOURCE DIRECTORY> -B <BUILD_DIRECTORY>' instead.")
message(
FATAL_ERROR
"In-source builds are not supported. "
"Specify a build directory via 'cmake -S <SOURCE DIRECTORY> -B <BUILD_DIRECTORY>' instead."
)
file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" "${CMAKE_CURRENT_SOURCE_DIR}/CMakeFiles")
endif()

# Use folders for source file organization with IDE generators (Visual Studio/Xcode)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Add common module directories to default search path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common")

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)

# cmake-format: off
string(JSON _name GET ${buildspec} name)
string(JSON _website GET ${buildspec} website)
string(JSON _author GET ${buildspec} author)
string(JSON _email GET ${buildspec} email)
string(JSON _version GET ${buildspec} version)
string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId)
string(JSON _windowsAppUUID GET ${buildspec} uuids windowsApp)
# cmake-format: on

set(PLUGIN_AUTHOR ${_author})
set(PLUGIN_WEBSITE ${_website})
set(PLUGIN_EMAIL ${_email})
set(PLUGIN_VERSION ${_version})
set(MACOS_BUNDLEID ${_bundleId})

string(REPLACE "." ";" _version_canonical "${_version}")
list(GET _version_canonical 0 PLUGIN_VERSION_MAJOR)
list(GET _version_canonical 1 PLUGIN_VERSION_MINOR)
list(GET _version_canonical 2 PLUGIN_VERSION_PATCH)
unset(_version_canonical)

include(buildnumber)
include(osconfig)

# Allow selection of common build types via UI
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
if(NOT CMAKE_GENERATOR MATCHES "(Xcode|Visual Studio .+)")
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)
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
Expand Down
Loading

0 comments on commit b16a53a

Please sign in to comment.