@@ -20,26 +20,20 @@ add_library(${PLUGIN_NAME} SHARED
20
20
# Below here, keep in sync with: https://github.com/simolus3/sqlite3.dart/blob/main/sqlite3_flutter_libs/windows/CMakeLists.txt
21
21
# ##
22
22
23
- # Only fetch and build sqlite3 if it hasn't been added yet
24
- if (NOT TARGET sqlite3 )
25
- # Essentially, the idea of this build script is to compile a sqlite3.dll
26
- # and make Flutter bundle that with the final app.
27
- # It looks like we can't avoid building a sqlite3_flutter_libs.dll too,
28
- # but that's not on me.
29
- apply_standard_settings (${PLUGIN_NAME} )
30
- set_target_properties (${PLUGIN_NAME} PROPERTIES
31
- CXX_VISIBILITY_PRESET hidden )
32
- target_compile_definitions (${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL )
33
- target_include_directories (${PLUGIN_NAME} INTERFACE
34
- "${CMAKE_CURRENT_SOURCE_DIR} /include" )
35
- target_link_libraries (${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin )
23
+ # Apply standard settings for the plugin
24
+ apply_standard_settings (${PLUGIN_NAME} )
25
+ set_target_properties (${PLUGIN_NAME} PROPERTIES
26
+ CXX_VISIBILITY_PRESET hidden )
27
+ target_compile_definitions (${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL )
28
+ target_include_directories (${PLUGIN_NAME} INTERFACE
29
+ "${CMAKE_CURRENT_SOURCE_DIR} /include" )
30
+ target_link_libraries (${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin )
36
31
32
+ # Check if the target 'sqlite3' already exists
33
+ if (NOT TARGET sqlite3_amplify_db_common )
37
34
include (FetchContent )
38
35
39
36
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0" )
40
- # cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when
41
- # the default is used, so override it to the recommended behavior.
42
- # We can't really ask users to use a cmake that recent, so there's this if here.
43
37
FetchContent_Declare (
44
38
sqlite3
45
39
URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz
@@ -54,13 +48,14 @@ if(NOT TARGET sqlite3)
54
48
55
49
FetchContent_MakeAvailable (sqlite3 )
56
50
57
- add_library (sqlite3 SHARED "sqlite3_flutter.c" )
51
+ # Create an alias for the sqlite3 library specifically for amplify_db_common
52
+ # Must be preserved to avoid collisions, ie consumer has a dependency on sqlite3 too
53
+ add_library (sqlite3_amplify_db_common SHARED "sqlite3_flutter.c" )
58
54
59
- target_include_directories (sqlite3 PRIVATE "${sqlite3_SOURCE_DIR} " )
60
- target_compile_options (sqlite3 PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O2>" "/w" )
55
+ target_include_directories (sqlite3_amplify_db_common PRIVATE "${sqlite3_SOURCE_DIR} " )
56
+ target_compile_options (sqlite3_amplify_db_common PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O2>" "/w" )
61
57
62
- # Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt
63
- target_compile_definitions (sqlite3 PRIVATE
58
+ target_compile_definitions (sqlite3_amplify_db_common PRIVATE
64
59
SQLITE_ENABLE_DBSTAT_VTAB
65
60
SQLITE_ENABLE_FTS5
66
61
SQLITE_ENABLE_RTREE
@@ -82,13 +77,13 @@ if(NOT TARGET sqlite3)
82
77
SQLITE_HAVE_LOCALTIME_R
83
78
SQLITE_HAVE_LOCALTIME_S
84
79
)
80
+ endif ()
85
81
86
- # Ensure sqlite3 actually gets built
87
- add_dependencies (${PLUGIN_NAME} sqlite3 )
82
+ # Ensure sqlite3_amplify_db_common is used by the plugin
83
+ add_dependencies (${PLUGIN_NAME} sqlite3_amplify_db_common )
88
84
89
- # List of absolute paths to libraries that should be bundled with the plugin
90
- set (amplify_db_common_bundled_libraries
91
- "$<TARGET_FILE:sqlite3>"
92
- PARENT_SCOPE
93
- )
94
- endif ()
85
+ # List of absolute paths to libraries that should be bundled with the plugin
86
+ set (amplify_db_common_bundled_libraries
87
+ "$<TARGET_FILE:sqlite3_amplify_db_common>"
88
+ PARENT_SCOPE
89
+ )
0 commit comments