mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-20 18:51:19 +00:00
Merge pull request #19 from threeal/add-targets-input-option
Add Targets Input Option
This commit is contained in:
commit
dcccacb93b
15
.github/workflows/test.yml
vendored
15
.github/workflows/test.yml
vendored
@ -39,6 +39,21 @@ jobs:
|
||||
- name: Check if the default build directory does not exist
|
||||
run: test ! -d build
|
||||
|
||||
use-action-with-specified-targets:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3.3.0
|
||||
|
||||
- name: Use this action with specified targets
|
||||
uses: ./
|
||||
with:
|
||||
source-dir: test
|
||||
targets: test_c test_cpp
|
||||
|
||||
- name: Run build result
|
||||
run: build/test_c && build/test_cpp
|
||||
|
||||
use-action-with-specified-compiler:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
|
@ -13,6 +13,9 @@ inputs:
|
||||
description: The build directory of CMake project
|
||||
required: false
|
||||
default: build
|
||||
targets:
|
||||
description: List of build targets
|
||||
required: false
|
||||
generator:
|
||||
description: The build system generator of the CMake project
|
||||
required: false
|
||||
@ -33,6 +36,9 @@ runs:
|
||||
run: |
|
||||
ARGS="${{ inputs.source-dir }} -B ${{ inputs.build-dir }}"
|
||||
BUILD_ARGS="--build ${{ inputs.build-dir }}"
|
||||
if [ -n '${{ inputs.targets }}' ]; then
|
||||
BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}"
|
||||
fi
|
||||
if [ -n '${{ inputs.generator }}' ]; then
|
||||
ARGS="$ARGS -G ${{ inputs.generator }}"
|
||||
fi
|
||||
|
@ -11,3 +11,6 @@ endif()
|
||||
if(BUILD_CXX)
|
||||
add_executable(hello_world hello_world.cpp)
|
||||
endif()
|
||||
|
||||
add_executable(test_c EXCLUDE_FROM_ALL test.c)
|
||||
add_executable(test_cpp EXCLUDE_FROM_ALL test.cpp)
|
||||
|
6
test/test.c
Normal file
6
test/test.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("all ok\n");
|
||||
return 0;
|
||||
}
|
6
test/test.cpp
Normal file
6
test/test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "all ok" << std::endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user