Skip to content
Merged

CI #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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: CMake on multiple platforms

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

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

strategy:
fail-fast: false

matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Release,Debug]
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++
- os: macos-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
- os: macos-latest
c_compiler: cl
- os: macos-latest
c_compiler: gcc

steps:
- uses: actions/checkout@v4

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "test-build-output-dir=${{ github.workspace }}/test-build" >> "$GITHUB_OUTPUT"

- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.test-build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DNSTALL_CLI_ONLY=ON
-S ${{ github.workspace }}

- name: Build for tests
run: cmake --build ${{ steps.strings.outputs.test-build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.test-build-output-dir }}/tests
run: ctest --build-config ${{ matrix.build_type }} --verbose
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build
*.profraw
.cache
compile_commands.json

# testing binaries
*_Installer
40 changes: 23 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_CXX_FLAGS "-g")
option(NSTALL_TEST_BUILD "Build with automatic gui testing" OFF)
option(NSTALL_CLI_ONLY "Build with no GUI" OFF)

include_directories(include)

Expand All @@ -21,11 +20,11 @@ set(NSTALL_CARRIER_NAME ${PROJECT_NAME}-carrier)

set(INSTALLER_SOURCES
src/Installer/InstallerMain.cpp src/Installer/PayloadExtractor.cpp
src/Installer/InstallerForm.cpp src/Installer/InstallerCLI.cpp)
src/Installer/InstallerCLI.cpp)
set(CONSTRUCTOR_SOURCES
src/Constructor/ConstructorMain.cpp src/Constructor/ConstructorForm.cpp
src/Constructor/ConstructorCLI.cpp src/Constructor/PayloadPacker.cpp)
set(SHARED_SOURCES src/Common/MetaInfo.cpp)
src/Constructor/ConstructorMain.cpp src/Constructor/ConstructorCLI.cpp
src/Constructor/PayloadPacker.cpp)
set(SHARED_SOURCES src/Common/MetaInfo.cpp)

add_library(${COMMON_TARGET} ${SHARED_SOURCES})
target_compile_definitions(
Expand All @@ -34,8 +33,11 @@ target_compile_definitions(
-DNSTALL_EXE_EXTENSION="${CMAKE_EXECUTABLE_SUFFIX}"
-DNSTALL_CARRIER_NAME="${NSTALL_CARRIER_NAME}")

if(NSTALL_TEST_BUILD)
target_compile_definitions(${COMMON_TARGET} PUBLIC -DNSTALL_TEST_BUILD)
if(NSTALL_CLI_ONLY)
target_compile_definitions(${COMMON_TARGET} PUBLIC -DNSTALL_CLI_ONLY)
else()
list(APPEND INSTALLER_SOURCES src/Installer/InstallerForm.cpp)
list(APPEND CONSTRUCTOR_SOURCES src/Constructor/ConstructorForm.cpp)
endif()

# Dependencies
Expand Down Expand Up @@ -68,15 +70,17 @@ FetchContent_Declare(
FetchContent_MakeAvailable(fmt)
target_link_libraries(${COMMON_TARGET} PUBLIC fmt::fmt)

# nana
message(STATUS "Fetching dependency: nana")
FetchContent_Declare(
nana
GIT_REPOSITORY https://github.com/cnjinhao/nana
GIT_TAG 96d48b8413866028f5d284ee55b763ceab7aeb1f)
FetchContent_MakeAvailable(nana)
set_target_properties(nana PROPERTIES CXX_STANDARD 17)
target_link_libraries(${COMMON_TARGET} PUBLIC nana)
if(NOT NSTALL_CLI_ONLY)
# nana
message(STATUS "Fetching dependency: nana")
FetchContent_Declare(
nana
GIT_REPOSITORY https://github.com/cnjinhao/nana
GIT_TAG 96d48b8413866028f5d284ee55b763ceab7aeb1f)
FetchContent_MakeAvailable(nana)
set_target_properties(nana PROPERTIES CXX_STANDARD 17)
target_link_libraries(${COMMON_TARGET} PUBLIC nana)
endif()

# libsodium
message(STATUS "Fetching dependency: sodium")
Expand All @@ -102,3 +106,5 @@ add_custom_command(
COMMAND
${CMAKE_COMMAND} -E copy $<TARGET_FILE:${INSTALLER_TARGET}>
$<TARGET_FILE_DIR:${CONSTRUCTOR_TARGET}>/resources/${NSTALL_CARRIER_NAME})

add_subdirectory(tests)
Loading
Loading