Skip to content

Commit

Permalink
Cross-platform Makefile (#146)
Browse files Browse the repository at this point in the history
* Default Generator

* Fix: Ignore cache for Mac

* Fix: Windows nmake

* Windows: NMake build

* test-only: Reuse build

* Rename fuzzylite-config.cmake to fuzzylite.cmake
  • Loading branch information
jcrada committed Mar 6, 2024
1 parent e13f2e8 commit ab1c95f
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 73 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/LinuxFullBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler_version: [ "13", "14", "15"]
compiler_version: [ "13", "14", "15" ]
build_type: [ "release", "debug" ]
use_cpp98: [ "OFF", "ON" ]
use_float: [ "OFF", "ON" ]
Expand All @@ -31,9 +31,9 @@ jobs:
env:
CXX: clang++-${{ matrix.compiler_version }}
run: |
cmake -B build/ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_CPP98=${{ matrix.use_cpp98 }} -DFL_USE_FLOAT=${{ matrix.use_float }} .
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
make build
make test
build-gcc:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -61,6 +61,6 @@ jobs:
env:
CXX: g++-${{ matrix.compiler_version }}
run: |
cmake -B build/ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_CPP98=${{ matrix.use_cpp98 }} -DFL_USE_FLOAT=${{ matrix.use_float }} .
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
make build
make test
13 changes: 6 additions & 7 deletions .github/workflows/LinuxMediumBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,19 @@ jobs:
env:
CXX: ${{ matrix.use_cxx }}
run: |
cmake -B build/ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_CPP98=${{ matrix.use_cpp98 }} -DFL_USE_FLOAT=${{ matrix.use_float }} .
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
make build
make test
- name: Coverage
if: ${{ matrix.use_cxx == 'clang++-15' && matrix.build_type == 'release' && matrix.use_cpp98 == 'OFF' && matrix.use_float == 'OFF' }}
env:
CXX: "clang++-15"
GCOV: "llvm-cov-15 gcov"
run: |
echo '${{matrix}}'
cmake -B build/ -DFL_BUILD_COVERAGE=ON .
cmake --build build/ --parallel --target fl-test
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }} COVERAGE=ON
make build
make test
pip install gcovr
make coverage
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/LinuxQuickBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
steps:
- uses: actions/checkout@v4

# - name: Linting FuzzyLite
# run: make lint
# - name: Linting FuzzyLite
# run: make lint

- name: Restore cmake dependencies
id: cache-restore-cmake-deps
Expand All @@ -32,9 +32,9 @@ jobs:
env:
CXX: ${{ matrix.use_cxx }}
run: |
cmake -B build/ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_BUILD_COVERAGE=ON.
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} COVERAGE=ON
make build
make test
- name: Coverage
env:
Expand Down
51 changes: 28 additions & 23 deletions .github/workflows/MacFullBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:

- name: Building FuzzyLite
run: |
cmake -B build/ -G"Xcode" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_CPP98=${{ matrix.use_cpp98 }} -DFL_USE_FLOAT=${{ matrix.use_float }} .
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
make build
make test
build-clang:
runs-on: macos-latest
Expand All @@ -45,19 +45,22 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Restore cmake dependencies
id: cache-restore-cmake-deps
uses: actions/cache/restore@v4
with:
path: |
build/_deps
key: ${{ runner.os }}-cmake-deps
# Not restoring because dependency would have been built with Xcode
# - name: Restore cmake dependencies
# id: cache-restore-cmake-deps
# uses: actions/cache/restore@v4
# with:
# path: |
# build/_deps
# key: ${{ runner.os }}-cmake-deps

- name: Building FuzzyLite
env:
CMAKE_GENERATOR: "Unix Makefiles"
run: |
cmake -B build/ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_CPP98=${{ matrix.use_cpp98 }} -DFL_USE_FLOAT=${{ matrix.use_float }} .
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
make build
make test
build-gcc:
runs-on: ubuntu-latest
Expand All @@ -73,18 +76,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Restore cmake dependencies
id: cache-restore-cmake-deps
uses: actions/cache/restore@v4
with:
path: |
build/_deps
key: ${{ runner.os }}-cmake-deps
# Not restoring because dependency would have been built with Xcode
# - name: Restore cmake dependencies
# id: cache-restore-cmake-deps
# uses: actions/cache/restore@v4
# with:
# path: |
# build/_deps
# key: ${{ runner.os }}-cmake-deps

- name: Building FuzzyLite
env:
CXX: g++-${{ matrix.compiler_version }}
CMAKE_GENERATOR: "Unix Makefiles"
run: |
cmake -B build/ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_CPP98=${{ matrix.use_cpp98 }} -DFL_USE_FLOAT=${{ matrix.use_float }} .
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
make build
make test
6 changes: 3 additions & 3 deletions .github/workflows/MacMediumBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:

- name: Building FuzzyLite
run: |
cmake -B build/ -G"Xcode" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_CPP98=${{ matrix.use_cpp98 }} -DFL_USE_FLOAT=${{ matrix.use_float }} .
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
make build
make test
6 changes: 3 additions & 3 deletions .github/workflows/MacQuickBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:

- name: Building FuzzyLite
run: |
cmake -B build/ -G"Xcode" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} .
cmake --build build/ --parallel
ctest --test-dir build/
make configure BUILD=${{ matrix.build_type }}
make build
make test
- name: Save cmake dependencies
if: steps.cache-restore-cmake-deps.outputs.cache-hit != 'true'
Expand Down
41 changes: 37 additions & 4 deletions .github/workflows/WindowsFullBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [ "build/*", "build-windows/*" ]

jobs:
build:
build-vs:
runs-on: windows-latest

strategy:
Expand All @@ -32,6 +32,39 @@ jobs:
- name: Building FuzzyLite
shell: cmd
run: |
cmake -B build/ -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFL_CPP98=${{ matrix.use_cpp98 }} -DFL_USE_FLOAT=${{ matrix.use_float }} .
cmake --build build/ --parallel
ctest --test-dir build/
nmake configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
nmake build
nmake test
build-nmake:
runs-on: windows-latest

strategy:
fail-fast: false
matrix:
platform: [ "x64", "win32" ]
build_type: [ "release", "debug" ]
use_cpp98: [ "OFF", "ON" ]
use_float: [ "OFF", "ON" ]

steps:
- uses: actions/checkout@v4

- uses: ilammy/msvc-dev-cmd@v1
# Not restoring because dependency would have been built with VS
# - name: Restore cmake dependencies
# id: cache-restore-cmake-deps
# uses: actions/cache/restore@v4
# with:
# path: |
# build/_deps
# key: ${{ runner.os }}-cmake-deps

- name: Building FuzzyLite
shell: cmd
env:
CMAKE_GENERATOR: "NMake Makefiles"
run: |
nmake configure BUILD=${{ matrix.build_type }} CPP98=${{ matrix.use_cpp98 }} FLOAT=${{ matrix.use_float }}
nmake build
nmake test
6 changes: 3 additions & 3 deletions .github/workflows/WindowsMediumBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ jobs:
- name: Building FuzzyLite
shell: cmd
run: |
cmake -B build/ -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} .
cmake --build build/ --parallel
ctest --test-dir build/
nmake configure BUILD=${{ matrix.build_type }}
nmake build
nmake test
6 changes: 3 additions & 3 deletions .github/workflows/WindowsQuickBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
- name: Building FuzzyLite
shell: cmd
run: |
cmake -B build/ -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} .
cmake --build build/ --parallel
ctest --test-dir build/
nmake configure BUILD=${{ matrix.build_type }}
nmake build
nmake test
- name: Save cmake dependencies
if: steps.cache-restore-cmake-deps.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ install(TARGETS ${fl-targets} EXPORT fuzzylite-config
)
# Store the fuzzylite CMake config for other projects to use
install(EXPORT fuzzylite-config DESTINATION share/fuzzylite/cmake)
export(TARGETS ${fl-targets} FILE fuzzylite-config.cmake)
export(TARGETS ${fl-targets} FILE fuzzylite.cmake)

install(DIRECTORY fuzzylite/ DESTINATION ${FL_INSTALL_INCLUDEDIR}/fuzzylite)
install(DIRECTORY fl/ DESTINATION ${FL_INSTALL_INCLUDEDIR}/fl)
Expand Down
21 changes: 7 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,48 @@
BUILD = debug
CPP98 = OFF
FLOAT = OFF
COVERAGE = ON
COVERAGE = OFF

.phonywin:

all: configure build test

.PHONY: clean
clean:
rm -rf build/

.PHONY: configure
configure:
cmake -B build/ -DCMAKE_BUILD_TYPE=$(BUILD) -DFL_CPP98=$(CPP98) -DFL_USE_FLOAT=$(FLOAT) -DFL_BUILD_COVERAGE=$(COVERAGE) .
cmake -B build/ -DCMAKE_BUILD_TYPE=$(BUILD) -DFL_CPP98=$(CPP98) -DFL_USE_FLOAT=$(FLOAT) -DFL_BUILD_COVERAGE=$(COVERAGE)

.PHONY: build
build:
build: .phonywin
cmake --build build/ --parallel

.PHONY: test
test:
test: .phonywin
ctest --test-dir build/

.PHONY: test-only
test-only:
$(MAKE) configure && \
cmake -B build/ && \
cmake --build build/ --parallel --target fl-test && \
$(MAKE) test

.PHONY: install
install:
cmake --build build/ --target install

.PHONY: coverage
coverage:
# pip install gcovr
gcovr -r src/ build/CMakeFiles/fl-test.dir/ --coveralls build/coveralls.json --html build/coverage.html --html-details --sort uncovered-percent --html-theme github.blue --txt --txt-summary
# open build/coverage.html

.PHONY: clean-coverage
clean-coverage:
find build/CMakeFiles/fl-test.dir -type f -name '*.gc' -print0 | xargs -0 rm

.PHONY: jupyter
jupyter:
docker build -f examples/notebook/Dockerfile -t xeus . && docker run --rm -p 8888:8888 -v.:/mnt/fuzzylite -it xeus jupyter notebook --allow-root --ip 0.0.0.0


CLANG_FORMAT=clang-format --style=file -i

.PHONY: format
format:
# headers
find fuzzylite -type f -name '*.h' -print0 | xargs -0 $(CLANG_FORMAT)
Expand All @@ -60,7 +53,6 @@ format:
# tests
find test -type f -name '*.cpp' -print0 | xargs -0 $(CLANG_FORMAT)

.PHONY: lint
lint:
# headers
find fuzzylite -type f -name '*.h' -print0 | xargs -0 $(CLANG_FORMAT) --dry-run --Werror
Expand All @@ -71,3 +63,4 @@ lint:
# tests
find test -type f -name '*.cpp' -print0 | xargs -0 $(CLANG_FORMAT) --dry-run --Werror


0 comments on commit ab1c95f

Please sign in to comment.