-
Notifications
You must be signed in to change notification settings - Fork 29
/
CMakeLists.txt
46 lines (40 loc) · 1.56 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
cmake_minimum_required(VERSION 3.11.0)
project(webview VERSION 0.10.0)
set(CMAKE_CXX_STANDARD 17)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT -DWEBVIEW_STATIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd -DWEBVIEW_STATIC")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(PkgConfig REQUIRED)
pkg_check_modules(
gtk3 REQUIRED gtk+-3.0
IMPORTED_TARGET
)
pkg_check_modules(
webkit2 REQUIRED webkit2gtk-4.0
IMPORTED_TARGET
)
set(CMAKE_CXX_FLAGS "-DWEBVIEW_STATIC")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework WebKit -DWEBVIEW_STATIC")
endif()
include(FetchContent)
FetchContent_Declare(
webviewNative
GIT_REPOSITORY https://github.com/webview/webview
GIT_TAG adbb85d0f54537b8034ece0bab67c7d1438e3cda
)
FetchContent_Populate(webviewNative)
include_directories(
"${webviewnative_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/libs/include"
)
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/libs")
add_library(webview SHARED "${webviewnative_SOURCE_DIR}/webview.cc")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
target_compile_definitions(webview PRIVATE "WEBVIEW_API=__declspec(dllexport)")
target_link_libraries(webview WebView2Loader.dll.lib)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libs/WebView2Loader.dll WebView2Loader.dll COPYONLY)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(webview PkgConfig::gtk3 PkgConfig::webkit2)
endif()