Skip to content

Commit 72680e0

Browse files
committed
chore(common): Windows CMake file collision
1 parent 0feddcb commit 72680e0

File tree

1 file changed

+42
-37
lines changed

1 file changed

+42
-37
lines changed

packages/common/amplify_db_common/windows/CMakeLists.txt

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ add_library(${PLUGIN_NAME} SHARED
2121
###
2222

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

@@ -34,57 +34,62 @@ target_include_directories(${PLUGIN_NAME} INTERFACE
3434
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
3535

3636
include(FetchContent)
37+
3738
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
3839
# cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when
3940
# the default is used, so override it to the recommended behavior.
4041
# We can't really ask users to use a cmake that recent, so there's this if here.
4142
FetchContent_Declare(
4243
sqlite3
43-
URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz
44+
URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz
4445
DOWNLOAD_EXTRACT_TIMESTAMP NEW
4546
)
4647
else()
4748
FetchContent_Declare(
4849
sqlite3
49-
URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz
50+
URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz
5051
)
5152
endif()
52-
FetchContent_MakeAvailable(sqlite3)
5353

54-
add_library(sqlite3 SHARED "sqlite3_flutter.c")
54+
# Only fetch and build sqlite3 if it hasn't been added yet
55+
if (NOT TARGET sqlite3)
56+
FetchContent_MakeAvailable(sqlite3)
5557

56-
target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}")
57-
target_compile_options(sqlite3 PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O2>" "/w")
58+
add_library(sqlite3 SHARED "sqlite3_flutter.c")
5859

59-
# Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt
60-
target_compile_definitions(sqlite3 PRIVATE
61-
SQLITE_ENABLE_FTS5
62-
SQLITE_ENABLE_RTREE
63-
SQLITE_DQS=0
64-
SQLITE_DEFAULT_MEMSTATUS=0
65-
SQLITE_TEMP_STORE=2
66-
SQLITE_MAX_EXPR_DEPTH=0
67-
SQLITE_OMIT_AUTHORIZATION
68-
SQLITE_OMIT_DECLTYPE
69-
SQLITE_OMIT_DEPRECATED
70-
SQLITE_OMIT_GET_TABLE
71-
SQLITE_OMIT_LOAD_EXTENSION
72-
SQLITE_OMIT_PROGRESS_CALLBACK
73-
SQLITE_OMIT_SHARED_CACHE
74-
SQLITE_OMIT_TCL_VARIABLE
75-
SQLITE_OMIT_TRACE
76-
SQLITE_USE_ALLOCA
77-
SQLITE_UNTESTABLE
78-
SQLITE_HAVE_ISNAN
79-
SQLITE_HAVE_LOCALTIME_R
80-
SQLITE_HAVE_LOCALTIME_S
81-
)
60+
target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}")
61+
target_compile_options(sqlite3 PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O2>" "/w")
8262

83-
# Ensure sqlite3 actually gets build
84-
add_dependencies(${PLUGIN_NAME} sqlite3)
63+
# Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt
64+
target_compile_definitions(sqlite3 PRIVATE
65+
SQLITE_ENABLE_DBSTAT_VTAB
66+
SQLITE_ENABLE_FTS5
67+
SQLITE_ENABLE_RTREE
68+
SQLITE_DQS=0
69+
SQLITE_DEFAULT_MEMSTATUS=0
70+
SQLITE_TEMP_STORE=2
71+
SQLITE_MAX_EXPR_DEPTH=0
72+
SQLITE_STRICT_SUBTYPE=1
73+
SQLITE_OMIT_AUTHORIZATION
74+
SQLITE_OMIT_DECLTYPE
75+
SQLITE_OMIT_DEPRECATED
76+
SQLITE_OMIT_PROGRESS_CALLBACK
77+
SQLITE_OMIT_SHARED_CACHE
78+
SQLITE_OMIT_TCL_VARIABLE
79+
SQLITE_OMIT_TRACE
80+
SQLITE_USE_ALLOCA
81+
SQLITE_UNTESTABLE
82+
SQLITE_HAVE_ISNAN
83+
SQLITE_HAVE_LOCALTIME_R
84+
SQLITE_HAVE_LOCALTIME_S
85+
)
8586

86-
# List of absolute paths to libraries that should be bundled with the plugin
87-
set(amplify_db_common_bundled_libraries
88-
"$<TARGET_FILE:sqlite3>"
89-
PARENT_SCOPE
90-
)
87+
# Ensure sqlite3 actually gets built
88+
add_dependencies(${PLUGIN_NAME} sqlite3)
89+
90+
# List of absolute paths to libraries that should be bundled with the plugin
91+
set(amplify_db_common_bundled_libraries
92+
"$<TARGET_FILE:sqlite3>"
93+
PARENT_SCOPE
94+
)
95+
endif()

0 commit comments

Comments
 (0)