Skip to content

Commit

Permalink
chore: new cpp CI
Browse files Browse the repository at this point in the history
  • Loading branch information
chybz committed Jan 16, 2024
1 parent b63026f commit fdf8ad3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/test-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,34 @@ on:
- main
- cpp*
- renovate/**
paths:
- cpp/**
- testdata/**
pull_request:
branches:
- main
paths:
- cpp/**
- testdata/**
workflow_call:

jobs:
test-cpp:
strategy:
matrix:
os:
#- ubuntu-20.04
#- ubuntu-22.04
#- windows-2019
- windows-2022
runs-on: ${{ matrix.os }}
config:
- os: ubuntu-latest
cc: gcc
- os: ubuntu-latest
cc: clang
- os: macos-latest
cc: clang
- os: windows-latest
cc: cl
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: install dependencies
working-directory: cpp
run: |
cmake -P cmake/cmate install
cmake -P cmake/cmate --cc=${{ matrix.config.cc }} install
- name: configure and build
working-directory: cpp
run: |
cmake -P cmake/cmate build --release
cmake -P cmake/cmate --cc=${{ matrix.config.cc }} build --release
30 changes: 29 additions & 1 deletion cpp/cmake/cmate
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ list(
APPEND
CMATE_OPTIONS
"verbose"
"cc"
)

function(cmate_build_help VAR)
Expand All @@ -1339,7 +1340,9 @@ function(cmate_build_help VAR)
Usage: cmate [OPTIONS] COMMAND
Options:
--verbose Verbose operation
--verbose Verbose operation
--cc=ID Compiler suite to use (overrides CMATE_CC)
(e.g.: gcc, clang, gcc-10, clang-16, cl)
Commands:
"
Expand Down Expand Up @@ -1432,6 +1435,30 @@ function(cmate_set_defaults)
cmate_setg(CMATE_SOURCE_PAT "*.[ch]pp")
endfunction()

function(cmate_set_compilers)
set(CC "$ENV{CMATE_CC}")

if(CMATE_CC)
set(CC "${CMATE_CC}")
endif()

if(CC)
if(${CC} MATCHES "^gcc(.*)$")
set(CXX "g++${CMAKE_MATCH_1}")
elseif(${CC} MATCHES "^clang(.*)$")
set(CXX "clang++${CMAKE_MATCH_1}")
else()
set(CXX "${CC}")
endif()

cmate_msg("using compilers CC=${CC} CXX=${CXX}")
cmate_setg(CMAKE_C_COMPILER "${CC}")
cmate_setg(CMAKE_CXX_COMPILER "${CXX}")
set(ENV{CC} "${CC}")
set(ENV{CXX} "${CXX}")
endif()
endfunction()

##############################################################################
#
# Command processing
Expand Down Expand Up @@ -1461,6 +1488,7 @@ endfunction()
if(CMAKE_SCRIPT_MODE_FILE)
cmate_set_defaults()
cmate_parse_arguments()
cmate_set_compilers()
cmate_load_conf("${CMATE_ROOT_DIR}/${CMATE_PRJFILE}")
cmate_process_cmd()
endif()
2 changes: 1 addition & 1 deletion cpp/deps.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nlohmann/json@v3.11.3 -DJSON_BuildTests=OFF
cucumber/messages@cpp-msvc-link --srcdir=cpp
cucumber/messages --srcdir=cpp

0 comments on commit fdf8ad3

Please sign in to comment.