|
1 | 1 | cmake_minimum_required(VERSION 3.20)
|
2 | 2 | project(cl-webview-win LANGUAGES C CXX)
|
3 | 3 |
|
4 |
| -# x64 前提 |
5 | 4 | if (NOT MSVC OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
6 | 5 | message(FATAL_ERROR "This build expects MSVC on 64-bit (x64) Windows.")
|
7 | 6 | endif()
|
8 | 7 |
|
9 | 8 | set(CMAKE_C_STANDARD 11)
|
10 | 9 | set(CMAKE_CXX_STANDARD 17)
|
11 |
| -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) |
12 | 10 |
|
13 | 11 | include(FetchContent)
|
14 |
| -# 上流 webview を取得(必要に応じてタグ固定) |
| 12 | + |
| 13 | +# upstream を取得(必要ならタグは調整) |
15 | 14 | FetchContent_Declare(
|
16 | 15 | webview
|
17 | 16 | GIT_REPOSITORY https://github.com/webview/webview
|
18 | 17 | GIT_TAG 0.12.0
|
19 | 18 | )
|
20 |
| -FetchContent_MakeAvailable(webview) |
21 |
| - |
22 |
| -# C API を DLL 化(CFFI からロードする想定) |
23 |
| -add_library(webview SHARED) |
24 |
| - |
25 |
| -# 上流の C API 実装(パスは上流リポ構成に追従) |
26 |
| -target_sources(webview PRIVATE |
27 |
| - ${webview_SOURCE_DIR}/webview/webview_capi.cpp |
28 |
| -) |
29 | 19 |
|
30 |
| -# 上流のコアにリンク |
31 |
| -target_link_libraries(webview PRIVATE webview::core) |
| 20 | +# upstream のビルドを有効化(共有ライブラリを作る) |
| 21 | +set(WEBVIEW_BUILD ON CACHE BOOL "" FORCE) |
| 22 | +set(WEBVIEW_BUILD_SHARED_LIBRARY ON CACHE BOOL "" FORCE) |
| 23 | +set(WEBVIEW_BUILD_STATIC_LIBRARY OFF CACHE BOOL "" FORCE) |
| 24 | +# 公式 WebView2 Loader DLL に頼らない最小実装(既定で ON だが明示しておく) |
| 25 | +set(WEBVIEW_USE_BUILTIN_MSWEBVIEW2 ON CACHE BOOL "" FORCE) |
32 | 26 |
|
33 |
| -# 必要に応じて DLL 名を固定したい場合は有効化 |
34 |
| -# set_target_properties(webview PROPERTIES OUTPUT_NAME "libwebview") |
| 27 | +FetchContent_MakeAvailable(webview) |
35 | 28 |
|
36 |
| -# 出力先 |
37 |
| -set_target_properties(webview PROPERTIES |
38 |
| - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
39 |
| - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" |
40 |
| - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 29 | +# 生成物を取り出しやすい場所へコピーするターゲット |
| 30 | +add_custom_target(stage ALL |
| 31 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/dist |
| 32 | + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:webview::core_shared> ${CMAKE_BINARY_DIR}/dist/webview.dll |
| 33 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_LINKER_FILE:webview::core_shared> ${CMAKE_BINARY_DIR}/dist/webview.lib |
| 34 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_PDB_FILE:webview::core_shared> ${CMAKE_BINARY_DIR}/dist/webview.pdb |
| 35 | + DEPENDS webview::core_shared |
41 | 36 | )
|
42 | 37 |
|
43 |
| -if (MSVC) |
44 |
| - target_compile_definitions(webview PRIVATE -DUNICODE -D_UNICODE) |
45 |
| - # 静的ランタイム (/MT) にしたい場合は以下を有効化 |
46 |
| - # foreach(flag_var CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE) |
47 |
| - # string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") |
48 |
| - # endforeach() |
49 |
| -endif() |
50 |
| - |
51 |
| -target_compile_definitions(webview PRIVATE WEBVIEW_LISP_BINDING=1) |
| 38 | +# 必要なら DLL 名を固定(BUILD.md に合わせて) |
| 39 | +# set_target_properties(webview::core_shared PROPERTIES OUTPUT_NAME "libwebview") |
0 commit comments