forked from sorayuki/obs-multi-rtmp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
150 lines (134 loc) · 4.23 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
cmake_minimum_required(VERSION 3.16)
project(obs-multi-rtmp VERSION 0.2.8.0)
option(PORTABLE_MODE "if obs is used in portable mode" OFF)
set(QTDIR "${QTDIR}" CACHE PATH "Path to qt directory")
list(APPEND CMAKE_PREFIX_PATH "${QTDIR}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
set(LIB_OBS libobs)
# build obs lib
if (WIN32)
# Windows
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(PLAT "32bit")
set(LINK_PLAT "x86")
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLAT "64bit")
set(LINK_PLAT "x64")
else ()
message(FATAL_ERROR "Unsupported Architecture!")
endif ()
if (NOT DEFINED OBS_SRC_DIR)
set(OBS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/obs-src")
endif ()
if (NOT DEFINED OBS_BIN_DIR)
set(OBS_BIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/obs-bin")
endif ()
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if (${PORTABLE_MODE})
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/obs-bin" CACHE PATH "" FORCE)
else ()
set(CMAKE_INSTALL_PREFIX "$ENV{ProgramData}/obs-studio" CACHE PATH "" FORCE)
endif ()
endif ()
execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/pexports.exe"
"${OBS_BIN_DIR}/bin/${PLAT}/obs.dll"
OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/libobs.def"
COMMAND_ECHO STDOUT
)
execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/pexports.exe"
"${OBS_BIN_DIR}/bin/${PLAT}/obs-frontend-api.dll"
OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/obs-frontend-api.def"
COMMAND_ECHO STDOUT
)
execute_process(COMMAND ${CMAKE_LINKER}
"/lib" "/MACHINE:${LINK_PLAT}"
"/def:${CMAKE_CURRENT_BINARY_DIR}/libobs.def"
"/out:${CMAKE_CURRENT_BINARY_DIR}/libobs.lib"
)
execute_process(COMMAND ${CMAKE_LINKER}
"/lib" "/MACHINE:${LINK_PLAT}"
"/def:${CMAKE_CURRENT_BINARY_DIR}/obs-frontend-api.def"
"/out:${CMAKE_CURRENT_BINARY_DIR}/obs-frontend-api.lib"
)
elseif (APPLE)
# macOS
find_library(_LIB_OBS "${LIB_OBS}.0.dylib" PATHS ${OBS_BIN_DIR} REQUIRED)
set(LIB_OBS "${_LIB_OBS}")
elseif (UNIX)
# Linux
find_package(LibObs REQUIRED)
else ()
message(FATAL_ERROR "Unsupported OS!")
endif ()
# build plugin
add_library(obs-multi-rtmp SHARED
"src/obs-multi-rtmp.cpp"
"src/obs-multi-rtmp.h"
"src/edit-widget.cpp"
"src/edit-widget.h"
"src/push-widget.cpp"
"src/push-widget.h"
"src/pch.h"
)
target_precompile_headers(obs-multi-rtmp PRIVATE
"src/pch.h"
)
if (WIN32)
configure_file("src/version.rc.in" "${CMAKE_CURRENT_BINARY_DIR}/version.rc")
target_sources(obs-multi-rtmp PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}/version.rc"
)
endif ()
target_include_directories(obs-multi-rtmp PRIVATE
"${OBS_SRC_DIR}/libobs"
"${OBS_SRC_DIR}/UI/obs-frontend-api"
)
target_link_directories(obs-multi-rtmp PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}"
${OBS_BIN_DIR}
)
target_link_libraries(obs-multi-rtmp PRIVATE
Qt5::Widgets
${LIB_OBS}
obs-frontend-api
)
if (WIN32)
if (${PORTABLE_MODE})
install(TARGETS obs-multi-rtmp RUNTIME
DESTINATION "obs-plugins/${PLAT}"
)
install(DIRECTORY locale
DESTINATION "data/obs-plugins/obs-multi-rtmp"
)
else ()
install(TARGETS obs-multi-rtmp RUNTIME
DESTINATION "plugins/obs-multi-rtmp/bin/${PLAT}"
)
install(DIRECTORY locale
DESTINATION "plugins/obs-multi-rtmp/data"
)
endif ()
elseif (APPLE)
set_target_properties(obs-multi-rtmp PROPERTIES
PREFIX ""
SUFFIX ".so"
)
install(TARGETS obs-multi-rtmp LIBRARY
DESTINATION "obs-studio/plugins/obs-multi-rtmp/bin"
)
install(DIRECTORY locale
DESTINATION "obs-studio/plugins/obs-multi-rtmp/data"
)
elseif (UNIX)
set_target_properties(obs-multi-rtmp PROPERTIES PREFIX "")
install(TARGETS obs-multi-rtmp LIBRARY
DESTINATION "lib/obs-plugins"
)
install(DIRECTORY locale
DESTINATION "share/obs/obs-plugins/obs-multi-rtmp"
)
endif ()