Skip to content

Commit

Permalink
Add build dir for cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
markkohdev committed Aug 19, 2024
1 parent 753175f commit 4f98c93
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 45 deletions.
74 changes: 35 additions & 39 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,41 @@ jobs:
with:
clang-format-version: 16

run-cpp-tests:
runs-on: ${{ matrix.os }}
continue-on-error: true
defaults:
run:
working-directory: cpp
strategy:
matrix:
# TODO: Switch back to macos-latest once https://github.com/actions/python-versions/pull/114 is fixed
os:
- 'ubuntu-latest'
# TODO: Fix failing CMake build on windows:
# Error: `cl : command line error D8016: '/O2' and '/RTC1' command-line options are incompatible [D:\a\voyager\voyager\cpp\test\test.vcxproj]`
# I've tried passing CXX flags, but windows doesn't seem to respect disabling runtime checks with /RTC1 or disabling optimizations with /O2
- windows-latest
- macos-12
name: Test C++ on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install CMake (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
choco install ninja
- name: Install CMake (MacOS)
if: matrix.os == 'macos-12'
run: brew install cmake
- name: Install CMake (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y cmake
- name: Run tests
run: make test

run-java-tests:
continue-on-error: true
name: Test with Java ${{ matrix.java-version }} on ${{ matrix.os }}
Expand Down Expand Up @@ -217,45 +252,6 @@ jobs:
asv machine --yes
asv continuous --sort name --no-only-changed refs/remotes/origin/main ${{ github.sha }} | tee >(sed '1,/All benchmarks:/d' > $GITHUB_STEP_SUMMARY)
run-cpp-tests:
runs-on: ${{ matrix.os }}
continue-on-error: true
defaults:
run:
working-directory: cpp
strategy:
matrix:
# TODO: Switch back to macos-latest once https://github.com/actions/python-versions/pull/114 is fixed
os:
- 'ubuntu-latest'
# TODO: Fix failing CMake build on windows:
# Error: `cl : command line error D8016: '/O2' and '/RTC1' command-line options are incompatible [D:\a\voyager\voyager\cpp\test\test.vcxproj]`
# I've tried passing CXX flags, but windows doesn't seem to respect disabling runtime checks with /RTC1 or disabling optimizations with /O2
# - windows-latest
- macos-12
name: Test C++ on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install CMake (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
choco install ninja
- name: Install CMake (MacOS)
if: matrix.os == 'macos-12'
run: brew install cmake
- name: Install CMake (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y cmake
- name: Configure CMake
run: cmake .
- name: Build with CMake
run: make
- name: Run Tests (if any)
run: cat Makefile

build-python-wheels:
needs: [run-python-tests, run-python-tests-with-address-sanitizer]
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.egg-info/
build/
*/build/*
!build/.gitkeep
dist/
tmp/
__pycache__/
Expand All @@ -26,6 +27,7 @@ CMakeFiles
CMakeScripts
Testing
Makefile
!cpp/Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
Expand Down
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ To build the C++ library with `cmake`, use the following commands:
```shell
cd cpp
git submodule update --init --recursive
cmake .
make
make build
```

## Testing
Expand Down Expand Up @@ -114,8 +113,6 @@ To run the C++ tests, use the following commands:
```shell
cd cpp
git submodule update --init --recursive
cmake .
make
make test
```

Expand Down
3 changes: 2 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if (MSVC)
string(REGEX REPLACE "/RTC1" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()

enable_testing()

add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
Expand All @@ -37,4 +39,3 @@ add_custom_target(format
COMMENT "Running C++ formatter"
)

enable_testing()
15 changes: 15 additions & 0 deletions cpp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
default_target: build

BUILD_DIR := build

cmake:
cmake -S . -B $(BUILD_DIR)

build: cmake
cmake --build ${BUILD_DIR}

test: build
cmake --build ${BUILD_DIR} --target test

clean:
rm -rf ${BUILD_DIR}/*
Empty file added cpp/build/.gitkeep
Empty file.
4 changes: 4 additions & 0 deletions cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ target_link_libraries(VoyagerTests

# Add the tests
add_test(NAME VoyagerTests COMMAND VoyagerTests)

# Discover tests using Doctest
include(${CMAKE_SOURCE_DIR}/include/doctest/scripts/cmake/doctest.cmake)
doctest_discover_tests(VoyagerTests)

0 comments on commit 4f98c93

Please sign in to comment.