Skip to content

Commit 8dfbdcd

Browse files
committed
test
1 parent 740e008 commit 8dfbdcd

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

packages/common/amplify_db_common/windows/CMakeLists.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,90 @@ set(PLUGIN_NAME "amplify_db_common_plugin")
1515
add_library(${PLUGIN_NAME} SHARED
1616
"amplify_db_common_plugin.cpp"
1717
)
18+
19+
###
20+
# Below here, keep in sync with: https://github.com/simolus3/sqlite3.dart/blob/main/sqlite3_flutter_libs/windows/CMakeLists.txt
21+
###
22+
23+
# Essentially, the idea of this build script is to compile a sqlite3.dll
24+
# and make Fluter bundle that with the final app.
25+
# It looks like we can't avoid building a sqlite3_flutter_libs.dll too,
26+
# but that's not on me.
27+
28+
apply_standard_settings(${PLUGIN_NAME})
29+
set_target_properties(${PLUGIN_NAME} PROPERTIES
30+
CXX_VISIBILITY_PRESET hidden)
31+
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
32+
target_include_directories(${PLUGIN_NAME} INTERFACE
33+
"${CMAKE_CURRENT_SOURCE_DIR}/include")
34+
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
35+
36+
# Include FetchContent for sqlite3 if not already available.
37+
include(FetchContent)
38+
39+
# Only add the sqlite3 library if it hasn't been defined already.
40+
if (NOT TARGET sqlite3)
41+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
42+
FetchContent_Declare(
43+
sqlite3
44+
URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz
45+
DOWNLOAD_EXTRACT_TIMESTAMP NEW
46+
)
47+
else()
48+
FetchContent_Declare(
49+
sqlite3
50+
URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz
51+
)
52+
endif()
53+
54+
FetchContent_MakeAvailable(sqlite3)
55+
56+
# Define the sqlite3 library only if it wasn't already defined.
57+
add_library(sqlite3 SHARED "sqlite3_flutter.c")
58+
59+
# Configure sqlite3 compilation options.
60+
target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}")
61+
target_compile_options(sqlite3 PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O2>" "/w")
62+
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_FTS5
66+
SQLITE_ENABLE_RTREE
67+
SQLITE_DQS=0
68+
SQLITE_DEFAULT_MEMSTATUS=0
69+
SQLITE_TEMP_STORE=2
70+
SQLITE_MAX_EXPR_DEPTH=0
71+
SQLITE_OMIT_AUTHORIZATION
72+
SQLITE_OMIT_DECLTYPE
73+
SQLITE_OMIT_DEPRECATED
74+
SQLITE_OMIT_GET_TABLE
75+
SQLITE_OMIT_LOAD_EXTENSION
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+
)
86+
87+
# Create an alias for this version of sqlite3 for your plugin's use.
88+
add_library(sqlite3_amplify_db_common ALIAS sqlite3)
89+
else()
90+
# If sqlite3 already exists, create an alias for your plugin to avoid duplication.
91+
add_library(sqlite3_amplify_db_common ALIAS sqlite3)
92+
endif()
93+
94+
# Link your plugin to the sqlite3 alias.
95+
target_link_libraries(${PLUGIN_NAME} PRIVATE sqlite3_amplify_db_common)
96+
97+
# Ensure sqlite3 actually gets built.
98+
add_dependencies(${PLUGIN_NAME} sqlite3_amplify_db_common)
99+
100+
# List of absolute paths to libraries that should be bundled with the plugin.
101+
set(amplify_db_common_bundled_libraries
102+
"$<TARGET_FILE:sqlite3_amplify_db_common>"
103+
PARENT_SCOPE
104+
)

0 commit comments

Comments
 (0)