Files
cesiumflutter/windows/CMakeLists.txt
T

53 lines
1.9 KiB
CMake
Raw Normal View History

2026-11-07 15:48:01 +01:00
cmake_minimum_required(VERSION 3.14)
set(PROJECT_NAME "cesiumjs")
project(${PROJECT_NAME} LANGUAGES CXX)
cmake_policy(VERSION 3.14...3.25)
set(PLUGIN_NAME "cesiumjs_plugin")
# --- WebView2 SDK (headers + static loader), fetched from NuGet ------------
set(WEBVIEW2_VERSION "1.0.4314.35")
set(WEBVIEW2_SHA256
"90778deb1b77e36292828b4b5833c9255c27533f40e0ddd55891ae718944edc4")
set(WEBVIEW2_DIR "${CMAKE_BINARY_DIR}/webview2-${WEBVIEW2_VERSION}")
if(NOT EXISTS "${WEBVIEW2_DIR}/build/native/include/WebView2.h")
set(_wv2_pkg "${CMAKE_BINARY_DIR}/webview2-${WEBVIEW2_VERSION}.nupkg")
file(DOWNLOAD
"https://api.nuget.org/v3-flatcontainer/microsoft.web.webview2/${WEBVIEW2_VERSION}/microsoft.web.webview2.${WEBVIEW2_VERSION}.nupkg"
"${_wv2_pkg}"
EXPECTED_HASH SHA256=${WEBVIEW2_SHA256}
TLS_VERIFY ON)
file(ARCHIVE_EXTRACT INPUT "${_wv2_pkg}" DESTINATION "${WEBVIEW2_DIR}")
endif()
if(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64")
set(WEBVIEW2_ARCH "arm64")
else()
set(WEBVIEW2_ARCH "x64")
endif()
add_library(${PLUGIN_NAME} SHARED
"include/cesiumjs/cesiumjs_plugin_c_api.h"
"cesiumjs_plugin.cpp"
)
apply_standard_settings(${PLUGIN_NAME})
set_target_properties(${PLUGIN_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(${PLUGIN_NAME} PRIVATE
"${WEBVIEW2_DIR}/build/native/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE
flutter flutter_wrapper_plugin
"${WEBVIEW2_DIR}/build/native/${WEBVIEW2_ARCH}/WebView2LoaderStatic.lib"
shlwapi version)
# The loader is linked statically: nothing to bundle. End users need the
# WebView2 Runtime (preinstalled on Windows 10 21H2+ and Windows 11).
set(cesiumjs_bundled_libraries
""
PARENT_SCOPE
)