77endif ()
88
99# Check required CMake version
10- set (REQUIRED_CMAKE_VERSION "3.14 .0" )
10+ set (REQUIRED_CMAKE_VERSION "3.18 .0" )
1111if (SIMPLE_BVH_TOPLEVEL_PROJECT)
1212 cmake_minimum_required (VERSION ${REQUIRED_CMAKE_VERSION} )
1313else ()
@@ -24,13 +24,33 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SimpleBVHOptions.cmake)
2424 include (${CMAKE_CURRENT_SOURCE_DIR} /SimpleBVHOptions.cmake)
2525endif ()
2626
27+ # Enable ccache if available
28+ find_program (CCACHE_PROGRAM ccache)
29+ if (CCACHE_PROGRAM)
30+ option (SIMPLE_BVH_WITH_CCACHE "Enable ccache when building IPC Toolkit" ${SIMPLE_BVH_TOPLEVEL_PROJECT} )
31+ else ()
32+ option (SIMPLE_BVH_WITH_CCACHE "Enable ccache when building IPC Toolkit" OFF )
33+ endif ()
34+ if (SIMPLE_BVH_WITH_CCACHE AND CCACHE_PROGRAM)
35+ message (STATUS "Enabling Ccache support (${CCACHE_PROGRAM} )" )
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+
2747################################################################################
2848
2949project (SimpleBVH
3050 DESCRIPTION "A simple BVH data structure."
3151 LANGUAGES CXX)
3252
33- option (SIMPLE_BVH_WITH_UNIT_TESTS "Build unit-tests" ${SIMPLE_BVH_TOPLEVEL_PROJECT} )
53+ option (SIMPLE_BVH_BUILD_TESTS "Build unit-tests" ${SIMPLE_BVH_TOPLEVEL_PROJECT} )
3454
3555# Set default minimum C++ standard
3656if (SIMPLE_BVH_TOPLEVEL_PROJECT)
@@ -42,13 +62,16 @@ endif()
4262list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake/simple_bvh/" )
4363list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake/recipes/" )
4464
65+ # General CMake utils
66+ include (simple_bvh_cpm_cache)
67+
4568################################################################################
4669# Main library
4770################################################################################
4871
4972add_library (simple_bvh
50- src/BVH.cpp
51- src/Morton.cpp
73+ src/SimpleBVH/ BVH.cpp
74+ src/SimpleBVH/ Morton.cpp
5275)
5376target_include_directories (simple_bvh PUBLIC src)
5477add_library (simple_bvh::simple_bvh ALIAS simple_bvh)
@@ -61,13 +84,13 @@ add_library(simple_bvh::simple_bvh ALIAS simple_bvh)
6184# Required Libraries
6285################################################################################
6386
64- # Extra warnings
65- include (simple_bvh_warnings)
66- target_link_libraries (simple_bvh PRIVATE simple_bvh::warnings)
67-
6887include (eigen)
6988target_link_libraries (simple_bvh PUBLIC Eigen3::Eigen)
7089
90+ # Extra warnings (link last for highest priority)
91+ include (simple_bvh_warnings)
92+ target_link_libraries (simple_bvh PRIVATE simple_bvh::warnings)
93+
7194################################################################################
7295# Compiler options
7396################################################################################
@@ -80,14 +103,8 @@ target_compile_features(simple_bvh PUBLIC cxx_std_14)
80103################################################################################
81104
82105# Enable unit testing at the root level
83- if (SIMPLE_BVH_WITH_UNIT_TESTS)
84- include (CTest)
85- enable_testing ()
86-
87- # Include Catch2 and provide function `catch_discover_tests` to register tests.
88- include (catch2)
89- FetchContent_GetProperties(catch2)
90- include ("${catch2_SOURCE_DIR} /contrib/Catch.cmake" )
91-
92- add_subdirectory (tests)
93- endif ()
106+ if (SIMPLE_BVH_TOPLEVEL_PROJECT AND SIMPLE_BVH_BUILD_TESTS)
107+ include (CTest)
108+ enable_testing ()
109+ add_subdirectory (tests)
110+ endif ()
0 commit comments