OpenBluetoothToolbox / SimpleBLE

SimpleBLE - the all-in-one Bluetooth library for MacOS, iOS, Windows, Linux and Android.
https://www.simpleble.org
Other
655 stars 110 forks source link

how to install in Flutter windows plugin? got error #250

Closed ohdonpiano closed 1 month ago

ohdonpiano commented 1 year ago

Hi, I want to use SimpleBLE in my Flutter native Windows plugin to do so, I followed these steps:

  1. created a new native windows plugin
  2. copied SimpleBLE source folder inside the plugin folder
  3. following "Usage with CMake (Local)" instructions from the docs, in CMakeLists.txt I've added:

add_subdirectory(SimpleBLE/simpleble ${CMAKE_BINARY_DIR}/simpleble) target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin simpleble::simpleble)

Then I built the example project, but got this error:

Error MSB3073 The command "setlocal "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake if %errorlevel% neq 0 goto :cmEnd :cmEnd endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone :cmErrorLevel exit /b %1 :cmDone if %errorlevel% neq 0 goto :VCEnd :VCEnd" exited with code 1. INSTALL C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets 160

If I understand well, the install phase fails Is there a CMake instruction I'm missing?

The build error is fixed if I open the visual studio project manually and disable the Post Build Event of "INSTALL", which has the command line: setlocal "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake if %errorlevel% neq 0 goto :cmEnd :cmEnd endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone :cmErrorLevel exit /b %1 :cmDone if %errorlevel% neq 0 goto :VCEnd

then the solution builds fine. This VS project is auto-generated by Flutter at every build, so this solution is not working.

kdewald commented 1 month ago

Hey @ohdonpiano, thanks for reaching out.

Unfortunately, Flutter is not as straightforward with these things, but we are considering a Flutter implementation some time in the future.