77endif ()
88
99# Check required CMake version
10- set (REQUIRED_CMAKE_VERSION "3.14 .0" )
10+ set (REQUIRED_CMAKE_VERSION "3.18 .0" )
1111if (TIGHT_INCLUSION_TOPLEVEL_PROJECT)
1212 cmake_minimum_required (VERSION ${REQUIRED_CMAKE_VERSION} )
1313else ()
@@ -24,24 +24,50 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/TightInclusionOptions.cmake)
2424 include (${CMAKE_CURRENT_SOURCE_DIR} /TightInclusionOptions.cmake)
2525endif ()
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
2959project (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
4369include (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
4773if (TIGHT_INCLUSION_TOPLEVEL_PROJECT)
@@ -51,12 +77,19 @@ if(TIGHT_INCLUSION_TOPLEVEL_PROJECT)
5177endif ()
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+
5483list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake/tight_inclusion/" )
5584list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake/recipes/" )
5685list (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)
6699add_library (tight_inclusion)
67100add_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
90125include (eigen)
91126target_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)
98136endif ()
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
142159if (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)
159161endif ()
0 commit comments