1
0
Fork 0
mirror of https://github.com/TheLartians/ModernCppStarter.git synced 2025-08-30 21:51:12 +02:00

only apply tools for top-level directory

This commit is contained in:
Lars Melchior 2020-04-29 10:12:57 +02:00
parent 373d3c1651
commit c74c3a13b1
4 changed files with 16 additions and 14 deletions

View file

@ -14,10 +14,6 @@ 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()
# --- Import tools ----
include(cmake/tools.cmake)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info

View file

@ -1,16 +1,16 @@
# this file contains a list of tools that can be activated and downloaded on-demand
# each tool is enabled during configuration by passing an additional `-DUSE_<TOOL>=<VALUE>` argument to CMake
# determine if a tool has already been enabled
foreach(TOOL USE_SANITIZER;USE_CCACHE)
get_property(${TOOL}_ENABLED GLOBAL "" PROPERTY ${TOOL}_ENABLED SET)
endforeach()
# only activate tools for top level project
if (NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
return()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
# enables sanitizers support using the the `USE_SANITIZER` flag
# available values are: Address, Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined'
if (USE_SANITIZER AND NOT USE_SANITIZER_ENABLED)
set_property(GLOBAL PROPERTY USE_SANITIZER_ENABLED true)
if (USE_SANITIZER)
CPMAddPackage(
NAME StableCoder-cmake-scripts
GITHUB_REPOSITORY StableCoder/cmake-scripts
@ -22,9 +22,7 @@ endif()
# enables CCACHE support through the USE_CCACHE flag
# possible values are: YES, NO or equivalent
if (USE_CCACHE AND NOT USE_CCACHE_ENABLED)
set_property(GLOBAL PROPERTY USE_CCACHE_ENABLED true)
if (USE_CCACHE)
CPMAddPackage(
NAME Ccache.cmake
GITHUB_REPOSITORY TheLartians/Ccache.cmake

View file

@ -4,6 +4,10 @@ project(GreeterStandalone
LANGUAGES CXX
)
# --- Import tools ----
include(../cmake/tools.cmake)
# ---- Dependencies ----
include(../cmake/CPM.cmake)

View file

@ -9,6 +9,10 @@ project(GreeterTests
option(ENABLE_TEST_COVERAGE "Enable test coverage" OFF)
option(TEST_INSTALLED_VERSION "Test the version found by find_package" OFF)
# --- Import tools ----
include(../cmake/tools.cmake)
# ---- Dependencies ----
include(../cmake/CPM.cmake)