Skip to content

Commit 4cb0199

Browse files
authored
Switch to CPM and clean up code (#4)
* Switch from FetchContent to [CPM](https://github.com/cpm-cmake/CPM.cmake) * Use `config.hpp` instead of `target_compile_definitions` * Rename CMake options * Add `spdlog` dependency for logging * Renamed parameters to: * `e[ab][01]_t[01]` for edge-edge vertices * `v_t[01]` and `f[012]_t[01]` for vertex-face vertices * `[abcd]_t[01]` for generic vertices * Combined VF and EE CCD into one generic function * Changed `max_itr` to type `long` * Add more doxygen comments * Add `pbar` and CLI11 to Tight_Inclusion_bin * Update README.md * Removed figures from the repo
1 parent d079924 commit 4cb0199

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1763
-1409
lines changed

.github/workflows/continuous.yml

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ name: Build
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [main]
76
pull_request:
8-
branches:
9-
- main
107

118
env:
129
CTEST_OUTPUT_ON_FAILURE: ON
@@ -23,36 +20,37 @@ jobs:
2320
strategy:
2421
fail-fast: false
2522
matrix:
26-
os: [ubuntu-20.04, macos-latest]
23+
os: [ubuntu-latest, macos-latest]
2724
config: [Debug, Release]
2825
include:
2926
- os: macos-latest
3027
name: macOS
31-
- os: ubuntu-20.04
28+
- os: ubuntu-latest
3229
name: Linux
3330
steps:
3431
- name: Checkout repository
35-
uses: actions/checkout@v1
32+
uses: actions/checkout@v3.5.3
3633
with:
3734
fetch-depth: 10
3835

3936
- name: Dependencies (Linux)
4037
if: runner.os == 'Linux'
4138
run: |
4239
sudo apt-get update
43-
sudo apt-get -o Acquire::Retries=3 install \
44-
ccache \
45-
libgmp-dev
40+
sudo apt-get -o Acquire::Retries=3 install ccache libgmp-dev
41+
echo 'CACHE_PATH=~/.cache/ccache' >> "$GITHUB_ENV"
4642
4743
- name: Dependencies (macOS)
4844
if: runner.os == 'macOS'
49-
run: brew install ccache gmp
45+
run: |
46+
brew install ccache gmp
47+
echo 'CACHE_PATH=~/Library/Caches/ccache' >> "$GITHUB_ENV"
5048
5149
- name: Cache Build
5250
id: cache-build
53-
uses: actions/cache@v1
51+
uses: actions/cache@v3.0.11
5452
with:
55-
path: ~/.ccache
53+
path: ${{ env.CACHE_PATH }}
5654
key: ${{ runner.os }}-${{ matrix.config }}-cache
5755

5856
- name: Prepare ccache
@@ -67,8 +65,7 @@ jobs:
6765
cd build
6866
cmake .. \
6967
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
70-
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
71-
-DTIGHT_INCLUSION_SUPPRESS_PROGRESS_OUTPUT=ON
68+
-DCMAKE_BUILD_TYPE=${{ matrix.config }}
7269
7370
- name: Configure (Release)
7471
if: matrix.config == 'Release'
@@ -79,43 +76,40 @@ jobs:
7976
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
8077
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
8178
-DTIGHT_INCLUSION_WITH_GMP=ON \
82-
-DTIGHT_INCLUSION_WITH_TESTS=ON \
83-
-DTIGHT_INCLUSION_SUPPRESS_PROGRESS_OUTPUT=ON
79+
-DTIGHT_INCLUSION_WITH_SAMPLE_QUERIES=ON
8480
8581
- name: Build
8682
run: cd build; make -j2; ccache --show-stats
8783

8884
- name: Tests
89-
run: cd build; ./Tight_Inclusion_bin
85+
run: cd build; ./app/Tight_Inclusion_bin --no-pbar
9086

9187
####################
9288
# Windows
9389
####################
9490

9591
Windows:
96-
runs-on: windows-2019
97-
env:
98-
CC: cl.exe
99-
CXX: cl.exe
100-
SCCACHE_IDLE_TIMEOUT: "12000"
92+
runs-on: windows-latest
10193
strategy:
10294
fail-fast: false
10395
matrix:
10496
config: [Debug, Release]
10597
steps:
10698
- name: Checkout repository
107-
uses: actions/checkout@v1
99+
uses: actions/checkout@v3.5.3
108100
with:
109101
fetch-depth: 10
110-
- uses: seanmiddleditch/gha-setup-ninja@master
102+
103+
- name: Install Ninja
104+
uses: seanmiddleditch/gha-setup-ninja@master
111105

112106
- name: Set env
113107
run: |
114108
echo "appdata=$env:LOCALAPPDATA" >> ${env:GITHUB_ENV}
115109
116110
- name: Cache build
117111
id: cache-build
118-
uses: actions/cache@v2
112+
uses: actions/cache@v3.0.11
119113
with:
120114
path: ${{ env.appdata }}\Mozilla\sccache
121115
key: ${{ runner.os }}-${{ matrix.config }}-cache-${{ github.sha }}
@@ -132,18 +126,15 @@ jobs:
132126
- name: Configure and build
133127
shell: cmd
134128
run: |
135-
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
136-
cmake --version
129+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
137130
cmake -G Ninja ^
138131
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^
139132
-DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
140-
-DTIGHT_INCLUSION_SUPPRESS_PROGRESS_OUTPUT=ON ^
141133
-B build ^
142134
-S .
143-
cd build
144-
ninja -j1
135+
cmake --build build -j1
145136
146137
- name: Tests
147138
run: |
148139
cd build
149-
./Tight_Inclusion_bin
140+
./app/Tight_Inclusion_bin --no-pbar

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ external
230230
sample-queries
231231

232232
*.nosync
233+
233234
###############################################################################
235+
234236
paper/
235-
fig/*.pdf
237+
TightInclusionOptions.cmake
238+
src/tight_inclusion/config.hpp
239+
app/config.hpp

CMakeLists.txt

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ else()
77
endif()
88

99
# Check required CMake version
10-
set(REQUIRED_CMAKE_VERSION "3.14.0")
10+
set(REQUIRED_CMAKE_VERSION "3.18.0")
1111
if(TIGHT_INCLUSION_TOPLEVEL_PROJECT)
1212
cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})
1313
else()
@@ -24,24 +24,50 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/TightInclusionOptions.cmake)
2424
include(${CMAKE_CURRENT_SOURCE_DIR}/TightInclusionOptions.cmake)
2525
endif()
2626

27+
# Enable ccache if available
28+
find_program(CCACHE_PROGRAM ccache)
29+
if(CCACHE_PROGRAM)
30+
option(TIGHT_INCLUSION_WITH_CCACHE "Enable ccache when building Tight Inclusion" ${TIGHT_INCLUSION_TOPLEVEL_PROJECT})
31+
else()
32+
option(TIGHT_INCLUSION_WITH_CCACHE "Enable ccache when building Tight Inclusion" OFF)
33+
endif()
34+
if(TIGHT_INCLUSION_WITH_CCACHE AND CCACHE_PROGRAM)
35+
message(STATUS "Enabling Ccache support")
36+
set(ccacheEnv
37+
CCACHE_BASEDIR=${CMAKE_BINARY_DIR}
38+
CCACHE_SLOPPINESS=clang_index_store,include_file_ctime,include_file_mtime,locale,pch_defines,time_macros
39+
)
40+
foreach(lang IN ITEMS C CXX)
41+
set(CMAKE_${lang}_COMPILER_LAUNCHER
42+
${CMAKE_COMMAND} -E env ${ccacheEnv} ${CCACHE_PROGRAM}
43+
)
44+
endforeach()
45+
endif()
46+
47+
################################################################################
48+
# CMake Policies
49+
################################################################################
50+
51+
cmake_policy(SET CMP0054 NEW) # Only interpret if() arguments as variables or keywords when unquoted.
52+
cmake_policy(SET CMP0076 NEW) # target_sources() command converts relative paths to absolute.
53+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
54+
cmake_policy(SET CMP0135 NEW) # Set the timestamps of all extracted contents to the time of the extraction.
55+
endif()
56+
2757
################################################################################
2858

2959
project(TightInclusion
3060
DESCRIPTION "Tight Inclusion CCD"
31-
LANGUAGES CXX)
61+
LANGUAGES CXX
62+
VERSION "1.0.4")
3263

33-
OPTION(TIGHT_INCLUSION_WITH_TESTS "Enable test functions" OFF)
34-
OPTION(TIGHT_INCLUSION_WITH_GMP "Enable rational based predicates, for debug" OFF)
35-
OPTION(TIGHT_INCLUSION_WITH_TIMER "Enable profiling timers, for debug" OFF)
36-
OPTION(TIGHT_INCLUSION_WITH_DOUBLE_PRECISION "Enable double precision floating point numbers as input" ON)
37-
OPTION(TIGHT_INCLUSION_LIMIT_QUEUE_SIZE "Enable limitation of maximal queue size" OFF)
38-
39-
# Option to supress progress output when on GH actions.
40-
OPTION(TIGHT_INCLUSION_SUPPRESS_PROGRESS_OUTPUT "Enable limitation of maximal queue size" OFF)
41-
mark_as_advanced(TIGHT_INCLUSION_SUPPRESS_PROGRESS_OUTPUT)
64+
option(TIGHT_INCLUSION_WITH_GMP "Enable rational based predicates (for debugging)" OFF)
65+
option(TIGHT_INCLUSION_WITH_TIMER "Enable profiling timers (for debugging)" OFF)
66+
option(TIGHT_INCLUSION_WITH_DOUBLE_PRECISION "Enable double precision floating point numbers as input" ON)
67+
option(TIGHT_INCLUSION_LIMIT_QUEUE_SIZE "Enable limitation of maximal queue size" OFF)
4268

4369
include(CMakeDependentOption)
44-
cmake_dependent_option(TIGHT_INCLUSION_FLOAT_WITH_DOUBLE_INPUT "Enable converting double queries to float" OFF "TIGHT_INCLUSION_WITH_DOUBLE_PRECISION" OFF)
70+
cmake_dependent_option(TIGHT_INCLUSION_FLOAT_WITH_DOUBLE_INPUT "Enable converting double queries to float" OFF "TIGHT_INCLUSION_WITH_DOUBLE_PRECISION" ON)
4571

4672
# Set default minimum C++ standard
4773
if(TIGHT_INCLUSION_TOPLEVEL_PROJECT)
@@ -51,12 +77,19 @@ if(TIGHT_INCLUSION_TOPLEVEL_PROJECT)
5177
endif()
5278

5379
### Configuration
80+
set(TIGHT_INCLUSION_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src/tight_inclusion")
81+
set(TIGHT_INCLUSION_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src")
82+
5483
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/tight_inclusion/")
5584
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/recipes/")
5685
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/find/")
5786

58-
# Tight Inclusion utils
59-
include(tight_inclusion_utils)
87+
# General CMake utils
88+
include(tight_inclusion_cpm_cache)
89+
include(tight_inclusion_use_colors)
90+
91+
# Generate position-independent code by default
92+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
6093

6194
################################################################################
6295
# Tight Inclusion Library
@@ -66,10 +99,16 @@ include(tight_inclusion_utils)
6699
add_library(tight_inclusion)
67100
add_library(tight_inclusion::tight_inclusion ALIAS tight_inclusion)
68101

69-
add_subdirectory(src/tight_inclusion)
102+
# Fill in configuration options
103+
configure_file(
104+
"${TIGHT_INCLUSION_SOURCE_DIR}/config.hpp.in"
105+
"${TIGHT_INCLUSION_SOURCE_DIR}/config.hpp")
106+
107+
# Add source and header files to tight_inclusion
108+
add_subdirectory("${TIGHT_INCLUSION_SOURCE_DIR}")
70109

71110
# Public include directory for Tight Inclusion
72-
target_include_directories(tight_inclusion PUBLIC src)
111+
target_include_directories(tight_inclusion PUBLIC "${TIGHT_INCLUSION_INCLUDE_DIR}")
73112

74113
################################################################################
75114
# Optional Definitions
@@ -82,45 +121,23 @@ target_compile_definitions(tight_inclusion PUBLIC NOMINMAX)
82121
# Dependencies
83122
################################################################################
84123

85-
# Extra warnings
86-
include(tight_inclusion_warnings)
87-
target_link_libraries(tight_inclusion PRIVATE tight_inclusion::warnings)
88-
89-
# libigl
124+
# Eigen
90125
include(eigen)
91126
target_link_libraries(tight_inclusion PUBLIC Eigen3::Eigen)
92127

128+
# Logger
129+
include(spdlog)
130+
target_link_libraries(tight_inclusion PUBLIC spdlog::spdlog)
131+
93132
# GMP (optional)
94-
if(TIGHT_INCLUSION_WITH_GMP OR TIGHT_INCLUSION_WITH_TESTS)
133+
if(TIGHT_INCLUSION_WITH_GMP)
95134
find_package(GMP REQUIRED)
96135
target_link_libraries(tight_inclusion PUBLIC gmp::gmp)
97-
target_compile_definitions(tight_inclusion PUBLIC TIGHT_INCLUSION_USE_GMP)
98136
endif()
99137

100-
################################################################################
101-
# Definitions
102-
################################################################################
103-
104-
if(TIGHT_INCLUSION_WITH_TIMER)
105-
target_compile_definitions(tight_inclusion PRIVATE TIGHT_INCLUSION_USE_TIMER)
106-
endif()
107-
108-
if (TIGHT_INCLUSION_WITH_DOUBLE_PRECISION)
109-
message(STATUS "Tight Inclusion: Using Double Precision Floating Points")
110-
target_compile_definitions(tight_inclusion PUBLIC TIGHT_INCLUSION_DOUBLE)
111-
else()
112-
message(STATUS "Tight Inclusion: Using Single Precision Floating Points")
113-
endif()
114-
115-
if(TIGHT_INCLUSION_LIMIT_QUEUE_SIZE)
116-
message(STATUS "Tight Inclusion: Limiting maximal queue size")
117-
target_compile_definitions(tight_inclusion PUBLIC TIGHT_INCLUSION_LIMIT_QUEUE_SIZE)
118-
endif()
119-
120-
if(TIGHT_INCLUSION_FLOAT_WITH_DOUBLE_INPUT)
121-
message(STATUS "Tight Inclusion: Converting double inputs to float for tests")
122-
target_compile_definitions(tight_inclusion PUBLIC TIGHT_INCLUSION_FWDI)
123-
endif()
138+
# Extra warnings (link last for highest priority)
139+
include(tight_inclusion_warnings)
140+
target_link_libraries(tight_inclusion PRIVATE tight_inclusion::warnings)
124141

125142
################################################################################
126143
# Compiler options
@@ -140,20 +157,5 @@ target_compile_features(tight_inclusion PUBLIC cxx_std_17)
140157
################################################################################
141158

142159
if(TIGHT_INCLUSION_TOPLEVEL_PROJECT)
143-
add_executable(Tight_Inclusion_bin "app/main.cpp")
144-
target_link_libraries(Tight_Inclusion_bin PUBLIC tight_inclusion)
145-
146-
set(TIGHT_INCLUSION_SAMPLE_QUERIES_DIR "${PROJECT_SOURCE_DIR}/sample-queries")
147-
include(sample_queries)
148-
149-
if(TIGHT_INCLUSION_SUPPRESS_PROGRESS_OUTPUT)
150-
target_compile_definitions(Tight_Inclusion_bin PUBLIC TIGHT_INCLUSION_SUPPRESS_PROGRESS_OUTPUT)
151-
endif()
152-
153-
if (TIGHT_INCLUSION_WITH_TESTS)
154-
target_sources(Tight_Inclusion_bin PUBLIC "app/read_rational_csv.cpp")
155-
target_compile_definitions(Tight_Inclusion_bin PUBLIC TIGHT_INCLUSION_RUN_EXAMPLES)
156-
target_compile_definitions(Tight_Inclusion_bin PUBLIC
157-
TIGHT_INCLUSION_SAMPLE_QUERIES_DIR="${TIGHT_INCLUSION_SAMPLE_QUERIES_DIR}/")
158-
endif()
160+
add_subdirectory(app)
159161
endif()

0 commit comments

Comments
 (0)