Skip to content

Commit 0f79937

Browse files
authored
Merge pull request #646 from chewing/windows-vcpkg
build: use vcpkg on Windows
2 parents e8ac272 + 3383f93 commit 0f79937

File tree

5 files changed

+33
-63
lines changed

5 files changed

+33
-63
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ jobs:
3434
run: sudo apt-get install ninja-build
3535
- if: ${{ matrix.os == 'macos-latest' }}
3636
run: brew install ninja
37-
- if: ${{ matrix.os == 'windows-latest' }}
38-
run: choco install ninja
3937
- if: ${{ matrix.os == 'windows-latest' }}
4038
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
39+
- if: ${{ matrix.os == 'windows-latest' }}
40+
run: |
41+
choco install ninja
42+
echo VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT >> $env:GITHUB_ENV
43+
echo CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake >> $env:GITHUB_ENV
44+
echo VCPKG_TARGET_TRIPLET=x64-windows-static >> $env:GITHUB_ENV
45+
& $env:VCPKG_INSTALLATION_ROOT\vcpkg install --triplet x64-windows-static sqlite3
46+
& $env:VCPKG_INSTALLATION_ROOT\vcpkg install --triplet x64-windows-static-md sqlite3
4147
4248
- name: Setup rustup
4349
run: |
@@ -46,7 +52,7 @@ jobs:
4652
4753
- name: Build
4854
run: |
49-
cmake --preset ${{ matrix.preset }}
55+
cmake --preset ${{ matrix.preset }} -DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_TARGET_TRIPLET }}
5056
cmake --build build
5157
cmake --install build --prefix install
5258

CMakeLists.txt

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ if(CMAKE_SYSTEM MATCHES "Windows")
8989
corrosion_add_target_rustflags(chewing_capi -Ctarget-feature=+crt-static)
9090
corrosion_add_target_rustflags(chewing_testhelper -Ctarget-feature=+crt-static)
9191
corrosion_add_target_rustflags(chewing-cli -Ctarget-feature=+crt-static)
92+
if(VCPKG_TARGET_TRIPLET)
93+
corrosion_set_env_vars(chewing-cli VCPKGRS_TRIPLET=${VCPKG_TARGET_TRIPLET})
94+
endif()
9295
endif()
9396

9497
# Feature probe
@@ -99,39 +102,10 @@ set(CURSES_NEED_WIDE true)
99102
find_package(Curses)
100103

101104
if(WITH_SQLITE3)
102-
find_package(SQLite3 QUIET)
105+
find_package(SQLite3 REQUIRED)
103106
if(SQLite3_FOUND)
104107
message(STATUS "Found SQLite3 version ${SQLite3_VERSION}")
105108
include_directories(SQLite3_INCLUDE_DIRS)
106-
else()
107-
message(STATUS "Fetching SQLite3 source from internet")
108-
FetchContent_Declare(
109-
SQLite3
110-
URL https://www.sqlite.org/2024/sqlite-amalgamation-3460000.zip
111-
URL_HASH SHA3_256=1221eed70de626871912bfca144c00411f0c30d3c2b7935cff3963b63370ef7c
112-
)
113-
FetchContent_MakeAvailable(SQLite3)
114-
115-
include_directories(${sqlite3_SOURCE_DIR})
116-
add_library(sqlite3_library STATIC
117-
${sqlite3_SOURCE_DIR}/sqlite3.c
118-
${sqlite3_SOURCE_DIR}/sqlite3.h
119-
)
120-
find_package(Threads)
121-
target_link_libraries(sqlite3_library PUBLIC ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
122-
set(SQLite3_LIBRARIES sqlite3_library)
123-
124-
add_executable(sqlite3
125-
${sqlite3_SOURCE_DIR}/shell.c
126-
)
127-
target_link_libraries(sqlite3 PRIVATE ${SQLite3_LIBRARIES})
128-
set_target_properties(sqlite3 PROPERTIES
129-
RUNTIME_OUTPUT_DIRECTORY ${sqlite3_BINARY_DIR}
130-
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${sqlite3_BINARY_DIR}
131-
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${sqlite3_BINARY_DIR}
132-
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${sqlite3_BINARY_DIR}
133-
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${sqlite3_BINARY_DIR}
134-
)
135109
endif()
136110
endif()
137111

Cargo.lock

Lines changed: 20 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ directories = "5.0.0"
2323
log = { workspace = true }
2424
rusqlite = { version = ">= 0.28.0", optional = true }
2525

26-
[target.'cfg(windows)'.dependencies]
27-
rusqlite = { version = ">= 0.28.0", features = ["bundled"], optional = true }
28-
2926
[dev-dependencies]
3027
tempfile = { workspace = true }
3128

capi/data/mini.dat

-22 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)