Skip to content

Commit

Permalink
build: use Ninja on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
kanru committed Jan 1, 2024
1 parent 5b35fe9 commit 36c971c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
CMAKE_GENERATOR: Ninja

jobs:
build:
Expand All @@ -31,6 +32,13 @@ jobs:
with:
submodules: 'true'

- if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install ninja-build
- if: ${{ matrix.os == 'macos-latest' }}
run: brew install ninja
- if: ${{ matrix.os == 'windows-latest' }}
run: choco install ninja

- name: Setup rustup
run: |
rustup default ${{ matrix.rust_version }}
Expand All @@ -50,6 +58,8 @@ jobs:
with:
submodules: 'true'

- run: sudo apt-get install ninja-build

- name: Build
run: cargo xtask build --build-type ${{env.BUILD_TYPE}} --with-rust false --with-hash true --verbose true

Expand All @@ -68,6 +78,8 @@ jobs:
with:
submodules: 'true'

- run: sudo apt-get install ninja-build

- name: Setup rustup
run: |
rustup default stable
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if(CMAKE_C_COMPILER_ID MATCHES GNU|Clang)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
endif()
elseif(MSVC)
elseif(CMAKE_C_COMPILER_ID MATCHES MSVC)
# /wd4819
# Without BOM, Visual Studio does not treat source file as UTF-8
# encoding, thus it will complain about invalid character. Use
Expand Down Expand Up @@ -70,7 +70,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})

option(WITH_SQLITE3 "Use sqlite3 to store userphrase" true)
option(WITH_INTERNAL_SQLITE3 "Use internal sqlite3" false)
if(MSVC)
if(CMAKE_C_COMPILER_ID MATCHES MSVC)
set(WITH_INTERNAL_SQLITE3 true)
endif()

Expand Down Expand Up @@ -274,7 +274,7 @@ if(NOT WITH_RUST)
target_link_libraries(libchewing
PRIVATE common
PRIVATE userphrase)
if(BUILD_SHARED_LIBS AND MSVC)
if(BUILD_SHARED_LIBS AND CMAKE_C_COMPILER_ID MATCHES MSVC)
target_compile_definitions(libchewing PRIVATE CHEWINGDLL_EXPORTS)
endif()
endif()
Expand All @@ -297,7 +297,7 @@ if(WITH_RUST)
PRIVATE LINKER:-exported_symbols_list,${CMAKE_BINARY_DIR}/symbols.map
PRIVATE LINKER:-dead_strip
)
elseif(MSVC)
elseif(CMAKE_C_COMPILER_ID MATCHES MSVC)
target_link_options(libchewing PRIVATE "/DEF ${CMAKE_BINARY_DIR}/symbols.map")
set_target_properties(libchewing PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ foreach(target ${ALL_TESTS})
add_executable(${target} ${TEST_SRC_DIR}/${target}.c)
target_link_libraries(${target} testhelper)
# XXX workaround MSVC issue
if(MSVC AND WITH_RUST)
if(CMAKE_C_COMPILER_ID MATCHES MSVC AND WITH_RUST)
target_link_libraries(${target} chewing)
else()
target_link_libraries(${target} libchewing)
Expand Down

0 comments on commit 36c971c

Please sign in to comment.