-
-
Notifications
You must be signed in to change notification settings - Fork 251
/
CMakeLists.txt
195 lines (167 loc) · 6.36 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
cmake_minimum_required(VERSION 3.16...3.26)
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)
project(${_name} VERSION ${_version})
option(ENABLE_FRONTEND_API "Use obs-frontend-api for UI functionality" ON)
option(ENABLE_QT "Use Qt functionality" ON)
include(compilerconfig)
include(defaults)
include(helpers)
add_library(${CMAKE_PROJECT_NAME} MODULE)
add_subdirectory(deps)
# SDL2 headers clash with obs simd stuff for some reason
if (NOT DISABLE_NATIVE_ARCH)
set(CMAKE_CXX_FLAGS "-march=native")
endif()
if (WIN32 OR WIN64)
# Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL when building with VS2019)
if (MSVC)
add_definitions(/MP /d2FH4-)
endif()
# Copy dependencies
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SDL2_DLLS}
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
install(FILES ${SDL2_DLLS} DESTINATION
CONFIGURATIONS RelWithDebInfo Debug Release
DESTINATION obs-plugins/64bit
)
endif()
string(TIMESTAMP TODAY "%Y.%m.%d %H:%M")
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Get the latest commit hash
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
target_compile_definitions(${PROJECT_NAME} PUBLIC
GIT_BRANCH="${GIT_BRANCH}"
GIT_COMMIT_HASH="${GIT_COMMIT_HASH}"
PLUGIN_VERSION="${_version}"
BUILD_TIME="${TODAY}"
)
find_package(libobs REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs)
find_package(obs-frontend-api REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
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>)
set_target_properties(
${CMAKE_PROJECT_NAME}
PROPERTIES AUTOMOC ON
AUTOUIC ON)
if (MSVC)
set(input-overlay_PLATFORM_SOURCES
src/util/window_helper_win.cpp
src/hook/uiohook_helper_win.cpp)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(input-overlay_PLATFORM_DEPS
ws2_32
iphlpapi)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(input-overlay_PLATFORM_DEPS
wsock32
iphlpapi)
endif()
elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
add_definitions(-DLINUX=1)
add_definitions(-DUNIX=1)
set(input-overlay_PLATFORM_SOURCES
src/util/window_helper_nix.cpp
src/hook/uiohook_helper_linux.cpp)
endif()
if (LOCAL_INSTALLATION)
if (UNIX AND NOT APPLE)
# Installs into home directory
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
# Copy to obs-studio dev environment for immediate testing
COMMAND "${CMAKE_COMMAND}" -E make_directory
"$ENV{HOME}/.config/obs-studio/plugins/${CMAKE_PROJECT_NAME}/bin/64bit"
COMMAND "${CMAKE_COMMAND}" -E make_directory
"$ENV{HOME}/.config/obs-studio/plugins/${CMAKE_PROJECT_NAME}/data"
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${CMAKE_PROJECT_NAME}>"
"$ENV{HOME}/.config/obs-studio/plugins/${CMAKE_PROJECT_NAME}/bin/64bit"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/data"
"$ENV{HOME}/.config/obs-studio/plugins/${CMAKE_PROJECT_NAME}/data"
)
endif()
endif()
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
${input-overlay_PLATFORM_DEPS}
${SDL2_LIBRARIES}
uiohook_static
)
target_include_directories(
${CMAKE_PROJECT_NAME}
PRIVATE
${SDL2_INCLUDE_DIRS}
${COMMON_HEADERS}
${JSON_11_HEADER}
${UIOHOOK_INCLUDE_DIR}
${MONGOOSE_INCLUDE_DIR}
)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE src)
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
src/input_overlay.cpp
src/sources/input_source.cpp
src/sources/input_source.hpp
src/sources/input_source.cpp
src/hook/sdl_gamepad.hpp
src/hook/sdl_gamepad.cpp
src/hook/uiohook_helper.hpp
src/hook/gamepad_hook_helper.hpp
src/hook/gamepad_hook_helper.cpp
src/gui/io_settings_dialog.cpp
src/gui/io_settings_dialog.hpp
src/util/obs_util.cpp
src/util/obs_util.hpp
src/util/overlay.cpp
src/util/overlay.hpp
src/util/element/element.cpp
src/util/element/element.hpp
src/util/element/element_texture.cpp
src/util/element/element_texture.hpp
src/util/element/element_button.cpp
src/util/element/element_button.hpp
src/util/element/element_mouse_wheel.cpp
src/util/element/element_mouse_wheel.hpp
src/util/element/element_trigger.cpp
src/util/element/element_trigger.hpp
src/util/element/element_analog_stick.cpp
src/util/element/element_analog_stick.hpp
src/util/element/element_gamepad_id.cpp
src/util/element/element_gamepad_id.hpp
src/util/element/element_mouse_movement.cpp
src/util/element/element_mouse_movement.hpp
src/util/element/element_dpad.cpp
src/util/element/element_dpad.hpp
src/network/remote_connection.cpp
src/network/remote_connection.hpp
src/network/mg.cpp
src/network/mg.hpp
src/util/config.cpp
src/util/config.hpp
src/util/input_filter.cpp
src/util/input_filter.hpp
src/util/log.h
src/util/settings.h
src/util/lang.h src/network/websocket_server.hpp
src/network/websocket_server.cpp
src/gui/io_settings_dialog.ui
${input-overlay_PLATFORM_SOURCES}
${COMMON_HEADERS}/input_data.cpp
${MONGOOSE_SOURCE})
set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
configure_file(src/plugin-macros.h.in ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)