-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
144 lines (114 loc) · 5.86 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
cmake_minimum_required(VERSION 3.16...3.21)
# Change obs-plugintemplate to your plugin's name in a machine-readable format (e.g.:
# obs-myawesomeplugin) and set
project(scrab VERSION 1.2.0)
add_library(${CMAKE_PROJECT_NAME} MODULE)
string(TIMESTAMP TODAY "%Y.%m.%d %H:%M")
add_definitions(-DBUILD_TIME="${TODAY}")
add_definitions(-DSCRAB_VERSION="${PROJECT_VERSION}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/external")
# Replace `Your Name Here` with the name (yours or your organization's) you want to see as the
# author of the plugin (in the plugin's metadata itself and in the installers)
set(PLUGIN_AUTHOR "univrsal")
# Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS releases (used both in
# the installer and when submitting the installer for notarization)
set(MACOS_BUNDLEID "xyz.vrsal.${CMAKE_PROJECT_NAME}")
# Replace `[email protected]` with the maintainer email address you want to put in Linux packages
set(LINUX_MAINTAINER_EMAIL "[email protected]")
option(LOCAL_INSTALLATION "Whether to install for the current user (default: OFF)" OFF)
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
src/screenshot/screenshotgrabber.cpp
src/screenshot/screenshotgrabber.hpp
src/screenshot/screengrabberchooserrectitem.cpp
src/screenshot/screengrabberchooserrectitem.hpp
src/screenshot/toolboxgraphicsitem.cpp
src/screenshot/toolboxgraphicsitem.hpp
src/screenshot/screengrabberoverlayitem.cpp
src/screenshot/screengrabberoverlayitem.hpp
src/scrab.cpp
)
# Import libobs as main plugin dependency
include(cmake/ObsPluginHelpers.cmake)
# Uncomment these lines if you want to use the OBS Frontend API in your plugin
if (LOCAL_INSTALLATION)
if (UNIX AND NOT APPLE)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE "/usr/include/obs")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
find_package(LibObs REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE obs-frontend-api libobs)
# 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"
)
elseif (WIN32)
# Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL when building with VS2019)
if (MSVC)
add_definitions(/MP /d2FH4-)
endif()
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
# Copy to obs-studio dev environment for immediate testing
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${CMAKE_PROJECT_NAME}>"
"${libobs_DIR}/../rundir/$<CONFIG>/obs-plugins/64bit")
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E copy
"$<TARGET_PDB_FILE:${CMAKE_PROJECT_NAME}>"
"${libobs_DIR}/../rundir/$<CONFIG>/obs-plugins/64bit")
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E make_directory
"${libobs_DIR}/../rundir/$<CONFIG>/data/obs-plugins/${CMAKE_PROJECT_NAME}")
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/data"
"${libobs_DIR}/../rundir/$<CONFIG>/data/obs-plugins/${CMAKE_PROJECT_NAME}")
)
endif()
endif()
find_package(libobs REQUIRED)
find_package(obs-frontend-api REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs)
# Uncomment those lines if you want to use Qt in your plugin
find_qt(COMPONENTS Widgets Core)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt::Core Qt::Widgets)
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON)
configure_file(src/plugin-macros.h.in ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-macros.generated.h)
# /!\ TAKE NOTE: No need to edit things past this point /!\
# --- Platform-independent build settings ---
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
# --- End of section ---
# --- Windows-specific build settings and tasks ---
if(OS_WINDOWS)
configure_file(cmake/bundle/windows/installer-Windows.iss.in
${CMAKE_BINARY_DIR}/installer-Windows.generated.iss)
if(MSVC)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W4)
endif()
# --- End of section ---
# -- macOS specific build settings and tasks --
elseif(OS_MACOS)
configure_file(cmake/bundle/macos/installer-macos.pkgproj.in
${CMAKE_BINARY_DIR}/installer-macos.generated.pkgproj)
set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall)
# --- End of section ---
# --- Linux-specific build settings and tasks ---
else()
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall)
endif()
# --- End of section ---
setup_plugin_target(${CMAKE_PROJECT_NAME})