-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
105 lines (85 loc) · 3.65 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
cmake_minimum_required(VERSION 3.21.0)
set(CMAKE_CXX_STANDARD 20)
set(ABSL_PROPAGATE_CXX_STD ON)
project(vstwebview)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Third party packages are pulled in via FetchContent
include(FetchContent)
# We don't want VSTGUI to bloat the binary.
set(SMTG_ADD_VSTGUI OFF)
set(SMTG_ADD_VST3_PLUGINS_SAMPLES OFF)
set(SMTG_ADD_VST3_HOSTING_SAMPLES OFF)
# VST3SDK
FetchContent_Declare(
vst3sdk
GIT_REPOSITORY https://github.com/steinbergmedia/vst3sdk.git
GIT_SHALLOW 1
)
FetchContent_MakeAvailable(vst3sdk)
# json
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz)
FetchContent_MakeAvailable(json)
smtg_enable_vst3_sdk()
# Platform specific sources and compile options.
IF (WIN32)
set(WEBVIEW_PLATFORM_SOURCES
src/vstwebview/win32/webview_win32.h
src/vstwebview/win32/webview_win32.cc
src/vstwebview/win32/webview_edge_chromium.h
src/vstwebview/win32/webview_edge_chromium.cc)
# Needed to shut MSVC up about experimental/coroutine and experimental/resumable even though
# we are not directly using them and they're coming through somehow from Edge
add_compile_options(/await)
elseif (UNIX)
if (NOT APPLE)
set(WEBVIEW_PLATFORM_SOURCES src/vstwebview/gtk/webview_gtk.cc)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(WEBKIT2GTK REQUIRED webkit2gtk-4.1)
else()
# TODO any package checking for OSX
add_compile_options(-Wno-suggest-override)
set(WEBVIEW_PLATFORM_SOURCES src/vstwebview/osx/webview_osx.mm)
endif ()
endif ()
add_library(vstwebview
${WEBVIEW_PLATFORM_SOURCES}
src/vstwebview/webview_controller_bindings.cc
src/vstwebview/webview_message_listener.cc
src/vstwebview/webview_pluginview.cc
src/vstwebview/webview.cc)
target_compile_options(vstwebview PUBLIC "$<$<CONFIG:DEBUG>:-DDEVELOPMENT>")
target_compile_options(vstwebview PUBLIC "$<$<CONFIG:RELEASE>:-DRELEASE>")
target_include_directories(vstwebview PRIVATE ./src ${vstsdk_SOURCE_DIR} ${json_SOURCE_DIR}/include)
target_include_directories(vstwebview PUBLIC ./include)
add_dependencies(vstwebview nlohmann_json::nlohmann_json)
# Needed for webview2.h & friends on Win32.
if (WIN32)
option(WIL_BUILD_PACKAGING "" OFF)
option(WIL_BUILD_TESTS "" OFF)
FetchContent_Declare(wil GIT_REPOSITORY "https://github.com/microsoft/wil")
FetchContent_MakeAvailable(wil)
include(NuGet)
nuget_add(WebView2 "Microsoft.Web.WebView2" 1.0.1150.38)
nuget_add(CppWinRT "Microsoft.Windows.CppWinRT" 2.0.220315.1)
target_compile_definitions(vstwebview PRIVATE UNICODE=1 _UNICODE=1)
target_include_directories(vstwebview PRIVATE ${WebView2_PATH}/build/native/include)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_libraries(vstwebview PRIVATE ${WebView2_PATH}/build/native/x64/WebView2LoaderStatic.lib)
else ()
target_link_libraries(vstwebview PRIVATE ${WebView2_PATH}/build/native/x86/WebView2LoaderStatic.lib)
endif ()
target_link_libraries(vstwebview PRIVATE WIL::WIL Dwmapi Shlwapi)
elseif(UNIX)
# GTK on Linux
if (NOT APPLE)
target_include_directories(vstwebview PRIVATE ${GTK3_INCLUDE_DIRS} ${WEBKIT2GTK_INCLUDE_DIRS} ${GTKMM3_INCLUDE_DIRS})
target_link_libraries(vstwebview PRIVATE ${GTK3_LIBRARIES} ${WEBKIT2GTK_LIBRARIES} ${GTKMM3_LIBRARIES})
else()
target_link_libraries(vstwebview "-framework Foundation")
endif()
endif ()
option(BUILD_DEMO "Build demos" OFF)
if(BUILD_DEMO)
add_subdirectory(demo/panner)
endif()