forked from sorayuki/obs-multi-rtmp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
111 lines (99 loc) · 3.14 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
cmake_minimum_required(VERSION 3.16)
project(obs-multi-rtmp VERSION 0.2.4)
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)
# 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)
set(CMAKE_INSTALL_PREFIX "${OBS_BIN_DIR}" CACHE PATH "" FORCE)
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
message(FATAL_ERROR "Unsupported OS!")
elseif (UNIX)
# Linux
find_package(LibObs REQUIRED)
else ()
message(FATAL_ERROR "Unsupported OS!")
endif ()
add_library(obs-multi-rtmp SHARED
"src/obs-multi-rtmp.cpp"
"src/obs-multi-rtmp.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}"
)
target_link_libraries(obs-multi-rtmp PRIVATE
Qt5::Widgets
libobs
obs-frontend-api
)
if (WIN32)
install(TARGETS obs-multi-rtmp RUNTIME
DESTINATION "obs-plugins/${PLAT}"
)
install(DIRECTORY locale
DESTINATION "data/obs-plugins/obs-multi-rtmp"
)
elseif (APPLE)
# not implemented
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 ()