Skip to content

Commit 31dc1df

Browse files
committed
build: use Ninja on all platforms
1 parent 5b35fe9 commit 31dc1df

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

.github/workflows/ci.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
env:
1212
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
1313
BUILD_TYPE: Release
14+
CMAKE_GENERATOR: Ninja
1415

1516
jobs:
1617
build:
@@ -20,6 +21,13 @@ jobs:
2021
os: [ubuntu-latest, windows-latest, macos-latest]
2122
with_rust: ['true', 'false']
2223
rust_version: ['1.70', 'stable']
24+
include:
25+
- os: ubuntu-latest
26+
c_compiler: cc
27+
- os: windows-latest
28+
c_compiler: cl.exe
29+
- os: macos-latest
30+
c_compiler: cc
2331
exclude:
2432
- with_rust: 'false'
2533
rust_version: 'stable'
@@ -31,12 +39,23 @@ jobs:
3139
with:
3240
submodules: 'true'
3341

42+
- if: ${{ matrix.os == 'ubuntu-latest' }}
43+
run: sudo apt-get install ninja-build
44+
- if: ${{ matrix.os == 'macos-latest' }}
45+
run: brew install ninja
46+
- if: ${{ matrix.os == 'windows-latest' }}
47+
run: choco install ninja
48+
- if: ${{ matrix.os == 'windows-latest' }}
49+
uses: ilammy/msvc-dev-cmd@1a763147372cb4ca09f2a6716ff70f2f4396bb8c
50+
3451
- name: Setup rustup
3552
run: |
3653
rustup default ${{ matrix.rust_version }}
3754
rustup update
3855
3956
- name: Build
57+
env:
58+
CC: ${{ matrix.c_compiler }}
4059
run: cargo xtask build --build-type ${{env.BUILD_TYPE}} --with-rust ${{matrix.with_rust}} --verbose true
4160

4261
- name: Test
@@ -50,6 +69,8 @@ jobs:
5069
with:
5170
submodules: 'true'
5271

72+
- run: sudo apt-get install ninja-build
73+
5374
- name: Build
5475
run: cargo xtask build --build-type ${{env.BUILD_TYPE}} --with-rust false --with-hash true --verbose true
5576

@@ -61,13 +82,15 @@ jobs:
6182
matrix:
6283
with_rust: ['true', 'false']
6384
runs-on: ubuntu-latest
64-
name: with_rust=${{ matrix.with_rust }}
85+
name: Coverage with_rust=${{ matrix.with_rust }}
6586

6687
steps:
6788
- uses: actions/checkout@v3
6889
with:
6990
submodules: 'true'
7091

92+
- run: sudo apt-get install ninja-build
93+
7194
- name: Setup rustup
7295
run: |
7396
rustup default stable

CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if(CMAKE_C_COMPILER_ID MATCHES GNU|Clang)
4141
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
4242
endif()
4343
endif()
44-
elseif(MSVC)
44+
elseif(CMAKE_C_COMPILER_ID MATCHES MSVC)
4545
# /wd4819
4646
# Without BOM, Visual Studio does not treat source file as UTF-8
4747
# encoding, thus it will complain about invalid character. Use
@@ -70,7 +70,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
7070

7171
option(WITH_SQLITE3 "Use sqlite3 to store userphrase" true)
7272
option(WITH_INTERNAL_SQLITE3 "Use internal sqlite3" false)
73-
if(MSVC)
73+
if(CMAKE_C_COMPILER_ID MATCHES MSVC)
7474
set(WITH_INTERNAL_SQLITE3 true)
7575
endif()
7676

@@ -274,7 +274,7 @@ if(NOT WITH_RUST)
274274
target_link_libraries(libchewing
275275
PRIVATE common
276276
PRIVATE userphrase)
277-
if(BUILD_SHARED_LIBS AND MSVC)
277+
if(BUILD_SHARED_LIBS AND CMAKE_C_COMPILER_ID MATCHES MSVC)
278278
target_compile_definitions(libchewing PRIVATE CHEWINGDLL_EXPORTS)
279279
endif()
280280
endif()
@@ -297,7 +297,7 @@ if(WITH_RUST)
297297
PRIVATE LINKER:-exported_symbols_list,${CMAKE_BINARY_DIR}/symbols.map
298298
PRIVATE LINKER:-dead_strip
299299
)
300-
elseif(MSVC)
300+
elseif(CMAKE_C_COMPILER_ID MATCHES MSVC)
301301
target_link_options(libchewing PRIVATE "/DEF ${CMAKE_BINARY_DIR}/symbols.map")
302302
set_target_properties(libchewing PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
303303
endif()

test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ foreach(target ${ALL_TESTS})
5454
add_executable(${target} ${TEST_SRC_DIR}/${target}.c)
5555
target_link_libraries(${target} testhelper)
5656
# XXX workaround MSVC issue
57-
if(MSVC AND WITH_RUST)
57+
if(CMAKE_C_COMPILER_ID MATCHES MSVC AND WITH_RUST)
5858
target_link_libraries(${target} chewing)
5959
else()
6060
target_link_libraries(${target} libchewing)

0 commit comments

Comments
 (0)