Skip to content

Commit 525cfdb

Browse files
Update build system.
1 parent 68d088e commit 525cfdb

23 files changed

+605
-549
lines changed

CMakeLists.txt

Lines changed: 29 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,51 @@
11
cmake_minimum_required(VERSION 3.16...3.26)
22

3-
# probably best to move this to a seperate file
4-
function(setup_obs_lib_dependency target)
5-
if(BUILD_OUT_OF_TREE)
6-
find_package(libobs)
7-
if(libobs_FOUND AND NOT LIBOBS_LIB)
8-
target_link_libraries(${target} PUBLIC OBS::libobs)
9-
else()
10-
if(NOT LIBOBS_LIB)
11-
message(FATAL_ERROR "obs library not found - please set LIBOBS_LIB")
12-
endif()
13-
target_link_libraries(${target} PUBLIC ${LIBOBS_LIB})
14-
if(NOT LIBOBS_INCLUDE_DIR)
15-
message(FATAL_ERROR "obs.hpp header not found - please set LIBOBS_INCLUDE_DIR")
16-
endif()
17-
target_include_directories(${target} PRIVATE ${LIBOBS_INCLUDE_DIR})
18-
endif()
19-
find_package(obs-frontend-api)
20-
if(obs-frontend-api_FOUND AND NOT LIBOBS_FRONTEND_API_LIB)
21-
target_link_libraries(${target} PUBLIC OBS::obs-frontend-api)
22-
else()
23-
if(NOT LIBOBS_FRONTEND_API_LIB)
24-
message(FATAL_ERROR "libobs frontend-api library not found - please set LIBOBS_FRONTEND_API_LIB")
25-
endif()
26-
target_link_libraries(${target} PUBLIC ${LIBOBS_FRONTEND_API_LIB})
27-
if(NOT LIBOBS_FRONTEND_INCLUDE_DIR)
28-
message(FATAL_ERROR " obs-frontend-api.h not found - please set LIBOBS_FRONTEND_INCLUDE_DIR")
29-
endif()
30-
target_include_directories(${target} PRIVATE ${LIBOBS_FRONTEND_INCLUDE_DIR})
31-
endif()
32-
else()
33-
target_link_libraries(${target} PUBLIC OBS::libobs OBS::frontend-api)
34-
endif()
35-
endfunction()
3+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)
364

37-
project(elgato-marketplace VERSION 0.0.8)
38-
39-
if(${CMAKE_PROJECT_NAME} STREQUAL "obs-studio")
40-
set(OBS_FRONTEND_API_NAME "frontend-api")
41-
if(NOT DEFINED BUILD_OUT_OF_TREE)
42-
message(STATUS "${PROJECT_NAME} configured for in-tree build")
43-
endif()
44-
else()
45-
set(BUILD_OUT_OF_TREE ON)
46-
set(OBS_FRONTEND_API_NAME "obs-frontend-api")
47-
message(STATUS "${PROJECT_NAME} configured for out-of-tree build")
48-
endif()
49-
50-
if(BUILD_OUT_OF_TREE)
51-
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)
52-
include(compilerconfig)
53-
include(defaults)
54-
endif()
55-
include(helpers)
5+
project(${_name} VERSION ${_version})
566

577
option(ENABLE_FRONTEND_API "Use obs-frontend-api for UI functionality" OFF)
588
option(ENABLE_QT "Use Qt functionality" OFF)
599

60-
add_library(${PROJECT_NAME} MODULE)
10+
include(compilerconfig)
11+
include(defaults)
12+
include(helpers)
6113

62-
if(BUILD_OUT_OF_TREE)
63-
find_package(${OBS_FRONTEND_API_NAME} REQUIRED)
64-
endif()
14+
add_library(${CMAKE_PROJECT_NAME} MODULE)
6515

66-
target_link_libraries(${PROJECT_NAME} PRIVATE OBS::${OBS_FRONTEND_API_NAME})
16+
find_package(libobs REQUIRED)
17+
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs)
6718

68-
find_package(Qt6 COMPONENTS Widgets Core Concurrent)
69-
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets Qt6::Concurrent)
70-
target_compile_options(${PROJECT_NAME}
71-
PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang>:-Wno-quoted-include-in-framework-header -Wno-comma>)
19+
if(ENABLE_FRONTEND_API)
20+
find_package(obs-frontend-api REQUIRED)
21+
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
22+
endif()
7223

73-
set_target_properties(
74-
${PROJECT_NAME}
75-
PROPERTIES AUTOMOC ON
76-
AUTOUIC ON
77-
AUTORCC ON)
24+
if(ENABLE_QT)
25+
find_qt(COMPONENTS Widgets Core Concurrent)
26+
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt::Core Qt::Widgets Qt::Concurrent)
27+
target_compile_options(
28+
${CMAKE_PROJECT_NAME} PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang>:-Wno-quoted-include-in-framework-header
29+
-Wno-comma>)
30+
set_target_properties(
31+
${CMAKE_PROJECT_NAME}
32+
PROPERTIES AUTOMOC ON
33+
AUTOUIC ON
34+
AUTORCC ON)
35+
endif()
7836

7937
find_package(CURL REQUIRED)
80-
# find_package(ZLIB REQUIRED)
8138
find_package(nlohmann_json REQUIRED)
8239

83-
target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl nlohmann_json::nlohmann_json)
40+
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE CURL::libcurl nlohmann_json::nlohmann_json)
8441

8542
target_sources(
86-
${PROJECT_NAME}
43+
${CMAKE_PROJECT_NAME}
8744
PRIVATE src/plugin-module.cpp
8845
src/elgato-styles.hpp
8946
src/zip_file.hpp
9047
src/api.cpp
9148
src/api.hpp
92-
src/plugin-support.c
93-
src/plugin-support.h
9449
src/platform.cpp
9550
src/platform.h
9651
src/util.cpp
@@ -123,23 +78,7 @@ target_sources(
12378
src/elgato-widgets.cpp
12479
src/elgato-widgets.hpp)
12580

126-
target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
127-
128-
add_executable(${PROJECT_NAME}-loader loader/main.cpp)
129-
130-
install(TARGETS ${PROJECT_NAME}-loader RUNTIME DESTINATION data/obs-plugins/${PROJECT_NAME})
81+
add_executable(${CMAKE_PROJECT_NAME}-loader loader/main.cpp)
82+
install(TARGETS ${CMAKE_PROJECT_NAME}-loader RUNTIME DESTINATION data/obs-plugins/${CMAKE_PROJECT_NAME})
13183

132-
setup_obs_lib_dependency(${PROJECT_NAME})
133-
if(BUILD_OUT_OF_TREE)
134-
set_target_properties_plugin(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
135-
else()
136-
set_target_properties_obs(${PROJECT_NAME} PROPERTIES FOLDER "plugins/elgato" PREFIX "")
137-
endif()
138-
139-
if(BUILD_OUT_OF_TREE)
140-
if(OS_WINDOWS)
141-
set(OBS_PLUGIN_DESTINATION "obs-plugins/64bit")
142-
else()
143-
set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins")
144-
endif()
145-
endif()
84+
set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})

CMakePresets.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,10 @@
66
"patch": 0
77
},
88
"configurePresets": [
9-
{
10-
"name": "template",
11-
"hidden": true,
12-
"cacheVariables": {
13-
"ENABLE_FRONTEND_API": true,
14-
"ENABLE_QT": true
15-
}
16-
},
179
{
1810
"name": "macos",
1911
"displayName": "macOS Universal",
2012
"description": "Build for macOS 11.0+ (Universal binary)",
21-
"inherits": ["template"],
2213
"binaryDir": "${sourceDir}/build_macos",
2314
"condition": {
2415
"type": "equals",
@@ -28,9 +19,12 @@
2819
"generator": "Xcode",
2920
"warnings": {"dev": true, "deprecated": true},
3021
"cacheVariables": {
22+
"QT_VERSION": "6",
3123
"CMAKE_OSX_DEPLOYMENT_TARGET": "11.0",
3224
"CODESIGN_IDENTITY": "$penv{CODESIGN_IDENT}",
33-
"CODESIGN_TEAM": "$penv{CODESIGN_TEAM}"
25+
"CODESIGN_TEAM": "$penv{CODESIGN_TEAM}",
26+
"ENABLE_FRONTEND_API": true,
27+
"ENABLE_QT": true
3428
}
3529
},
3630
{
@@ -47,7 +41,6 @@
4741
"name": "windows-x64",
4842
"displayName": "Windows x64",
4943
"description": "Build for Windows x64",
50-
"inherits": ["template"],
5144
"binaryDir": "${sourceDir}/build_x64",
5245
"condition": {
5346
"type": "equals",
@@ -58,7 +51,10 @@
5851
"architecture": "x64",
5952
"warnings": {"dev": true, "deprecated": true},
6053
"cacheVariables": {
61-
"CMAKE_SYSTEM_VERSION": "10.0.18363.657"
54+
"QT_VERSION": "6",
55+
"CMAKE_SYSTEM_VERSION": "10.0.18363.657",
56+
"ENABLE_FRONTEND_API": true,
57+
"ENABLE_QT": true
6258
}
6359
},
6460
{
@@ -74,7 +70,6 @@
7470
"name": "linux-x86_64",
7571
"displayName": "Linux x86_64",
7672
"description": "Build for Linux x86_64",
77-
"inherits": ["template"],
7873
"binaryDir": "${sourceDir}/build_x86_64",
7974
"condition": {
8075
"type": "equals",
@@ -84,7 +79,10 @@
8479
"generator": "Ninja",
8580
"warnings": {"dev": true, "deprecated": true},
8681
"cacheVariables": {
87-
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
82+
"QT_VERSION": "6",
83+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
84+
"ENABLE_FRONTEND_API": true,
85+
"ENABLE_QT": true
8886
}
8987
},
9088
{
@@ -101,7 +99,6 @@
10199
"name": "linux-aarch64",
102100
"displayName": "Linux aarch64",
103101
"description": "Build for Linux aarch64",
104-
"inherits": ["template"],
105102
"binaryDir": "${sourceDir}/build_aarch64",
106103
"condition": {
107104
"type": "equals",
@@ -111,7 +108,10 @@
111108
"generator": "Ninja",
112109
"warnings": {"dev": true, "deprecated": true},
113110
"cacheVariables": {
114-
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
111+
"QT_VERSION": "6",
112+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
113+
"ENABLE_FRONTEND_API": false,
114+
"ENABLE_QT": false
115115
}
116116
},
117117
{

build-aux/.run-format.zsh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ invoke_formatter() {
2929

3030
case ${1} {
3131
clang)
32-
if (( ${+commands[clang-format-17]} )) {
33-
local formatter=clang-format-17
32+
if (( ${+commands[clang-format-16]} )) {
33+
local formatter=clang-format-16
3434
} elif (( ${+commands[clang-format]} )) {
3535
local formatter=clang-format
3636
local -a formatter_version=($(clang-format --version))
3737

38-
if ! is-at-least 17.0.3 ${formatter_version[-1]}; then
39-
log_error "clang-format is not version 17.0.3 or above (found ${formatter_version[-1]}."
38+
if ! is-at-least 16.0.5 ${formatter_version[-1]}; then
39+
log_error "clang-format is not version 16.0.5 or above (found ${formatter_version[-1]}."
4040
exit 2
4141
fi
4242

43-
if ! is-at-least ${formatter_version[-1]} 17.0.3; then
44-
log_error "clang-format is more recent than version 17.0.3 (found ${formatter_version[-1]})."
43+
if ! is-at-least ${formatter_version[-1]} 16.0.5; then
44+
log_error "clang-format is more recent than version 16.0.5 (found ${formatter_version[-1]})."
4545
exit 2
4646
fi
4747
} else {
48-
log_error "No viable clang-format version found (required 17.0.3)"
48+
log_error "No viable clang-format version found (required 16.0.5)"
4949
exit 2
5050
}
5151

buildspec.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
"label": "Pre-Built obs-deps",
1616
"hashes": {
1717
"macos": "90c2fc069847ec2768dcc867c1c63b112c615ed845a907dc44acab7a97181974",
18-
"windows-x64": "d0825a6fb65822c993a3059edfba70d72d2e632ef74893588cf12b1f0d329ce6",
19-
"windows-x86": "b69c864275189464483c240ef3f25ea16fba3050b136fe6c3db6e9ee63036683",
20-
"linux-x86_64": "9217c6b70854a08575cc3debe85ed5496bb0d8a9de54a1f8148aa71ad71f98d6"
18+
"windows-x64": "d0825a6fb65822c993a3059edfba70d72d2e632ef74893588cf12b1f0d329ce6"
2119
}
2220
},
2321
"qt6": {
@@ -38,9 +36,10 @@
3836
"bundleId": "com.elgato.marketplace-plugin"
3937
}
4038
},
41-
"name": "elgato-marketplace",
42-
"displayName": "Elgato Marketplace Plugin",
43-
"version": "0.0.8",
39+
"name": "elgato-marketplace-connect",
40+
"displayName": "Elgato Marketplace Connect",
41+
"version": "1.0.0.123",
42+
"releaseLabel": "RC 1",
4443
"author": "Elgato",
4544
"website": "https://elgato.com",
4645
"email": "support@elgato.com",

cmake/common/buildnumber.cmake

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@ if(NOT DEFINED PLUGIN_BUILD_NUMBER AND EXISTS "${_BUILD_NUMBER_CACHE}")
1212
file(READ "${_BUILD_NUMBER_CACHE}" PLUGIN_BUILD_NUMBER)
1313
math(EXPR PLUGIN_BUILD_NUMBER "${PLUGIN_BUILD_NUMBER}+1")
1414
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()
15+
if($ENV{CI} AND $ENV{GITHUB_RUN_ID})
16+
set(PLUGIN_BUILD_NUMBER "$ENV{GITHUB_RUN_ID}")
2317
else()
2418
set(PLUGIN_BUILD_NUMBER "1")
2519
endif()

0 commit comments

Comments
 (0)