1
- cmake_minimum_required (VERSION 3.5 )
1
+ cmake_minimum_required (VERSION 3.16 )
2
+
3
+ # Change obs-plugintemplate to your plugin's name in a machine-readable format
4
+ # (e.g.: obs-myawesomeplugin) and set
2
5
project (obs-midi VERSION 0.9.0 )
3
- set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR} " external )
4
- set (CMAKE_INCLUDE_CURRENT_DIR TRUE )
5
-
6
- set (CMAKE_PREFIX_PATH "${QTDIR} " )
7
- set (CMAKE_INCLUDE_CURRENT_DIR ON )
8
- set (CMAKE_AUTOMOC ON )
9
- set (CMAKE_AUTOUIC ON )
10
- set (CMAKE_CXX_STANDARD 17 )
11
- set (CMAKE_CXX_STANDARD_REQUIRED ON )
12
- add_definitions (-DASIO_STANDALONE )
13
-
14
- if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" )
15
- set (CMAKE_CXX_FLAGS "-mfpu=neon" )
16
- endif ()
17
- ##################
18
- # THE GOOD STUFF #
19
- ##################
20
- # RTMIDI
21
- add_subdirectory (src/libremidi )
22
- set (obs-midi_DEPS libremidi )
23
- include_directories (src/libremidi )
24
- include_directories (SYSTEM "${CMAKE_SOURCE_DIR} /UI/obs-frontend-api" )
25
- include_directories (${CMAKE_PACKAGE_PREFIX} )
6
+ add_library (${CMAKE_PROJECT_NAME} MODULE )
26
7
27
- if (((WIN32 ) AND (NOT COMMAND install_obs_plugin_with_data )) OR APPLE )
28
- include (external/FindLibObs.cmake )
29
- find_package (LibObs REQUIRED )
30
- else ()
31
- find_package (LibObs )
32
- endif ()
8
+ # Replace `Your Name Here` with the name (yours or your organization's) you want
9
+ # to see as the author of the plugin (in the plugin's metadata itself and in the installers)
10
+ set (PLUGIN_AUTHOR "Chris Yarger <cpyarger@gmail.com>" )
33
11
34
- find_package (Qt5 REQUIRED COMPONENTS Core Widgets )
35
- # Version bits
36
- execute_process (
37
- COMMAND git describe --abbrev=0 --tags
38
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
39
- OUTPUT_VARIABLE GIT_TAG
40
- OUTPUT_STRIP_TRAILING_WHITESPACE
41
- )
42
- configure_file (
43
- ${CMAKE_CURRENT_SOURCE_DIR} /include/version.h.in
44
- ${CMAKE_CURRENT_SOURCE_DIR} /src/version.h
45
- )
46
-
47
- include_directories (
48
- "${LIBOBS_INCLUDE_DIR} /../UI/obs-frontend-api"
49
- SYSTEM
50
- ${Qt5Core_INCLUDES}
51
- ${Qt5Widgets_INCLUDES}
52
- "${CMAKE_SOURCE_DIR} /UI" )
53
- set (obs-midi_SOURCES
54
- src/utils.cpp
55
- src/config.cpp
56
- src/midi-agent.cpp
57
- src/device-manager.cpp
58
- src/obs-controller.cpp
59
- src/forms/settings-dialog.cpp
60
- src/obs-midi.cpp
61
- src/events.cpp
62
- src/rpc/RpcEvent.cpp
63
- src/forms/Macros.cpp
64
- src/Midi_hook.cpp
65
- src/Midi_message.cpp )
66
-
67
- list (APPEND obs-midi_HEADERS
12
+ # Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS releases
13
+ # (used both in the installer and when submitting the installer for notarization)
14
+ set (MACOS_BUNDLEID "com.example.obs-midi" )
15
+
16
+ # Replace `me@contoso.com` with the maintainer email address you want to put in Linux packages
17
+ set (LINUX_MAINTAINER_EMAIL "cpyarger@gmail.com" )
18
+
19
+ # Add your custom source files here - header files are optional and only required for visibility
20
+ # e.g. in Xcode or Visual Studio
21
+ add_subdirectory (src/libremidi )
22
+ include_directories (src/libremidi )
23
+ target_sources (${CMAKE_PROJECT_NAME}
24
+ PRIVATE
25
+ src/utils.cpp
26
+ src/config.cpp
27
+ src/midi-agent.cpp
28
+ src/device-manager.cpp
29
+ src/obs-controller.cpp
30
+ src/forms/settings-dialog.cpp
31
+ src/obs-midi.cpp
32
+ src/events.cpp
33
+ src/rpc/RpcEvent.cpp
34
+ src/forms/Macros.cpp
35
+ src/Midi_hook.cpp
36
+ src/Midi_message.cpp )
37
+ target_sources (${CMAKE_PROJECT_NAME}
38
+ PRIVATE
68
39
src/utils.h
69
40
src/config.h
70
41
src/midi-agent.h
@@ -79,159 +50,100 @@ list(APPEND obs-midi_HEADERS
79
50
src/Midi_hook.h
80
51
src/Midi_message.h )
81
52
82
- qt5_wrap_ui (obs_midi_UI_HEADERS src/forms/settings-dialog.ui )
83
-
84
- add_library (obs-midi MODULE
85
- ${obs-midi_SOURCES}
86
- ${obs_midi_UI_HEADERS}
87
- ${obs-midi_HEADERS}
88
- src/forms/settings-dialog.ui )
89
- include_directories (
90
- "${LIBOBS_INCLUDE_DIR} /../UI/obs-frontend-api"
91
- ${obs_midi_UI_HEADERS}
92
- ${Qt5Core_INCLUDES}
93
- ${Qt5Widgets_INCLUDES}
94
- "${CMAKE_SOURCE_DIR} /deps/asio/asio/include" )
95
- if (LINUX )
96
- include_directories (/usr/include/obs )
97
- target_link_libraries (obs-midi
98
- obs-frontend-api
99
- ${obs-midi_DEPS}
100
- Qt5::Core
101
- Qt5::Widgets
102
- libobs.so )
103
- elseif (NOT DEFINED OBS_FRONTEND_LIB )
104
- target_link_libraries (obs-midi
105
- obs-frontend-api
106
- ${obs-midi_DEPS}
107
- Qt5::Core
108
- Qt5::Widgets
109
- libobs )
110
- else ()
111
- target_link_libraries (obs-midi
112
- "${OBS_FRONTEND_LIB} "
113
- ${obs-midi_DEPS}
53
+ # /!\ TAKE NOTE: No need to edit things past this point /!\
54
+
55
+ find_package (libobs REQUIRED )
56
+ find_package (obs-frontend-api REQUIRED )
57
+ include (external/ObsPluginHelpers.cmake )
58
+ find_package (Qt5Core REQUIRED )
59
+ find_package (Qt5Widgets REQUIRED )
60
+
61
+
62
+
63
+
64
+ # --- Platform-independent build settings ---
65
+
66
+ target_include_directories (${CMAKE_PROJECT_NAME}
67
+ PRIVATE ${CMAKE_SOURCE_DIR} /src )
68
+
69
+ target_link_libraries (${CMAKE_PROJECT_NAME}
70
+ PRIVATE
71
+ libremidi
72
+ OBS::libobs
73
+ OBS::obs-frontend-api
114
74
Qt5::Core
115
- Qt5::Widgets
116
- libobs )
117
- endif ()
75
+ Qt5::Widgets )
76
+
77
+ set_target_properties (${CMAKE_PROJECT_NAME} PROPERTIES
78
+ AUTOMOC ON
79
+ AUTOUIC ON
80
+ AUTORCC ON )
81
+
82
+ target_compile_features (${CMAKE_PROJECT_NAME}
83
+ PRIVATE
84
+ cxx_std_17 )
85
+
86
+ # --- End of section ---
87
+
118
88
# --- Windows-specific build settings and tasks ---
119
- if (WIN32 )
120
-
121
- if (MSVC )
122
- # Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL)
123
- add_definitions (/MP /d2FH4- )
124
- endif ()
125
- add_definitions (-D_WEBSOCKETPP_CPP11_STL_ )
126
- if (CMAKE_SIZEOF_VOID_P EQUAL 8 )
127
- set (ARCH_NAME "64bit" )
128
- set (OBS_BUILDDIR_ARCH "build64" )
129
- else ()
130
- set (ARCH_NAME "32bit" )
131
- set (OBS_BUILDDIR_ARCH "build32" )
132
- endif ()
133
- include_directories (
134
- "${LIBOBS_INCLUDE_DIR} /../${OBS_BUILDDIR_ARCH} /UI"
135
- )
136
- if (NOT DEFINED OBS_FRONTEND_LIB )
137
- target_link_libraries (obs-midi
138
- obs-frontend-api )
139
- else ()
140
- target_link_libraries (obs-midi
141
- "${OBS_FRONTEND_LIB} " )
89
+ if (OS_WINDOWS )
90
+ configure_file (
91
+ installer/installer-Windows.iss.in
92
+ ${CMAKE_SOURCE_DIR} /installer/installer-Windows.generated.iss )
93
+
94
+ configure_file (
95
+ CI/include/build_environment.ps1.in
96
+ ${CMAKE_SOURCE_DIR} /CI/include/build_environment.ps1 )
97
+
98
+ if (MSVC )
99
+ target_compile_options (${CMAKE_PROJECT_NAME}
100
+ PRIVATE
101
+ /MP
102
+ /d2FH4- )
142
103
endif ()
104
+ # --- End of section ---
105
+
106
+ # -- macOS specific build settings and tasks --
107
+ elseif (OS_MACOS )
108
+ configure_file (
109
+ bundle /installer-macOS.pkgproj.in
110
+ ${CMAKE_SOURCE_DIR} /bundle/installer-macOS.generated.pkgproj )
143
111
144
- # --- Release package helper ---
145
- # The "release" folder has a structure similar OBS' one on Windows
146
- set (RELEASE_DIR "${PROJECT_SOURCE_DIR} /release" )
147
- add_custom_command (TARGET obs-midi POST_BUILD
148
- # If config is Release, package release files
149
- COMMAND if $< CONFIG:Release> ==1 (
150
- "${CMAKE_COMMAND} " -E make_directory
151
- "${RELEASE_DIR} /data/obs-plugins/obs-midi"
152
- "${RELEASE_DIR} /obs-plugins/${ARCH_NAME} " )
153
- COMMAND if $< CONFIG:Release> ==1 ("${CMAKE_COMMAND} " -E copy_directory
154
- "${PROJECT_SOURCE_DIR} /data"
155
- "${RELEASE_DIR} /data/obs-plugins/obs-midi" )
156
- COMMAND if $< CONFIG:Release> ==1 ("${CMAKE_COMMAND} " -E copy
157
- "$<TARGET_FILE:obs-midi>"
158
- "${RELEASE_DIR} /obs-plugins/${ARCH_NAME} " )
159
- # If config is RelWithDebInfo, package release files
160
- COMMAND if $< CONFIG:RelWithDebInfo> ==1 (
161
- "${CMAKE_COMMAND} " -E make_directory
162
- "${RELEASE_DIR} /data/obs-plugins/obs-midi"
163
- "${RELEASE_DIR} /obs-plugins/${ARCH_NAME} " )
164
- COMMAND if $< CONFIG:RelWithDebInfo> ==1 ("${CMAKE_COMMAND} " -E copy_directory
165
- "${PROJECT_SOURCE_DIR} /data"
166
- "${RELEASE_DIR} /data/obs-plugins/obs-midi" )
167
- COMMAND if $< CONFIG:RelWithDebInfo> ==1 ("${CMAKE_COMMAND} " -E copy
168
- "$<TARGET_FILE:obs-midi>"
169
- "${RELEASE_DIR} /obs-plugins/${ARCH_NAME} " )
170
- COMMAND if $< CONFIG:RelWithDebInfo> ==1 ("${CMAKE_COMMAND} " -E copy
171
- "$<TARGET_PDB_FILE:obs-midi>"
172
- "${RELEASE_DIR} /obs-plugins/${ARCH_NAME} " )
173
- # Copy to obs-studio dev environment for immediate testing
174
- COMMAND if $< CONFIG:Debug> ==1 (
175
- "${CMAKE_COMMAND} " -E copy
176
- "$<TARGET_FILE:obs-midi>"
177
- "${LibObs_DIR} /../rundir/$<CONFIG>/obs-plugins/${ARCH_NAME} " )
178
- COMMAND if $< CONFIG:Debug> ==1 (
179
- "${CMAKE_COMMAND} " -E copy
180
- "$<TARGET_PDB_FILE:obs-midi>"
181
- "${LibObs_DIR} /../rundir/$<CONFIG>/obs-plugins/${ARCH_NAME} " )
182
- COMMAND if $< CONFIG:Debug> ==1 (
183
- "${CMAKE_COMMAND} " -E copy_directory
184
- "${PROJECT_SOURCE_DIR} /data"
185
- "${LibObs_DIR} /../rundir/$<CONFIG>/data/obs-plugins/${ARCH_NAME} " )
112
+ configure_file (
113
+ CI/include/build_environment.sh.in
114
+ ${CMAKE_SOURCE_DIR} /CI/include/build_environment.sh
186
115
)
187
- # --- End of sub-section ---
188
- endif ()
116
+
117
+ set (MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID} " )
118
+ set (MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION} " )
119
+ set (MACOSX_PLUGIN_SHORT_VERSION_STRING "1" )
120
+
121
+ target_compile_options (${CMAKE_PROJECT_NAME}
122
+ PRIVATE
123
+ -Wall
124
+ -Wextra
125
+ -Werror-implicit-function-declaration
126
+ -stdlib=libc++
127
+ -fvisibility=default )
128
+
129
+ set_target_properties (${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "" )
189
130
# --- End of section ---
131
+
190
132
# --- Linux-specific build settings and tasks ---
191
- if (UNIX AND NOT APPLE )
192
- include (GNUInstallDirs )
193
- set_target_properties (obs-midi PROPERTIES PREFIX "" )
194
- target_link_libraries (obs-midi obs-frontend-api )
195
-
196
- file (GLOB locale_files data/locale/*.ini )
197
- set (CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
198
- OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
199
- find_program (LSB_RELEASE_EXEC lsb_release )
200
- execute_process (COMMAND ${LSB_RELEASE_EXEC} -is
201
- OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
202
- OUTPUT_STRIP_TRAILING_WHITESPACE
133
+ else ()
134
+ configure_file (
135
+ CI/include/build_environment.sh.in
136
+ ${CMAKE_SOURCE_DIR} /CI/include/build_environment.sh
203
137
)
204
- if (COMMAND install_obs_plugin_with_data )
205
- message (STATUS "in tree mode" )
206
- elseif (${LSB_RELEASE_ID_SHORT} STREQUAL "Ubuntu" )
207
- install (TARGETS obs-midi LIBRARY
208
- DESTINATION "/usr/lib/obs-plugins"
209
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ )
210
- endif ()
211
- install (TARGETS obs-midi LIBRARY
212
- DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR} /obs-plugins"
213
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ )
214
- install (FILES ${locale_files}
215
- DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR} /obs/obs-plugins/obs-midi/locale" )
138
+
139
+ target_compile_options (${CMAKE_PROJECT_NAME}
140
+ PRIVATE
141
+ -Wall
142
+ -Wextra )
143
+
144
+ set_target_properties (${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "" )
216
145
endif ()
217
146
# --- End of section ---
218
- # -- OS X specific build settings and tasks --
219
- if (APPLE )
220
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=default" )
221
- set (CMAKE_SKIP_RPATH TRUE )
222
- set_target_properties (obs-midi PROPERTIES PREFIX "" )
223
- if (NOT DEFINED OBS_FRONTEND_LIB )
224
- target_link_libraries (obs-midi
225
- obs-frontend-api )
226
- else ()
227
- target_link_libraries (obs-midi
228
- "${OBS_FRONTEND_LIB} " )
229
- endif ()
230
- endif ()
231
- # -- End of section --
232
- if (COMMAND install_obs_plugin_with_data )
233
- install_obs_plugin_with_data (obs-midi data )
234
- endif ()
235
- set_target_properties (obs-midi PROPERTIES FOLDER "plugins/obs-midi" )
236
- #set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/external" ${CMAKE_MODULE_PATH})
147
+
148
+ setup_plugin_target (${CMAKE_PROJECT_NAME} )
237
149
0 commit comments