Skip to content

Windows Build Error — CMakeLists.txt Parse Error (“install” unexpected) #615

@Shrey113

Description

@Shrey113

🐛 Bug Report

The Flutter Windows build fails when using flutter_tts because the Windows plugin contains a corrupted CMakeLists.txt file. The build stops with the following error:

CMake Error at flutter/ephemeral/.plugin_symlinks/flutter_tts/windows/CMakeLists.txt:18:
  Parse error. Expected "(", got identifier with text "install".

This error occurs even on a fresh Flutter project with the latest Flutter SDK.


✔ Expected Behavior

The plugin should build successfully on Windows without modifying plugin files.


❌ Actual Behavior

The Windows plugin fails due to a malformed NuGet install block in the CMake file. The file contains an invalid extra line:

    ARGS install "Microsoft.Windows.CppWinRT" -Version 2.0.210503.1 -ExcludeVersion -OutputDirectory ...
)

This breaks the execute_process() block and causes CMake to throw a parse error.


🔁 Reproduction Steps

  1. Create a new Flutter project:

    flutter create test_tts
    cd test_tts
    
  2. Add the plugin:

    flutter pub add flutter_tts
    
  3. Run on Windows:

    flutter run -d windows
    
  4. Windows build fails with the CMake parse error.


🖥 Platform

  • Windows (Error occurs here)
  • Android
  • iOS
  • macOS

⚙ Versions

  • flutter_tts: latest from pub.dev

🧩 Root Cause

The plugin’s Windows CMakeLists.txt includes broken CMake syntax:

  • Extra ARGS line outside execute_process()
  • An extra ) that closes nothing
  • Incorrect NuGet command formatting

This prevents Windows builds from generating plugin build files.


✅ Working Fixed CMakeLists.txt

Here is a clean, working replacement for the plugin’s Windows CMakeLists.txt:

cmake_minimum_required(VERSION 3.14)

if(POLICY CMP0153)
  cmake_policy(SET CMP0153 NEW)
endif()

set(PROJECT_NAME "flutter_tts")
project(${PROJECT_NAME} LANGUAGES CXX)

find_program(NUGET_EXE NAMES nuget)
if(NOT NUGET_EXE)
  message(FATAL_ERROR "nuget.exe not found. Please install it.")
endif()

execute_process(
  COMMAND ${NUGET_EXE} install Microsoft.Windows.CppWinRT
          -Version 2.0.210503.1
          -ExcludeVersion
          -OutputDirectory ${CMAKE_BINARY_DIR}/packages
)

set(PLUGIN_NAME "flutter_tts_plugin")

add_library(${PLUGIN_NAME} SHARED
  "flutter_tts_plugin.cpp"
)

apply_standard_settings(${PLUGIN_NAME})

set_target_properties(${PLUGIN_NAME} PROPERTIES
  CXX_VISIBILITY_PRESET hidden
  VISIBILITY_INLINES_HIDDEN YES
)

target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_20)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)

target_include_directories(${PLUGIN_NAME} INTERFACE
  "${CMAKE_CURRENT_SOURCE_DIR}/include"
)

target_link_libraries(${PLUGIN_NAME} PRIVATE
  flutter
  flutter_wrapper_plugin
)

set_target_properties(${PLUGIN_NAME} PROPERTIES VS_PROJECT_IMPORT
  "${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.props"
)

target_link_libraries(${PLUGIN_NAME} PRIVATE
  "${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.targets"
)

set(flutter_tts_bundled_libraries "" PARENT_SCOPE)

🙏 Request

Please update the Windows plugin’s CMakeLists.txt file in the flutter_tts package so Windows builds work without manual patching.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions