Skip to content

Commit

Permalink
setup workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeryStk committed Nov 15, 2023
1 parent 6c0ab98 commit fad8ffe
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 23 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: Linux-Windows

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations.
#Consider changing this to true when your workflow is stable.
fail-fast: false


matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
18 changes: 4 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ project(${projectName} VERSION 0.01 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS " -static")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
endif(WIN32)

add_subdirectory("ResourceManager")
Expand All @@ -24,18 +23,9 @@ rm_embed_resources(RESOURCES "plotly_maker/plotly-2.27.0.min.js")


add_executable(${projectName} main.cpp cxxopts.hpp ${RESOURCES})
if(WIN32)
target_link_libraries(${projectName}
PRIVATE PlotlyMaker
-static-libgcc
-static-libstdc++
PRIVATE CommonUtils)
endif(WIN32)
if(UNIX)
target_link_libraries(${projectName}
PRIVATE PlotlyMaker
PRIVATE CommonUtils)
endif(UNIX)
target_link_libraries(${projectName} "ArrayCore")





1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
![Workflow](https://github.com/github/docs/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=main)
# devtools
DAVIS is utility for data visualization
The visualization is based on Plotly javascript https://plotly.com/
Expand Down
19 changes: 11 additions & 8 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include(FetchContent)
include(CMakePrintHelpers)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
Expand All @@ -7,6 +8,15 @@ FetchContent_Declare(
FetchContent_MakeAvailable(googletest)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Windows specific, for googletest

# Copy plotly java script to tests
MESSAGE("_____________________ Copy Plotlylib to Tests step ___________________________________________")
if(WIN32)
file(COPY ${CMAKE_SOURCE_DIR}/plotly_maker/plotly-2.27.0.min.js DESTINATION
${CMAKE_CURRENT_BINARY_DIR}/Debug/davis_htmls)
file(COPY ${CMAKE_SOURCE_DIR}/plotly_maker/plotly-2.27.0.min.js DESTINATION
${CMAKE_CURRENT_BINARY_DIR}/Release/davis_htmls)
endif(WIN32)

add_executable(${PROJECT_NAME}_plotly_tests PlotlyLibTest.cpp)
target_link_libraries(${PROJECT_NAME}_plotly_tests PRIVATE gtest_main)
target_link_libraries(${PROJECT_NAME}_plotly_tests PRIVATE ArrayCore)
Expand All @@ -15,15 +25,8 @@ add_executable(${PROJECT_NAME}_core_tests ArrayCoreTest.cpp)
target_link_libraries(${PROJECT_NAME}_core_tests PRIVATE gtest_main)
target_link_libraries(${PROJECT_NAME}_core_tests PRIVATE ArrayCore)


include_directories(${CMAKE_SOURCE_DIR})
include(GoogleTest)
gtest_discover_tests(${PROJECT_NAME}_plotly_tests _core_tests)

# Copy plotly java script to tests
add_custom_command(
TARGET ${PROJECT_NAME}_core_tests PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/plotly_maker/plotly-2.27.0.min.js
${CMAKE_CURRENT_BINARY_DIR}/davis_htmls/plotly-2.27.0.min.js
)

3 changes: 3 additions & 0 deletions array_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ project(${projectName} VERSION 0.01 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
endif(WIN32)
set(SOURCE_FILES
"../common_utils/common_utils.cpp"
"../common_utils/common_constants.cpp"
Expand Down
2 changes: 1 addition & 1 deletion common_utils/common_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void mayBeCreateJsWorkingFolder() {
struct stat sb;
if (stat(kOutFolderName, &sb) != 0) {
#ifdef _WIN32
mkdir(kOutFolderName);
_mkdir(kOutFolderName);
#elif __linux__
mode_t mode = 0755;
mkdir(kOutFolderName, mode);
Expand Down

0 comments on commit fad8ffe

Please sign in to comment.