Skip to content

Commit

Permalink
allow windows builds (#31)
Browse files Browse the repository at this point in the history
* add cmake statements to allow windows builds
move some logic

* fix

* module path fix

* comment WX, test on release

* test on windows

* only installing lcov on linux and in debug builds

* Apply suggestions to fix windows build
  • Loading branch information
ryan597 authored Dec 16, 2023
1 parent 54ab4ca commit 6541448
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 29 deletions.
7 changes: 2 additions & 5 deletions .github/actions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ inputs:
runs:
using: "composite"
steps:
- name: "install lcov for coverage"
run: sudo apt install lcov
shell: bash

- name: "check cache CPM"
id: cache-cpm
Expand All @@ -20,7 +17,7 @@ runs:
path: |
cmake/CPM.cmake
cmake/CodeCoverage.cmake
cmake/catch2
cmake/catch2/**
${{ inputs.build_type }}/_deps/**
key: ${{ hashFiles('CMakeLists.txt') }}--cpm

Expand All @@ -29,6 +26,6 @@ runs:
shell: bash

- name: "cmake build targets"
run: cmake --build build_${{inputs.build_type}} -j4
run: cmake --build build_${{inputs.build_type}} -j8
shell: bash

25 changes: 22 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: "install lcov for coverage"
run: sudo apt install lcov

- name: "checkout repo"
uses: actions/checkout@v4

Expand Down Expand Up @@ -50,6 +53,22 @@ jobs:
with:
build_type: Release

#- name: "test Release"
# working-directory: ./build_Release
# run: make test
- name: "test Release"
working-directory: ./build_Release
run: make test

build-windows:
runs-on: windows-latest

steps:
- name: "checkout repo"
uses: actions/checkout@v4

- name: "build Release"
uses: ./.github/actions
with:
build_type: Release

- name: "test Release"
working-directory: ./build_Release
run: ctest --output-on-failure
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
cmake
.vscode/
.vscode
.vs
cmake
30 changes: 17 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ set(CMAKE_CXX_STANDARD 20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

if(CMAKE_BUILD_TYPE MATCHES Debug)
# Flags to be added once refactor is done
#-Werror
add_compile_options(-Wno-unused-parameter)
if(MSVC)
#/WX
add_compile_options(/W4)
else()
# Flags to be added once refactor is done
#-Werror
add_compile_options(-Wno-unused-parameter)

# Code Coverage - download and append compiler flags
message(STATUS "Download Code Coverage cmake file")
file(DOWNLOAD
https://raw.githubusercontent.com/bilke/cmake-modules/master/CodeCoverage.cmake
${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake
SHOW_PROGRESS
)
include(CodeCoverage)
append_coverage_compiler_flags()
# Code Coverage - download and append compiler flags
file(DOWNLOAD
https://raw.githubusercontent.com/bilke/cmake-modules/master/CodeCoverage.cmake
${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake
SHOW_PROGRESS
)
include(CodeCoverage)
append_coverage_compiler_flags()
endif()
endif()

if(CMAKE_PROJECT_NAME STREQUAL ChessNGin AND BUILD_TESTING)
Expand All @@ -30,4 +34,4 @@ if(CMAKE_PROJECT_NAME STREQUAL ChessNGin AND BUILD_TESTING)
add_subdirectory(tests)
endif()

add_subdirectory(src)
add_subdirectory(src)
12 changes: 8 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ add_library(nginlib STATIC

add_executable(NGin ${SOURCES})

set(ENABLED_WARNING -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wold-style-cast -Wcast-align
-Woverloaded-virtual -Wconversion -Wsign-conversion -Wmisleading-indentation -Wduplicated-cond
-Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wdouble-promotion
-Wformat=2)
if(MSVC)
set(ENABLED_WARNINGS /Wall)
else()
set(ENABLED_WARNING -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wold-style-cast -Wcast-align
-Woverloaded-virtual -Wconversion -Wsign-conversion -Wmisleading-indentation -Wduplicated-cond
-Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wdouble-promotion
-Wformat=2)
endif()

target_compile_options(nginlib PRIVATE ${ENABLED_WARNING})
target_compile_options(NGin PRIVATE ${ENABLED_WARNING})
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ CPMAddPackage(
GIT_REPOSITORY "https://github.com/catchorg/Catch2.git"
GIT_TAG "v3.5.0"
)
list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")

list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")

# These tests can use the Catch2-provided main
add_executable(tests test.cpp)
Expand All @@ -26,7 +26,7 @@ include(CTest)
include(Catch)
catch_discover_tests(tests)

if(CMAKE_PROJECT_NAME STREQUAL ChessNGin AND CMAKE_BUILD_TYPE MATCHES Debug)
if( NOT MSVC AND CMAKE_BUILD_TYPE MATCHES Debug)
setup_target_for_coverage_lcov(NAME coverage
EXECUTABLE tests
EXCLUDE "/usr/*" "cmake/catch2/*"
Expand Down

0 comments on commit 6541448

Please sign in to comment.