Skip to content

Commit fc10962

Browse files
committed
cmake: Update CMake files to current state found on obs-studio
1 parent 1f99d40 commit fc10962

24 files changed

+505
-641
lines changed

.github/scripts/build-ubuntu

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,6 @@ ${_usage_host:-}"
204204
local cmake_version
205205
read -r _ _ cmake_version <<< "$(cmake --version)"
206206
207-
if [[ ${CPUTYPE} != ${target##*-} ]] {
208-
if is-at-least 3.21.0 ${cmake_version}; then
209-
cmake_args+=(--toolchain "${project_root}/cmake/linux/toolchains/${target##*-}-linux-gcc.cmake")
210-
else
211-
cmake_args+=(-D"CMAKE_TOOLCHAIN_FILE=${project_root}/cmake/linux/toolchains/${target##*-}-linux-gcc.cmake")
212-
fi
213-
}
214-
215207
cmake_build_args+=(--preset ${_preset}-${target##*-} --config ${config})
216208
if [[ ${generator} == 'Unix Makefiles' ]] {
217209
cmake_build_args+=(--parallel $(( $(nproc) + 1 )))

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.16...3.26)
1+
cmake_minimum_required(VERSION 3.22...3.26)
22

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

@@ -25,13 +25,13 @@ if(ENABLE_QT)
2525
find_package(Qt6 COMPONENTS Widgets Core)
2626
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets)
2727
target_compile_options(
28-
${CMAKE_PROJECT_NAME} PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang>:-Wno-quoted-include-in-framework-header
29-
-Wno-comma>)
28+
${CMAKE_PROJECT_NAME}
29+
PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang>:-Wno-quoted-include-in-framework-header -Wno-comma>
30+
)
3031
set_target_properties(
3132
${CMAKE_PROJECT_NAME}
32-
PROPERTIES AUTOMOC ON
33-
AUTOUIC ON
34-
AUTORCC ON)
33+
PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON
34+
)
3535
endif()
3636

3737
target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-main.c)

CMakePresets.json

Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171
}
7272
},
7373
{
74-
"name": "linux-x86_64",
75-
"displayName": "Linux x86_64",
76-
"description": "Build for Linux x86_64",
74+
"name": "ubuntu-x86_64",
75+
"displayName": "Ubuntu x86_64",
76+
"description": "Build for Ubuntu x86_64",
7777
"inherits": ["template"],
7878
"binaryDir": "${sourceDir}/build_x86_64",
7979
"condition": {
@@ -88,37 +88,10 @@
8888
}
8989
},
9090
{
91-
"name": "linux-ci-x86_64",
92-
"inherits": ["linux-x86_64"],
93-
"displayName": "Linux x86_64 CI build",
94-
"description": "Build for Linux x86_64 on CI",
95-
"cacheVariables": {
96-
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
97-
"CMAKE_COMPILE_WARNING_AS_ERROR": true
98-
}
99-
},
100-
{
101-
"name": "linux-aarch64",
102-
"displayName": "Linux aarch64",
103-
"description": "Build for Linux aarch64",
104-
"inherits": ["template"],
105-
"binaryDir": "${sourceDir}/build_aarch64",
106-
"condition": {
107-
"type": "equals",
108-
"lhs": "${hostSystemName}",
109-
"rhs": "Linux"
110-
},
111-
"generator": "Ninja",
112-
"warnings": {"dev": true, "deprecated": true},
113-
"cacheVariables": {
114-
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
115-
}
116-
},
117-
{
118-
"name": "linux-ci-aarch64",
119-
"inherits": ["linux-aarch64"],
120-
"displayName": "Linux aarch64 CI build",
121-
"description": "Build for Linux aarch64 on CI",
91+
"name": "ubuntu-ci-x86_64",
92+
"inherits": ["ubuntu-x86_64"],
93+
"displayName": "Ubuntu x86_64 CI build",
94+
"description": "Build for Ubuntu x86_64 on CI",
12295
"cacheVariables": {
12396
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
12497
"CMAKE_COMPILE_WARNING_AS_ERROR": true
@@ -155,31 +128,17 @@
155128
"configuration": "RelWithDebInfo"
156129
},
157130
{
158-
"name": "linux-x86_64",
159-
"configurePreset": "linux-x86_64",
160-
"displayName": "Linux x86_64",
161-
"description": "Linux build for x86_64",
162-
"configuration": "RelWithDebInfo"
163-
},
164-
{
165-
"name": "linux-ci-x86_64",
166-
"configurePreset": "linux-ci-x86_64",
167-
"displayName": "Linux x86_64 CI",
168-
"description": "Linux CI build for x86_64",
169-
"configuration": "RelWithDebInfo"
170-
},
171-
{
172-
"name": "linux-aarch64",
173-
"configurePreset": "linux-aarch64",
174-
"displayName": "Linux aarch64",
175-
"description": "Linux build for aarch64",
131+
"name": "ubuntu-x86_64",
132+
"configurePreset": "ubuntu-x86_64",
133+
"displayName": "Ubuntu x86_64",
134+
"description": "Ubuntu build for x86_64",
176135
"configuration": "RelWithDebInfo"
177136
},
178137
{
179-
"name": "linux-ci-aarch64",
180-
"configurePreset": "linux-ci-aarch64",
181-
"displayName": "Linux aarch64 CI",
182-
"description": "Linux CI build for aarch64",
138+
"name": "ubuntu-ci-x86_64",
139+
"configurePreset": "ubuntu-ci-x86_64",
140+
"displayName": "Ubuntu x86_64 CI",
141+
"description": "Ubuntu CI build for x86_64",
183142
"configuration": "RelWithDebInfo"
184143
}
185144
]

buildspec.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
{
22
"dependencies": {
33
"obs-studio": {
4-
"version": "30.1.2",
4+
"version": "30.2.2",
55
"baseUrl": "https://github.com/obsproject/obs-studio/archive/refs/tags",
66
"label": "OBS sources",
77
"hashes": {
8-
"macos": "490bae1c392b3b344b0270afd8cb887da4bc50bd92c0c426e96713c1ccb9701a",
9-
"windows-x64": "c2dd03fa7fd01fad5beafce8f7156da11f9ed9a588373fd40b44a06f4c03b867"
8+
"macos": "ce8c6ae586df17fef6c2473883531291010dfbb8fc1ce20582e23d3c41df41ba",
9+
"windows-x64": "536b58a31c852b7490c3a96546b5b6fc4257f56e63f35a95f11cb5857ebead45"
1010
}
1111
},
1212
"prebuilt": {
13-
"version": "2024-03-19",
13+
"version": "2024-05-08",
1414
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
1515
"label": "Pre-Built obs-deps",
1616
"hashes": {
17-
"macos": "2e9bfb55a5e0e4c1086fa1fda4cf268debfead473089df2aaea80e1c7a3ca7ff",
18-
"windows-x64": "6e86068371526a967e805f6f9903f9407adb683c21820db5f07da8f30d11e998"
17+
"macos": "da3167a3efecfa67dd72e4f2b7964c3456d74c639d4c62aa21ec300ebd5007a8",
18+
"windows-x64": "773c87a0d173125ef2768aaca6f6de64a7d6053213cc9f7d3970a301152042d8"
1919
}
2020
},
2121
"qt6": {
22-
"version": "2024-03-19",
22+
"version": "2024-05-08",
2323
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
2424
"label": "Pre-Built Qt6",
2525
"hashes": {
26-
"macos": "694f1e639c017e3b1f456f735330dc5afae287cbea85757101af1368de3142c8",
27-
"windows-x64": "72d1df34a0ef7413a681d5fcc88cae81da60adc03dcd23ef17862ab170bcc0dd"
26+
"macos": "248fb342e7ddf574af0960aaedeffb832deda1485dc81583302646e979593a6e",
27+
"windows-x64": "8f459af5115ce081ae24b108712327e113893f250e14a902b1bd188b43873ed1"
2828
},
2929
"debugSymbols": {
30-
"windows-x64": "fbddd1f659c360f2291911ac5709b67b6f8182e6bca519d24712e4f6fd3cc865"
30+
"windows-x64": "e4bc882f23195becbe53f1594fe75bdb9ff4f1d01e319f6caf8e0a38000cb42b"
3131
}
3232
}
3333
},
3434
"platformConfig": {
3535
"macos": {
36-
"bundleId": "com.example.obs-plugintemplate"
36+
"bundleId": "com.example.plugintemplate-for-obs"
3737
}
3838
},
39-
"name": "obs-plugintemplate",
40-
"displayName": "OBS Plugin Template",
39+
"name": "plugintemplate-for-obs",
40+
"displayName": "Plugin Template for OBS",
4141
"version": "1.0.0",
4242
"author": "Your Name Here",
4343
"website": "https://example.com",

cmake/common/bootstrap.cmake

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,41 @@ cmake_minimum_required(VERSION 3.16...3.26)
22

33
include_guard(GLOBAL)
44

5-
# Enable automatic PUSH and POP of policies to parent scope
6-
if(POLICY CMP0011)
7-
cmake_policy(SET CMP0011 NEW)
8-
endif()
9-
10-
# Enable distinction between Clang and AppleClang
11-
if(POLICY CMP0025)
12-
cmake_policy(SET CMP0025 NEW)
13-
endif()
14-
15-
# Enable strict checking of "break()" usage
16-
if(POLICY CMP0055)
17-
cmake_policy(SET CMP0055 NEW)
18-
endif()
19-
20-
# Honor visibility presets for all target types (executable, shared, module, static)
21-
if(POLICY CMP0063)
22-
cmake_policy(SET CMP0063 NEW)
23-
endif()
24-
25-
# Disable export function calls to populate package registry by default
26-
if(POLICY CMP0090)
27-
cmake_policy(SET CMP0090 NEW)
28-
endif()
5+
# Map fallback configurations for optimized build configurations
6+
# gersemi: off
7+
set(
8+
CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO
9+
RelWithDebInfo
10+
Release
11+
MinSizeRel
12+
None
13+
""
14+
)
15+
set(
16+
CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL
17+
MinSizeRel
18+
Release
19+
RelWithDebInfo
20+
None
21+
""
22+
)
23+
set(
24+
CMAKE_MAP_IMPORTED_CONFIG_RELEASE
25+
Release
26+
RelWithDebInfo
27+
MinSizeRel
28+
None
29+
""
30+
)
31+
# gersemi: on
2932

3033
# Prohibit in-source builds
3134
if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
32-
message(FATAL_ERROR "In-source builds are not supported. "
33-
"Specify a build directory via 'cmake -S <SOURCE DIRECTORY> -B <BUILD_DIRECTORY>' instead.")
35+
message(
36+
FATAL_ERROR
37+
"In-source builds are not supported. "
38+
"Specify a build directory via 'cmake -S <SOURCE DIRECTORY> -B <BUILD_DIRECTORY>' instead."
39+
)
3440
file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" "${CMAKE_CURRENT_SOURCE_DIR}/CMakeFiles")
3541
endif()
3642

@@ -42,31 +48,44 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common")
4248

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

45-
# cmake-format: off
4651
string(JSON _name GET ${buildspec} name)
4752
string(JSON _website GET ${buildspec} website)
4853
string(JSON _author GET ${buildspec} author)
4954
string(JSON _email GET ${buildspec} email)
5055
string(JSON _version GET ${buildspec} version)
5156
string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId)
5257
string(JSON _windowsAppUUID GET ${buildspec} uuids windowsApp)
53-
# cmake-format: on
5458

5559
set(PLUGIN_AUTHOR ${_author})
5660
set(PLUGIN_WEBSITE ${_website})
5761
set(PLUGIN_EMAIL ${_email})
5862
set(PLUGIN_VERSION ${_version})
5963
set(MACOS_BUNDLEID ${_bundleId})
6064

65+
string(REPLACE "." ";" _version_canonical "${_version}")
66+
list(GET _version_canonical 0 PLUGIN_VERSION_MAJOR)
67+
list(GET _version_canonical 1 PLUGIN_VERSION_MINOR)
68+
list(GET _version_canonical 2 PLUGIN_VERSION_PATCH)
69+
unset(_version_canonical)
70+
6171
include(buildnumber)
6272
include(osconfig)
6373

6474
# Allow selection of common build types via UI
65-
if(NOT CMAKE_BUILD_TYPE)
66-
set(CMAKE_BUILD_TYPE
75+
if(NOT CMAKE_GENERATOR MATCHES "(Xcode|Visual Studio .+)")
76+
if(NOT CMAKE_BUILD_TYPE)
77+
set(
78+
CMAKE_BUILD_TYPE
6779
"RelWithDebInfo"
68-
CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
69-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
80+
CACHE STRING
81+
"OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]"
82+
FORCE
83+
)
84+
set_property(
85+
CACHE CMAKE_BUILD_TYPE
86+
PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel
87+
)
88+
endif()
7089
endif()
7190

7291
# Disable exports automatically going into the CMake package registry

cmake/common/buildnumber.cmake

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,28 @@
33
include_guard(GLOBAL)
44

55
# Define build number cache file
6-
set(_BUILD_NUMBER_CACHE
7-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/.CMakeBuildNumber"
8-
CACHE INTERNAL "OBS build number cache file")
6+
set(
7+
_BUILD_NUMBER_CACHE
8+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/.CMakeBuildNumber"
9+
CACHE INTERNAL
10+
"OBS build number cache file"
11+
)
912

1013
# Read build number from cache file or manual override
11-
if(NOT DEFINED PLUGIN_BUILD_NUMBER AND EXISTS "${_BUILD_NUMBER_CACHE}")
12-
file(READ "${_BUILD_NUMBER_CACHE}" PLUGIN_BUILD_NUMBER)
13-
math(EXPR PLUGIN_BUILD_NUMBER "${PLUGIN_BUILD_NUMBER}+1")
14-
elseif(NOT DEFINED PLUGIN_BUILD_NUMBER)
15-
if($ENV{CI})
16-
if($ENV{GITHUB_RUN_ID})
17-
set(PLUGIN_BUILD_NUMBER "$ENV{GITHUB_RUN_ID}")
18-
elseif($ENV{GITLAB_RUN_ID})
19-
set(PLUGIN_BUILD_NUMBER "$ENV{GITLAB_RUN_ID}")
20-
else()
21-
set(PLUGIN_BUILD_NUMBER "1")
22-
endif()
14+
if(NOT DEFINED PLUGIN_BUILD_NUMBER)
15+
if(EXISTS "${_BUILD_NUMBER_CACHE}")
16+
file(READ "${_BUILD_NUMBER_CACHE}" PLUGIN_BUILD_NUMBER)
17+
math(EXPR PLUGIN_BUILD_NUMBER "${PLUGIN_BUILD_NUMBER}+1")
2318
else()
24-
set(PLUGIN_BUILD_NUMBER "1")
19+
if("$ENV{CI}")
20+
if("$ENV{GITHUB_RUN_ID}")
21+
set(PLUGIN_BUILD_NUMBER "$ENV{GITHUB_RUN_ID}")
22+
elseif("$ENV{GITLAB_RUN_ID}")
23+
set(PLUGIN_BUILD_NUMBER "$ENV{GITLAB_RUN_ID}")
24+
else()
25+
set(PLUGIN_BUILD_NUMBER "1")
26+
endif()
27+
endif()
2528
endif()
29+
file(WRITE "${_BUILD_NUMBER_CACHE}" "${PLUGIN_BUILD_NUMBER}")
2630
endif()
27-
file(WRITE "${_BUILD_NUMBER_CACHE}" "${PLUGIN_BUILD_NUMBER}")

0 commit comments

Comments
 (0)