Skip to content

Commit

Permalink
Folder organization and enable github action
Browse files Browse the repository at this point in the history
- Copy the API headers to build/include, which will be easier for used
  by API user
- Enable github action in Win/Mac/Linux

Remove unused files

add test

add test

add test

remove cmakepresets
  • Loading branch information
WisdomToNorth committed Aug 7, 2024
1 parent 7a35376 commit 05e40df
Show file tree
Hide file tree
Showing 44 changed files with 2,539 additions and 2,114 deletions.
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
57 changes: 50 additions & 7 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,11 +26,11 @@ 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/)
INTERFACE include/
${CMAKE_SOURCE_DIR}/build/include
)

if(NOT CAVC_HEADER_ONLY)
if(CAVC_BUILD_SHARED_LIB)
Expand Down Expand Up @@ -58,17 +58,60 @@ if(NOT CAVC_HEADER_ONLY)
target_compile_definitions(${CAVC_C_API_LIB}
PRIVATE CAVC_EXPORTS)
target_include_directories(${CAVC_C_API_LIB}
PUBLIC c_api_include/)
PUBLIC c_api_include/
)
target_link_libraries(${CAVC_C_API_LIB}
PRIVATE ${CAVC_CPP_HEADER_ONLY_LIB})
endif()



# Copy Headers to build/include/cavc
set(CAVC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/build/include/cavc)
set(CAVC_C_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/build/include/cavc_c)
set(CAVC_INTERNAL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/build/include/cavc/internal)

if (EXISTS ${CAVC_INCLUDE_DIR})
file(REMOVE_RECURSE ${CAVC_INCLUDE_DIR})
endif()

set(CAVC_HEADERS
include/intrlineseg2circle2.hpp
include/intrlineseg2lineseg2.hpp
include/mathutils.hpp
include/intrcircle2circle2.hpp
include/vector.hpp
include/plinesegment.hpp
include/polyline.hpp
include/polylinecombine.hpp
include/polylineintersects.hpp
include/polylineoffset.hpp
include/polylineoffsetislands.hpp
include/staticspatialindex.hpp
include/vector2.hpp
)

foreach(CAVC_HEADER ${CAVC_HEADERS})
file(COPY ${CAVC_HEADER} DESTINATION ${CAVC_INCLUDE_DIR})
endforeach()

set(CAVC_INTERNAL_HEADERS
include/internal/diagnostics.hpp
include/internal/common.hpp
)

foreach(CAVC_INTERNAL_HEADER ${CAVC_INTERNAL_HEADERS})
file(COPY ${CAVC_INTERNAL_HEADER} DESTINATION ${CAVC_INTERNAL_INCLUDE_DIR})
endforeach()
file(COPY src/cavaliercontours.h DESTINATION ${CAVC_C_INCLUDE_DIR})

if (NOT_SUBPROJECT AND NOT CAVC_HEADER_ONLY)
# output all libraries and executables to the root build dir for simplicity in running tests with dynamic libs
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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)
2 changes: 1 addition & 1 deletion tests/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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)
Expand Down
19 changes: 0 additions & 19 deletions tests/benchmarks/googlebenchmark.cmake

This file was deleted.

4 changes: 3 additions & 1 deletion tests/polylinefactory/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
add_library(PolylineFactory src/polylinefactory.cpp)

target_include_directories(PolylineFactory
PUBLIC include/)

PUBLIC include/
${CMAKE_SOURCE_DIR}/build/include)

target_link_libraries(PolylineFactory
PUBLIC ${CAVC_CPP_HEADER_ONLY_LIB})
Expand Down
3 changes: 2 additions & 1 deletion tests/polylinefactory/include/polylinefactory.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef CAVC_POLYLINEFACTORY_HPP
#define CAVC_POLYLINEFACTORY_HPP
#include "cavaliercontours.h"

#include "cavc/polyline.hpp"
#include "cavc_c/cavaliercontours.h"

struct cavc_pline_deleter {
void operator()(cavc_pline *pline) { cavc_pline_delete(pline); }
Expand Down
Loading

0 comments on commit 05e40df

Please sign in to comment.