Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder organization and enable github action #66

Merged
merged 1 commit into from
Aug 11, 2024
Merged
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
43 changes: 0 additions & 43 deletions .github/workflows/CI_tests.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Linux

on:
[push, pull_request]

jobs:
build-linux-gcc:
runs-on: ubuntu-latest
name: linux-gcc-relase

env:
targetName: Gui
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install brew and dependencies
run: |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile
echo "export PATH=\"$(brew --prefix)/bin:$PATH\"" >>~/.profile
source ~/.profile
brew install googletest
brew install google-benchmark
brew install ninja

- name: Ninja gcc build Release
working-directory: ${{github.workspace}}
run: |
source ~/.profile
cmake --no-warn-unused-cli \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-B${{github.workspace}}/build/Linux_Ninja_Release \
-S${{github.workspace}} -G Ninja
cmake --build ${{github.workspace}}/build/Linux_Ninja_Release --config Release --target all --

- name: Execute Unit Tests
working-directory: ${{github.workspace}}/build/Linux_Ninja_Release
run: |
ctest -T test -j 2 --output-on-failure

39 changes: 39 additions & 0 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: macOS

on:
[push, pull_request]

jobs:
mac-clang:
runs-on: macos-latest
name: mac-clang-release

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install brew and dependencies
run: |
brew install ninja
brew install googletest
brew install google-benchmark

- name: Build Release
working-directory: ${{github.workspace}}
run: |
export PATH="/usr/local/opt/llvm/bin:$PATH"
cmake \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DCMAKE_C_COMPILER:FILEPATH=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-B${{github.workspace}}/build/Mac_Ninja_Release \
-S${{github.workspace}} -G Ninja
cmake --build ${{github.workspace}}/build/Mac_Ninja_Release --config Release --target all --

- name: Execute Unit Tests Release
working-directory: ${{github.workspace}}/build/Mac_Ninja_Release
run: |
ctest -T test -j 3 --output-on-failure

67 changes: 67 additions & 0 deletions .github/workflows/ci_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Windows

on:
[push, pull_request]

jobs:
windows-msvc:

runs-on: windows-latest
name: windows-msvc-release

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Configure Compiler
uses: ilammy/msvc-dev-cmd@v1

- name: Cache Vcpkg Packages
id: vcpkg-cache
uses: actions/cache@v3
with:
path: vcpkg_ci_env
key: vcpkg-cache-windowsci
restore-keys: |
vcpkg-cache-windowsci

- name: Install Vcpkg
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
shell: powershell
run: |
echo "VCPKG_ROOT=" >> $GITHUB_ENV
git clone https://github.com/Microsoft/vcpkg.git vcpkg_ci_env
cd vcpkg_ci_env
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
Add-Content -Path .\triplets\x64-windows.cmake -Value "set(VCPKG_BUILD_TYPE release)"
vcpkg install gtest --triplet x64-windows
vcpkg install benchmark --triplet x64-windows
Remove-Item -Recurse -Force buildtrees
Remove-Item -Recurse -Force downloads
Remove-Item -Recurse -Force packages
Remove-Item -Recurse -Force ports
Remove-Item -Recurse -Force triplets
ls

- name: Build Release
working-directory: ${{github.workspace}}
run: |
cmd.exe /k "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
cmake -DVCPKG_MANIFEST_MODE=OFF `
-DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_CXX_STANDARD=20 `
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=cl.exe `
-DCMAKE_CXX_COMPILER=cl.exe `
-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg_ci_env/scripts/buildsystems/vcpkg.cmake `
-B${{github.workspace}}/build/win_msvc_release `
-S${{github.workspace}} -G Ninja
cmake --build ${{github.workspace}}/build/win_msvc_release --config Release --target all --

- name: Execute Unit Tests Release
working-directory: ${{github.workspace}}/build/win_msvc_release
shell: cmd
env:
PATH: ${{env.PATH}}
run: |
ctest -T test -j 2 --output-on-failure

26 changes: 25 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
*.user
# Forder
.vs/*
.idea/*
x64/*
CMakeLists.txt.user
out
build
install
*.ts
*.qm
.vscode

package
dist

regressions/output
regressions/Files
WinUserSetting.cmake
launch.json
settings.json
filename.txt
CMakePresets.json

.VSCodeCounter/*
.DS_Store
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.21)

# detect if CavalierContours is a subproject or not
# do not include examples, tests, and benchmarks in that case
if (NOT DEFINED PROJECT_NAME)
set(NOT_SUBPROJECT ON)
endif()


project(CavalierContours VERSION 0.1)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -16,6 +15,7 @@ if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif ()

# Build options
option(CAVC_HEADER_ONLY "C++ header only library of CavalierContours, if ON then no library is built" OFF)
option(CAVC_BUILD_SHARED_LIB "Build the C API CavalierContours dynamic shared library (SET OFF for static library)" ON)

Expand All @@ -26,8 +26,6 @@ else()
set(CAVC_C_API_LIB ${PROJECT_NAME})
endif()



add_library(${CAVC_CPP_HEADER_ONLY_LIB} INTERFACE)
target_include_directories(${CAVC_CPP_HEADER_ONLY_LIB}
INTERFACE include/)
Expand Down Expand Up @@ -68,7 +66,8 @@ if (NOT_SUBPROJECT AND NOT CAVC_HEADER_ONLY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_subdirectory(examples)
include(CTest)
find_package(GTest REQUIRED)
include(GoogleTest)
enable_testing()
add_subdirectory(tests)
endif()
1 change: 0 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.5)
macro(add_example name)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name}
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.11)
add_subdirectory(polylinefactory)
add_subdirectory(tests)
add_subdirectory(benchmarks)
27 changes: 17 additions & 10 deletions tests/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
cmake_minimum_required(VERSION 3.11)

include(googlebenchmark.cmake)
include(clipper.cmake)
find_package(benchmark REQUIRED)

macro(add_benchmark name)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name}
PRIVATE ${CAVC_CPP_HEADER_ONLY_LIB})
target_link_libraries(${name}
PRIVATE PolylineFactory)
target_link_libraries(${name}
PRIVATE benchmark::benchmark)
if (MSVC)
target_link_options(${name} PRIVATE $<$<CONFIG:RELWITHDEBINFO>:/PROFILE>)
add_executable(${name} ${name}.cpp)

target_include_directories(${name}
PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/include
${benchmark_INCLUDE_DIRS})

target_link_libraries(${name}
PRIVATE
${CAVC_CPP_HEADER_ONLY_LIB}
PolylineFactory
benchmark::benchmark)

if (MSVC)
target_link_options(${name} PRIVATE $<$<CONFIG:RELWITHDEBINFO>:/PROFILE>)
endif()
endmacro()

Expand Down
19 changes: 0 additions & 19 deletions tests/benchmarks/googlebenchmark.cmake

This file was deleted.

48 changes: 26 additions & 22 deletions tests/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
cmake_minimum_required(VERSION 3.11)
include (googletest.cmake)
cmake_minimum_required(VERSION 3.21)

macro(cavc_add_test name)
add_executable(${name} ${name}.cpp)

target_include_directories(${name}
PRIVATE include/)
set(gtesthelper
${CMAKE_CURRENT_SOURCE_DIR}/c_api_test_helpers.hpp
${CMAKE_CURRENT_SOURCE_DIR}/testhelpers.hpp
)

target_link_libraries(${name}
PRIVATE PolylineFactory)
macro(cavc_add_test name)
add_executable(${name} ${name}.cpp ${gtesthelper})

target_link_libraries(${name}
PRIVATE ${CAVC_C_API_LIB})
target_include_directories(${name}
PRIVATE
${GTEST_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/include)

target_link_libraries(${name}
PRIVATE gtest_main gtest gmock)
target_link_libraries(${name}
PRIVATE
PolylineFactory
${CAVC_CPP_HEADER_ONLY_LIB}
${CAVC_C_API_LIB}
GTest::gtest_main
GTest::gtest
GTest::gmock)

# note: adding executable as single test rather than discovering tests via gtest_discover_tests
# because it adds parmeterized tests as individual tests and ctest runs them one by one which is
# quite slow
add_test(NAME ${name} COMMAND ${name})
gtest_add_tests(TARGET ${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endmacro()

cavc_add_test(cavc_pline_tests)
cavc_add_test(cavc_pline_function_tests)
cavc_add_test(cavc_parallel_offset_tests)
cavc_add_test(cavc_combine_plines_tests)
cavc_add_test(staticspatialindex_tests)
cavc_add_test(TEST_cavc_pline)
cavc_add_test(TEST_cavc_pline_function)
cavc_add_test(TEST_cavc_parallel_offset)
cavc_add_test(TEST_cavc_combine_plines)
cavc_add_test(TEST_staticspatialindex)
Loading
Loading