summarylogtreecommitdiffstats
path: root/0001-cmake-Use-system-cef.patch
blob: ca1f020742f0fa58d578fa54f14df1609e1b2e87 (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
From 1de2bf028935c372d95d1aeaa231ed0ac7b5c7e2 Mon Sep 17 00:00:00 2001
From: Zhang Hua <zhanghua.00@qq.com>
Date: Wed, 15 Jul 2026 08:39:39 +0800
Subject: [PATCH 1/6] cmake: Use system cef

---
 CMakeLists.txt             |  2 +-
 deps.json                  | 24 -------------------
 src/Web/CMakeLists.txt     |  4 +---
 third_party/CMakeLists.txt |  8 -------
 viewer/CMakeLists.txt      |  8 +++----
 viewer/WebViewer.cpp       |  4 ++--
 waywallen/CMakeLists.txt   | 49 +-------------------------------------
 waywallen/web_main.cpp     |  4 ++--
 8 files changed, 11 insertions(+), 92 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed28836..cc7670d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,7 +62,7 @@ option(OWE_WAYWALLEN_PLUGIN_BUNDLE_LAYOUT
     OFF)
 
 if(BUILD_WEWEB)
-    include(${CMAKE_SOURCE_DIR}/cmake/CEF.cmake)
+    find_package(CEF 149.0.7827.156 REQUIRED)
 endif()
 
 add_subdirectory(src)
diff --git a/deps.json b/deps.json
index 2bfc643..9881b55 100644
--- a/deps.json
+++ b/deps.json
@@ -78,29 +78,5 @@
       "name": "quickjs",
       "exclude_from_all": true
     }
-  },
-  {
-    "dest": "build/_flatpak_deps/cef-src",
-    "type": "archive",
-    "only-arches": ["x86_64"],
-    "url": "https://cef-builds.spotifycdn.com/cef_binary_149.0.4%2Bg2f1bfd8%2Bchromium-149.0.7827.156_linux64_minimal.tar.bz2",
-    "sha256": "6d43607675e47ed6bfa40d1cfce136d04e7720529f8f1c4435d4ba1dcd1839b2",
-    "x-cmake": {
-      "name": "cef",
-      "exclude_from_all": true,
-      "source_subdir": "cmake-noop"
-    }
-  },
-  {
-    "dest": "build/_flatpak_deps/cef-src",
-    "type": "archive",
-    "only-arches": ["aarch64"],
-    "url": "https://cef-builds.spotifycdn.com/cef_binary_149.0.4%2Bg2f1bfd8%2Bchromium-149.0.7827.156_linuxarm64_minimal.tar.bz2",
-    "sha256": "8909a79689eec7b23ed80084b69766952d44e00f9a345832951b32903f8a80a0",
-    "x-cmake": {
-      "name": "cef",
-      "exclude_from_all": true,
-      "source_subdir": "cmake-noop"
-    }
   }
 ]
diff --git a/src/Web/CMakeLists.txt b/src/Web/CMakeLists.txt
index 38c55f1..39ea4ba 100644
--- a/src/Web/CMakeLists.txt
+++ b/src/Web/CMakeLists.txt
@@ -33,10 +33,8 @@ target_include_directories(owe-web-host PUBLIC .)
 target_link_libraries(owe-web-host
     PUBLIC
         owe-web-api
-        libcef_lib
-        libcef_dll_wrapper)
+        ${CEF_LIBRARIES})
 target_compile_features(owe-web-host PUBLIC cxx_std_20)
-weweb_apply_cef_module_target_settings(owe-web-host)
 set_target_properties(owe-web-host PROPERTIES
     POSITION_INDEPENDENT_CODE ON
     CXX_SCAN_FOR_MODULES ON)
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index b80147e..00adb23 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -53,11 +53,3 @@ target_include_directories(eigen SYSTEM INTERFACE ${eigen_SOURCE_DIR})
 
 # Audio output is handled by wavsen::audio (pulse/pipewire-backed,
 # selectable via WAVSEN_AUDIO_BACKEND in the wavsen subtree).
-
-# Promote CEF source dir to global scope so weweb/cmake/cef.cmake can
-# reach it via add_subdirectory from the project root. fetchdeps()
-# populates `cef_SOURCE_DIR` here in third_party/, but only this scope
-# sees it without an explicit cache.
-if(DEFINED cef_SOURCE_DIR)
-    set(cef_SOURCE_DIR "${cef_SOURCE_DIR}" CACHE INTERNAL "" FORCE)
-endif()
diff --git a/viewer/CMakeLists.txt b/viewer/CMakeLists.txt
index e1d711a..c7bf0fd 100644
--- a/viewer/CMakeLists.txt
+++ b/viewer/CMakeLists.txt
@@ -77,11 +77,11 @@ if(BUILD_WEWEB)
         PkgConfig::GLFW
         Vulkan::Vulkan
         argparse::argparse
-        ${CEF_STANDARD_LIBS})
+        ${CEF_LIBRARIES})
     set_target_properties(WebViewer PROPERTIES
         CXX_SCAN_FOR_MODULES ON
-        BUILD_RPATH   "\$ORIGIN"
-        INSTALL_RPATH "\$ORIGIN"
+        BUILD_RPATH   "\$ORIGIN:\$ORIGIN/..:\$ORIGIN/../cef"
+        INSTALL_RPATH "\$ORIGIN:\$ORIGIN/..:\$ORIGIN/../cef"
         BUILD_WITH_INSTALL_RPATH ON)
-    weweb_stage_cef_runtime(WebViewer)
+    SET_LIBRARY_TARGET_PROPERTIES(WebViewer)
 endif()
diff --git a/viewer/WebViewer.cpp b/viewer/WebViewer.cpp
index 772ce1b..1edcf31 100644
--- a/viewer/WebViewer.cpp
+++ b/viewer/WebViewer.cpp
@@ -167,8 +167,8 @@ int main(int argc, char** argv) {
     auto exe_dir = viewer::ExecutableDir(argv[0]);
 
     weweb::BrowserHost::InitOptions opts;
-    opts.resources_dir = exe_dir;
-    opts.locales_dir   = exe_dir / "locales";
+    opts.resources_dir = std::filesystem::path("/usr/lib/cef");
+    opts.locales_dir   = opts.resources_dir / "locales";
     if (int port = p.get<int>("--remote-debugging-port"); port > 0) {
         opts.enable_remote_debugging = true;
         opts.remote_debugging_port   = port;
diff --git a/waywallen/CMakeLists.txt b/waywallen/CMakeLists.txt
index 343ba50..90c390e 100644
--- a/waywallen/CMakeLists.txt
+++ b/waywallen/CMakeLists.txt
@@ -105,6 +105,7 @@ if(BUILD_WEWEB)
     target_compile_features(waywallen-weweb-renderer PRIVATE cxx_std_20)
     set_target_properties(waywallen-weweb-renderer PROPERTIES
         CXX_SCAN_FOR_MODULES ON
+        INSTALL_RPATH "\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/../lib/cef"
     )
     target_include_directories(waywallen-weweb-renderer
         PRIVATE
@@ -124,44 +125,11 @@ if(BUILD_WEWEB)
             rstd::rstd
             rstd.cppstd
     )
-    weweb_stage_cef_runtime(waywallen-weweb-renderer)
 
     install(TARGETS waywallen-weweb-renderer
         RUNTIME DESTINATION ${_OWE_WEWEB_INSTALL_DIR}
     )
     list(APPEND _OWE_STRIP_FILES ${OWE_WEWEB_BIN})
-    # CEF_BINARY_FILES / CEF_RESOURCE_FILES are basenames; prepend
-    # CEF_BINARY_DIR / CEF_RESOURCE_DIR for absolute paths.
-    #
-    # TODO: make this work with our vulkan stack
-    # Skipped 
-    #   libvulkan.so.1         — Khronos loader CEF ships for its
-    #                            SwiftShader fallback.
-    #   libvk_swiftshader.so   — SwiftShader vulkan ICD; useless when
-    #                            we drop the loader above.
-    #   vk_swiftshader_icd.json — JSON registering the ICD;
-    set(_CEF_SKIP) #libvulkan.so.1 libvk_swiftshader.so vk_swiftshader_icd.json)
-    foreach(_f IN LISTS CEF_BINARY_FILES)
-        if(NOT _f IN_LIST _CEF_SKIP)
-            install(FILES ${CEF_BINARY_DIR}/${_f}
-                DESTINATION ${_OWE_WEWEB_INSTALL_DIR})
-            if(_f STREQUAL "chrome-sandbox" OR _f MATCHES "\\.so(\\.[0-9]+)*$")
-                list(APPEND _OWE_STRIP_FILES ${_OWE_WEWEB_FILES_PREFIX}/${_f})
-            endif()
-        endif()
-    endforeach()
-    # CEF_RESOURCE_FILES contains a `locales` directory entry mixed in
-    # with .pak / .dat files — split per type.
-    foreach(_f IN LISTS CEF_RESOURCE_FILES)
-        if(_f STREQUAL "locales")
-            install(DIRECTORY ${CEF_RESOURCE_DIR}/locales/
-                DESTINATION ${_OWE_WEWEB_INSTALL_DIR}/locales
-                FILES_MATCHING PATTERN "*.pak")
-        else()
-            install(FILES ${CEF_RESOURCE_DIR}/${_f}
-                DESTINATION ${_OWE_WEWEB_INSTALL_DIR})
-        endif()
-    endforeach()
 endif()
 
 # --- Generate the plugin manifest -----------------------------------------
@@ -207,21 +175,6 @@ set(_OWE_FILES
 )
 if(BUILD_WEWEB)
     list(APPEND _OWE_FILES ${OWE_WEWEB_BIN})
-    foreach(_f IN LISTS CEF_BINARY_FILES)
-        if(NOT _f IN_LIST _CEF_SKIP)
-            list(APPEND _OWE_FILES ${_OWE_WEWEB_FILES_PREFIX}/${_f})
-        endif()
-    endforeach()
-    foreach(_f IN LISTS CEF_RESOURCE_FILES)
-        if(_f STREQUAL "locales")
-            file(GLOB _owe_paks RELATIVE ${CEF_RESOURCE_DIR}/locales
-                ${CEF_RESOURCE_DIR}/locales/*.pak)
-            list(TRANSFORM _owe_paks PREPEND "${_OWE_WEWEB_FILES_PREFIX}/locales/")
-            list(APPEND _OWE_FILES ${_owe_paks})
-        else()
-            list(APPEND _OWE_FILES ${_OWE_WEWEB_FILES_PREFIX}/${_f})
-        endif()
-    endforeach()
 endif()
 list(SORT _OWE_FILES)
 string(JOIN "\n" _owe_files_txt ${_OWE_FILES})
diff --git a/waywallen/web_main.cpp b/waywallen/web_main.cpp
index 41be15d..4f668bc 100644
--- a/waywallen/web_main.cpp
+++ b/waywallen/web_main.cpp
@@ -577,8 +577,8 @@ int main(int argc, char** argv) {
     // BrowserHost::Init wants resources / locales relative to argv[0].
     auto                            exe_dir = executable_dir(argv[0]);
     weweb::BrowserHost::InitOptions ho;
-    ho.resources_dir = exe_dir;
-    ho.locales_dir   = exe_dir / "locales";
+    ho.resources_dir = std::filesystem::path("/usr/lib/cef");
+    ho.locales_dir   = ho.resources_dir / "locales";
     ho.cache_dir     = derive_cache_dir(opts.workshop_id);
     if (opts.remote_debugging_port > 0) {
         ho.enable_remote_debugging = true;
-- 
2.55.0