11cmake_minimum_required (VERSION 3.15)
2+
3+ # Set CMP0175 to NEW to properly handle add_custom_command arguments
4+ if (POLICY CMP0175)
5+ cmake_policy (SET CMP0175 NEW)
6+ endif ()
7+
28set (PROJECT_NAME "webview_windows" )
39
410set (WIL_VERSION "1.0.220914.1" )
@@ -15,6 +21,7 @@ set(PLUGIN_NAME "webview_windows_plugin")
1521set (NUGET_URL https://dist.nuget.org/win-x86-commandline/v5.10.0/nuget.exe)
1622set (NUGET_SHA256 852b71cc8c8c2d40d09ea49d321ff56fd2397b9d6ea9f96e532530307bbbafd3)
1723
24+ # Find or download NuGet
1825find_program (NUGET nuget)
1926if (NOT NUGET)
2027 message (NOTICE "Nuget is not installed." )
@@ -30,15 +37,21 @@ if(NOT NUGET)
3037 endif ()
3138endif ()
3239
40+ # Create custom target for dependencies
3341add_custom_target (${PROJECT_NAME} _DEPENDENCIES_DOWNLOAD ALL )
42+
43+ # Download dependencies using NuGet
44+ # Note: Removed DEPENDS keyword from TARGET version of add_custom_command
3445add_custom_command (
3546 TARGET ${PROJECT_NAME} _DEPENDENCIES_DOWNLOAD PRE_BUILD
47+ COMMAND ${CMAKE_COMMAND} -E echo "Downloading dependencies..."
3648 COMMAND ${NUGET} install Microsoft.Windows.ImplementationLibrary -Version ${WIL_VERSION} -ExcludeVersion -OutputDirectory ${CMAKE_BINARY_DIR} /packages
3749 COMMAND ${NUGET} install Microsoft.Web.WebView2 -Version ${WEBVIEW_VERSION} -ExcludeVersion -OutputDirectory ${CMAKE_BINARY_DIR} /packages
38- DEPENDS ${NUGET}
50+ COMMENT "Downloading and installing NuGet packages"
3951)
4052
41- add_library (${PLUGIN_NAME} SHARED
53+ # Define source files
54+ set (PLUGIN_SOURCES
4255 "webview_windows_plugin.cc"
4356 "webview_platform.cc"
4457 "webview.cc"
@@ -52,25 +65,40 @@ add_library(${PLUGIN_NAME} SHARED
5265 "util/string_converter.cc"
5366)
5467
68+ # Create the plugin library
69+ add_library (${PLUGIN_NAME} SHARED ${PLUGIN_SOURCES} )
70+
71+ # Configure compiler options
5572if (MSVC )
5673 target_compile_options (${PLUGIN_NAME} PRIVATE "/await" )
5774endif ()
5875
76+ # Apply standard settings
5977apply_standard_settings(${PLUGIN_NAME} )
60- target_compile_features (${PLUGIN_NAME} PUBLIC cxx_std_20) # For std::format support
6178
62- set_target_properties (${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
79+ # Set C++ standard to 20 for std::format support
80+ target_compile_features (${PLUGIN_NAME} PUBLIC cxx_std_20)
6381
64- target_link_libraries (${PLUGIN_NAME} PRIVATE ${CMAKE_BINARY_DIR} /packages/Microsoft.Web.WebView2/build /native/Microsoft.Web.WebView2.targets)
65- target_link_libraries (${PLUGIN_NAME} PRIVATE ${CMAKE_BINARY_DIR} /packages/Microsoft.Windows.ImplementationLibrary/build /native/Microsoft.Windows.ImplementationLibrary.targets)
82+ # Configure visibility
83+ set_target_properties (${PLUGIN_NAME} PROPERTIES
84+ CXX_VISIBILITY_PRESET hidden
85+ )
86+
87+ # Add dependencies
88+ target_link_libraries (${PLUGIN_NAME} PRIVATE
89+ ${CMAKE_BINARY_DIR} /packages/Microsoft.Web.WebView2/build /native/Microsoft.Web.WebView2.targets
90+ ${CMAKE_BINARY_DIR} /packages/Microsoft.Windows.ImplementationLibrary/build /native/Microsoft.Windows.ImplementationLibrary.targets
91+ flutter
92+ flutter_wrapper_plugin
93+ )
6694
95+ # Configure definitions and includes
6796target_compile_definitions (${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
6897target_include_directories (${PLUGIN_NAME} INTERFACE
6998 "${CMAKE_CURRENT_SOURCE_DIR} /include"
7099)
71100
72- target_link_libraries (${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
73-
101+ # Set bundled libraries
74102set (webview_windows_bundled_libraries
75103 PARENT_SCOPE
76- )
104+ )
0 commit comments