-
Notifications
You must be signed in to change notification settings - Fork 57
/
CMakeLists.txt
117 lines (97 loc) · 4.9 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
# The Flutter tooling requires that developers have CMake 3.10 or later
# installed. You should not increase this version, as doing so will cause
# the plugin to fail to compile for some customers of the plugin.
cmake_minimum_required(VERSION 3.10)
#supass warning
cmake_policy(SET CMP0074 NEW)
# Project-level configuration.
set(PROJECT_NAME "webview_cef")
project(${PROJECT_NAME} LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 17)
include(${CMAKE_CURRENT_SOURCE_DIR}/../third/download.cmake)
prepare_prebuilt_files(${CMAKE_CURRENT_SOURCE_DIR}/../third/cef)
set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../third/cef")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")
find_package(CEF REQUIRED)
# This value is used when generating builds using this plugin, so it must
# not be changed.
set(PLUGIN_NAME "webview_cef_plugin")
# Define the plugin library target. Its name must not be changed (see comment
# on PLUGIN_NAME above).
#
# Any new source files that you add to the plugin should be added here.
add_library(${PLUGIN_NAME} SHARED
"webview_cef_plugin.cc"
"webview_cef_keyevent.h"
"webview_cef_texture.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_app.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_app.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_handler.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_handler.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_plugin.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_plugin.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_value.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_value.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_js_handler.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_js_handler.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_cookieVisitor.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_cookieVisitor.h"
)
# Apply a standard set of build settings that are configured in the
# application-level CMakeLists.txt. This can be removed for plugins that want
# full control over build settings.
apply_standard_settings(${PLUGIN_NAME})
# Symbols are hidden by default to reduce the chance of accidental conflicts
# between plugins. This should not be removed; any symbols that should be
# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
set_target_properties(${PLUGIN_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
# Source include directories and library dependencies. Add any plugin-specific
# dependencies here.
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
target_include_directories(${PLUGIN_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../common")
#########################################cef#########################################
set(CEF_TARGET ${PLUGIN_NAME})
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")
SET_CEF_TARGET_OUT_DIR()
add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
# Find required libraries and update compiler/linker variables.
FIND_LINUX_LIBRARIES("gmodule-2.0 gtk+-3.0 gthread-2.0 gtk+-unix-print-3.0 xi")
find_program(XCLIP_EXECUTABLE xclip)
if(NOT XCLIP_EXECUTABLE)
message(AUTHOR_WARNING "xclip executable not found. Users need it to paste text into CEF Area.")
endif()
# Executable target.
# add_executable(${CEF_TARGET} ${CEFCLIENT_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_TARGET} PUBLIC libcef_lib libcef_dll_wrapper "GL" ${CEF_STANDARD_LIBS})
# Set rpath so that libraries can be placed next to the executable.
set_target_properties(${CEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN")
set_target_properties(${CEF_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
set_target_properties(${CEF_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})
# We don't call deprecated GTK functions, and they can cause build failures, so disable them.
add_definitions("-DGTK_DISABLE_DEPRECATED")
# Set SUID permissions on the chrome-sandbox target.
# SET_LINUX_SUID_PERMISSIONS("${CEF_TARGET}" "${CEF_TARGET_OUT_DIR}/chrome-sandbox")
#set CEF binary and resource files which need to copy to the target output directory
set(cef_library_list "")
foreach(FILE ${CEF_BINARY_FILES})
list(APPEND cef_library_list ${CEF_BINARY_DIR}/${FILE})
endforeach()
foreach(FILE ${CEF_RESOURCE_FILES})
list(APPEND cef_library_list ${CEF_RESOURCE_DIR}/${FILE})
endforeach(FILE)
#######################################cef end#######################################
# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
# external build triggered from this build file.
set(webview_cef_bundled_libraries
""
${cef_library_list}
PARENT_SCOPE
)