Skip to content

Commit

Permalink
Modernize CMake (#99)
Browse files Browse the repository at this point in the history
* refactor(cmake): add `CPM.cmake`, restructure CMakeLists

* refactor(cmake): update examples

* refactor(cmake): update tests

* fix: missing include

* refactor(cmake): update python bindings

* feat: add sanitizer options

* feat(cmake): add install target

* refactor(cmake/python): use `CMAKE_LIBRARY_OUTPUT_DIRECTORY` when available

* feat(cmake): add sanitizer options for gcc

* fix(cmake): static builds

* refactor(cmake): add messages

* fix(format-project): shellcheck issues

* refactor(cmake/sanitizer): more explicit compiler id check

* fix: update formatting

* fix(workflows): build commands

* fix(workflows(windows): long paths

* fix(CMakeLists): disable VTK rendering group

* docs(readme): update build instructions

* docs(readme): fix test command

* fix: ctest excludes

* refactor: disable sanitizer for msvc and apple clang

* chore: apply cmake-format

* fix(cmake-format): define CPM functions

* fix(vtk): disable libproj support

* Should fix Windows workflow

* revert: formatting

* fix(ci/windows): enable long paths

* refactor(cmake): disable wrapping for vtk  and disable libproj

* refactor(cmake): disable sanitizer by default

* fix(windows): only export symbols for viennals

* refactor(cmake): exclude dependencies from all target

* refactor(cmake): use get-cpm

* refactor(cmake): lower required vtk version

* This should also fix the windows workflows as we've switched to a commit that includes upstream!10542

* fix: formatting

* fix: setup vtk env for targets

* fix: formatting

* fix: remove debug print

* fix(cmakelists): vtk dir on linux

* fix: skip vtk environment on non windows platforms

* fix: formatting

* refactor: more logging, don't use early return in macro

* early return behavior in macro may vary in different cmake versions

* refactor: adjust target naming
  • Loading branch information
Curve authored Dec 7, 2023
1 parent 2e14575 commit 1dda578
Show file tree
Hide file tree
Showing 71 changed files with 603 additions and 1,138 deletions.
3 changes: 3 additions & 0 deletions .cmake-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include: ["cmake/.cpm-format"]
format:
line_width: 100
12 changes: 5 additions & 7 deletions .github/workflows/linux_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,17 @@ jobs:

- name: Configure
run: |
cmake -B ./build \
cmake -B build \
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-D VIENNALS_BUILD_TESTS=ON
- name: Build Dependencies
run: cmake --build ./build --target buildDependencies

- name: Build Tests
run: cmake --build ./build --target buildTests
run: cmake --build build

- name: Run Tests
working-directory: ${{github.workspace}}/build
# Run all tests that are not labeled as benchmark
run: ctest -LE '^benchmark$'
run: ctest -E "Benchmark|Performance"

- name: Trigger Action on ViennaPS Repository
if: ${{ vars.TRIGGER_VIENNAPS == 'true' && github.event_name != 'schedule' && github.event_name != 'pull_request' }}
Expand All @@ -53,6 +50,7 @@ jobs:
token: ${{ secrets.PAT_VIENNAPS }}
repository: ${{github.repository_owner}}/ViennaPS
event-type: viennals-update-linux

linux-python:
runs-on: ubuntu-latest
steps:
Expand All @@ -65,7 +63,7 @@ jobs:
with:
key: viennals-dependency-cache-${{ runner.os }}-${{env.BUILD_TYPE}}-${{ hashFiles( './external/upstream/**CMakeLists.txt' ) }}
path: ${{github.workspace}}/dependencies/Install

- name: Build and install Python module
shell: bash
run: pip3 install --user . -v
11 changes: 4 additions & 7 deletions .github/workflows/macos_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- name: Configure
run: |
cmake -B ./build \
cmake -B build \
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-D VIENNALS_BUILD_TESTS=ON \
-D OpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
Expand All @@ -41,16 +41,13 @@ jobs:
-D OpenMP_CXX_LIB_NAMES="omp" \
-D OpenMP_omp_LIBRARY="$(brew --prefix libomp)/lib/libomp.a"
- name: Build Dependencies
run: cmake --build ./build --target buildDependencies

- name: Build Tests
run: cmake --build ./build --target buildTests
- name: Build
run: cmake --build build

- name: Run Tests
working-directory: ${{github.workspace}}/build
# Run all tests that are not labeled as benchmark
run: ctest -LE '^benchmark$'
run: ctest -E "Benchmark|Performance"

- name: Trigger Action on ViennaPS Repository
if: ${{ vars.TRIGGER_VIENNAPS == 'true' && github.event_name != 'schedule' && github.event_name != 'pull_request' }}
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/windows_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ jobs:
key: viennals-dependency-cache-${{ runner.os }}-${{env.BUILD_TYPE}}-${{ hashFiles( './external/upstream/**CMakeLists.txt' ) }}
path: ${{github.workspace}}/dependencies/Install

- name: Configure Git
# Workaround for windows, as the filename is 260 by default, however
# VTK has some files that exceed this limit, thus we need this workaround.
run: git config --system core.longpaths true

- name: Configure
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DVIENNALS_BUILD_TESTS=ON

- name: Build Dependencies
run: cmake --build ${{github.workspace}}/build --target buildDependencies

- name: Build Tests
run: cmake --build ${{github.workspace}}/build --target buildTests
- name: Build
run: cmake --build ${{github.workspace}}/build

- name: Add VTK to PATH
run: echo "${{github.workspace}}\dependencies\Install\vtk_external\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Run Tests
working-directory: ${{github.workspace}}/build
# Run all tests except those that are labeled as benchmark
run: ctest -LE "^benchmark$" -j 2 --output-on-failure --timeout 1800 -C ${{env.BUILD_TYPE}}
run: ctest -E "Benchmark|Performance" -j 2 --output-on-failure --timeout 1800 -C ${{env.BUILD_TYPE}}

- name: Trigger Action on ViennaPS Repository
if: ${{ vars.TRIGGER_VIENNAPS == 'true' && github.event_name != 'schedule' && github.event_name != 'pull_request' }}
Expand All @@ -54,6 +56,7 @@ jobs:
token: ${{ secrets.PAT_VIENNAPS }}
repository: ${{github.repository_owner}}/ViennaPS
event-type: viennals-update-windows

windows-python:
runs-on: windows-latest

Expand All @@ -68,6 +71,11 @@ jobs:
key: viennals-dependency-cache-${{ runner.os }}-${{env.BUILD_TYPE}}-${{ hashFiles( './external/upstream/**CMakeLists.txt' ) }}
path: ${{github.workspace}}/dependencies/Install

- name: Configure Git
# Workaround for windows, as the filename is 260 by default, however
# VTK has some files that exceed this limit, thus we need this workaround.
run: git config --system core.longpaths true

- name: Build and install Python module
shell: bash
run: pip3 install --user . -v
run: pip3 install --user . -v
Loading

0 comments on commit 1dda578

Please sign in to comment.