Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Error at flutter/ephemeral/.plugin_symlinks/amplify_db_common/windows/CMakeLists.txt:54 (add_library): add_library cannot create target "sqlite3" because an imported target with the same name already exists. #5477

Closed
2 of 14 tasks
richard457 opened this issue Sep 18, 2024 · 23 comments
Assignees
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced storage Issues related to the Storage Category windows

Comments

@richard457
Copy link

Description

CMake Error at flutter/ephemeral/.plugin_symlinks/amplify_db_common/windows/CMakeLists.txt:54 (add_library):
add_library cannot create target "sqlite3" because an imported target with
the same name already exists.

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

CMake Error at flutter/ephemeral/.plugin_symlinks/amplify_db_common/windows/CMakeLists.txt:54 (add_library):
add_library cannot create target "sqlite3" because an imported target with
the same name already exists.

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.24

Amplify Flutter Version

2.0

Deployment Method

Amplify Gen 2

Schema

No response

@github-actions github-actions bot added pending-triage This issue is in the backlog of issues to triage pending-maintainer-response Pending response from a maintainer of this repository labels Sep 18, 2024
@Equartey
Copy link
Contributor

Hi @richard457, can you give specific reproduction steps? What are you doing to produce this error?

@Equartey Equartey added storage Issues related to the Storage Category windows and removed pending-maintainer-response Pending response from a maintainer of this repository labels Sep 18, 2024
@richard457
Copy link
Author

Create a simple flutter project, add amplify_storage_s3: ^2.4.1 and powersync: ^1.8.2 or any other plugin that uses sqlite3 the compile the app for windows, I think I checking in amplify_db_common and realized that we are using sqlite3 as name which will conflict with other sqlite3 packages out there

# The Flutter tooling requires that developers have a version of Visual Studio
# installed that includes CMake 3.14 or later. You should not increase this
# version, as doing so will cause the plugin to fail to compile for some
# customers of the plugin.
cmake_minimum_required(VERSION 3.14)

# Project-level configuration.
set(PROJECT_NAME "amplify_db_common")
project(${PROJECT_NAME} LANGUAGES C CXX)

# This value is used when generating builds using this plugin, so it must
# not be changed
set(PLUGIN_NAME "amplify_db_common_plugin")

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

###
# Below here, keep in sync with: https://github.com/simolus3/sqlite3.dart/blob/main/sqlite3_flutter_libs/windows/CMakeLists.txt
###

# Essentially, the idea of this build script is to compile a sqlite3.dll
# and make Fluter bundle that with the final app.
# It looks like we can't avoid building a sqlite3_flutter_libs.dll too,
# but that's not on me.

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_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)

include(FetchContent)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
  # cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when
  # the default is used, so override it to the recommended behavior.
  # We can't really ask users to use a cmake that recent, so there's this if here.
  FetchContent_Declare(
    sqlite3
    URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz
    DOWNLOAD_EXTRACT_TIMESTAMP NEW
  )
else()
  FetchContent_Declare(
    sqlite3
    URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz
  )
endif()
FetchContent_MakeAvailable(sqlite3)

# add_library(sqlite3 SHARED "sqlite3_flutter.c")

target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}")
target_compile_options(sqlite3 PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O2>" "/w")

# Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt
target_compile_definitions(sqlite3 PRIVATE
  SQLITE_ENABLE_FTS5
  SQLITE_ENABLE_RTREE
  SQLITE_DQS=0
  SQLITE_DEFAULT_MEMSTATUS=0
  SQLITE_TEMP_STORE=2
  SQLITE_MAX_EXPR_DEPTH=0
  SQLITE_OMIT_AUTHORIZATION
  SQLITE_OMIT_DECLTYPE
  SQLITE_OMIT_DEPRECATED
  SQLITE_OMIT_GET_TABLE
  SQLITE_OMIT_LOAD_EXTENSION
  SQLITE_OMIT_PROGRESS_CALLBACK
  SQLITE_OMIT_SHARED_CACHE
  SQLITE_OMIT_TCL_VARIABLE
  SQLITE_OMIT_TRACE
  SQLITE_USE_ALLOCA
  SQLITE_UNTESTABLE
  SQLITE_HAVE_ISNAN
  SQLITE_HAVE_LOCALTIME_R
  SQLITE_HAVE_LOCALTIME_S
)

# Ensure sqlite3 actually gets build
add_dependencies(${PLUGIN_NAME} sqlite3)

# List of absolute paths to libraries that should be bundled with the plugin
set(amplify_db_common_bundled_libraries
  "$<TARGET_FILE:sqlite3>"
  PARENT_SCOPE
)

@Equartey

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Sep 18, 2024
@Equartey
Copy link
Contributor

@richard457 Thanks for sharing. We'll investigate and let you know what we find.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Sep 19, 2024
@Equartey Equartey added bug Something is not working; the issue has reproducible steps and has been reproduced and removed pending-triage This issue is in the backlog of issues to triage labels Sep 19, 2024
@Equartey Equartey self-assigned this Sep 19, 2024
@richard457
Copy link
Author

@Equartey any update?

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Sep 21, 2024
@Equartey
Copy link
Contributor

@richard457 I've been able to reproduce the error. Currently investigating a solution. I'll you know when more progress has been made.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Sep 24, 2024
@richard457
Copy link
Author

Thank you for update @Equartey We really appreciate your support, we are patiently waiting.

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Sep 26, 2024
@khatruong2009 khatruong2009 removed the pending-maintainer-response Pending response from a maintainer of this repository label Sep 26, 2024
@Equartey Equartey added the pending-release Issues that have been addressed in main but have not been released label Oct 29, 2024
@Equartey
Copy link
Contributor

Hi @richard457, apologies for the delay. A fix for this has been merged. We will notify you when it has been released!

@richard457
Copy link
Author

richard457 commented Nov 1, 2024

I installed the update but the error still persists

.plugin_symlinks/amplify_db_common/windows".
  See documentation for policy CMP0002 for more details.
Unable to generate build files

https://github.com/yegobox/flipper/actions/runs/11630194715/job/32388623308 cc @Equartey

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Nov 1, 2024
@ekjotmultani
Copy link
Member

ekjotmultani commented Nov 1, 2024

Hi @richard457, our sincere apologies that you are still facing this issue. For clarification, you upgraded to the latest version 2.5.0 of amplify-flutter, yet nothing changed?.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 1, 2024
@veganguy
Copy link

veganguy commented Nov 1, 2024

For clarification, you upgraded to the latest version 2.5.0 of amplify-flutter, yet nothing changed?.

That's correct - I have upgraded to amplify-flutter 2.5.0 and still get the same compile error on Windows, too. 🥺😢

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Nov 1, 2024
@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 1, 2024
@veganguy
Copy link

veganguy commented Nov 1, 2024

Thank you, @ekjotmultani - we sincerely appreciate your assistance with this. 🙏🏽

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Nov 1, 2024
@ekjotmultani ekjotmultani removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 1, 2024
@richard457
Copy link
Author

Yes I upgraded to 2.5.0 and it is still the same.

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Nov 2, 2024
@tyllark tyllark removed pending-maintainer-response Pending response from a maintainer of this repository pending-release Issues that have been addressed in main but have not been released labels Nov 7, 2024
@Equartey
Copy link
Contributor

Hi @richard457, sorry for the delay. I was reviewing the build log you provided and noticed you have had subsequent clean builds. Can you confirm if you are still facing this issue or resolved it another way?

@richard457
Copy link
Author

richard457 commented Nov 19, 2024

The issue continues to be a problem that needs urgent attention.

@Equartey
Copy link
Contributor

@richard457, I have a potential fix. Can you verify it works before we release it?

You can do this by adding a pubspec_overrides.yaml file with the following content:

dependency_overrides:
  amplify_db_common:
    git:
      url: https://github.com/aws-amplify/amplify-flutter.git
      ref: fix/windows-cmake-namespace
      path: packages/common/amplify_db_common
      fetch: fix/windows-cmake-namespace

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 19, 2024
@veganguy
Copy link

@richard457, I have a potential fix. Can you verify it works before we release it?

Dreams really do come true! 😃

I just tried your fix and I can confirm that YES I can finally compile one again for Windows. 👍🏽

Thanks so very much resolving this, @Equartey @ekjotmultani ! Most sincerely appreciated. 🙏🏽

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Nov 19, 2024
@Equartey Equartey removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 19, 2024
@Equartey
Copy link
Contributor

@veganguy awesome! I'm still working on fixing the failing tests. You're welcome to continue to use the override I supplied. Changes I make to fix tests might cause unexpected breakage. In such a case, consider changing the override ref to the original commit hash that produced a clean build for you. For example:

dependency_overrides:
  amplify_db_common:
    git:
      url: https://github.com/aws-amplify/amplify-flutter.git
      ref: 9010ff4e2470e086d469af1ad1ecb61f9054e6b7
      path: packages/common/amplify_db_common
      fetch: 9010ff4e2470e086d469af1ad1ecb61f9054e6b7

Thanks again for your patience. Once the fix gets released we will notify yall here.

@veganguy
Copy link

Thanks again for your patience. Once the fix gets released we will notify yall here.

Thanks for that! And thank you, @Equartey, once again for your most-appreciated assistance.

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Nov 19, 2024
@NikaHsn NikaHsn removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 19, 2024
@Equartey
Copy link
Contributor

Hi @richard457 @veganguy, this has been fixed in amplify_db_common 2.5.1. However, it's behind a flag that must be manually enabled.

Locate your CMakeLists.txt, typically at path: your_project_root/windows/CMakeLists.txt. Then paste the following near the top of the file to opt out of amplify building sqlite3 for windows (see example)

set(USE_CUSTOM_SQLITE3 ON) 

Please let me know if you have any issues.

@Equartey Equartey added the pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. label Nov 27, 2024
@richard457
Copy link
Author

@Equartey Tested both set(USE_CUSTOM_SQLITE3 ON) and override, the project can now compile, question do I need both override and set(USE_CUSTOM_SQLITE3 ON) ?

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Dec 8, 2024
@Equartey
Copy link
Contributor

Equartey commented Dec 9, 2024

@richard457 Awesome! You no longer need the pubspec override if you are consuming amplify_db_common 2.5.1 or newer.

I'm going to close this issue as resolved. If you have any more questions don't hesitate to reach out.

@Equartey Equartey closed this as completed Dec 9, 2024
@github-actions github-actions bot removed pending-maintainer-response Pending response from a maintainer of this repository pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. labels Dec 9, 2024
Copy link

github-actions bot commented Dec 9, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced storage Issues related to the Storage Category windows
Projects
None yet
Development

No branches or pull requests

7 participants