diff --git a/CMakeLists.txt b/CMakeLists.txt index 2913c6b..4750542 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,12 +14,9 @@ if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.") endif() -# ---- Add source files ---- +# --- Import tools ---- -# Note: globbing sources is considered bad practice as CMake's generators may not detect new files automatically. -# Keep that in mind when changing files, or explicitly mention them here. -FILE(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h") -FILE(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") +include(cmake/tools.cmake) # ---- Add dependencies via CPM ---- # see https://github.com/TheLartians/CPM.cmake for more info @@ -33,6 +30,13 @@ CPMAddPackage( VERSION 1.0 ) +# ---- Add source files ---- + +# Note: globbing sources is considered bad practice as CMake's generators may not detect new files automatically. +# Keep that in mind when changing files, or explicitly mention them here. +FILE(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h") +FILE(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") + # ---- Create library ---- # Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface target: diff --git a/README.md b/README.md index 5b7f137..fa73dd3 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ This template is the result of learnings from many previous projects and should - Code formatting enforced by [clang-format](https://clang.llvm.org/docs/ClangFormat.html) via [Format.cmake](https://github.com/TheLartians/Format.cmake) - Reproducible dependency management via [CPM.cmake](https://github.com/TheLartians/CPM.cmake) - Installable target with versioning information via [PackageProject.cmake](https://github.com/TheLartians/PackageProject.cmake) +- Support for [sanitizer tools and more](#additional-tools) ## Usage @@ -76,6 +77,14 @@ cmake --build build/test --target fix-format See [Format.cmake](https://github.com/TheLartians/Format.cmake) for more options. +### Additional tools + +The project includes an [tools.cmake](cmake/tools.cmake) file that can be used to import additional tools on-demand through CMake configuration arguments. +The following are currently supported. + +- `-DUSE_SANITIZER=
` +- `-DUSE_CCACHE=