dart - Flutter CMake install vscode fails - Stack Overflow

admin2025-04-22  1

I am trying to create a flutter plugin that wraps couchabse c++ sdk using FFI. Everything builds correctly however fails when cmake install is called.

Here is my CMakeLists that uses CPMAddPackage to include a package.

CPMAddPackage(
  NAME
  couchbase_cxx_client
  GIT_TAG
  1.0.4
  VERSION
  1.0.4
  GITHUB_REPOSITORY
  "couchbase/couchbase-cxx-client"
  OPTIONS
  "COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL ON"
  "COUCHBASE_CXX_CLIENT_BUILD_STATIC ON")

add_library(libcouchbase_ffi SHARED
  "libcouchbase_ffi.c"
)

set_target_properties(libcouchbase_ffi PROPERTIES
  PUBLIC_HEADER libcouchbase_ffi.h
  OUTPUT_NAME "libcouchbase_ffi"
)

The rest is basically default ffigen example generated using

flutter create --template=plugin_ffi --platforms=linux,macos,windows libcouchbase_ffi

I have not wrapped any functionality of the couchbase c++ sdk so it does not appear to be a source code issue. The only exported functions are the default sum from the example.

When building I see that everything builds correctly however when install is called I get the following error:

error MSB3073: The command "setlocal [D:\<MY PATH>\couchbase\libcouchbase_ffi\example\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake [D:\<MY PATH>\couchbase\libcouchbase_ffi\example\build\windows\x64\INSTALL.vcxproj]

Digging a bit deeper and calling cmake install myself I see more details:

CMake Error at _deps/json-build/external/PEGTL/cmake_install.cmake:52 (file):
  file cannot create directory:
  D:/<MY PATH>/couchbase/libcouchbase_ffi/example/build/windows/x64/$<TARGET_FILE_DIR:libcouchbase_ffi_example>/lib/cmake/pegtl.
  Maybe need administrative privileges.

I have tried running as admin but it produces the same error. It appears that $<TARGET_FILE_DIR:libcouchbase_ffi_example> is not correctly resolved.

Any suggestions are appreciated. Thank you.

转载请注明原文地址:http://anycun.com/QandA/1745301132a90576.html