From aa021169950a741d1449ee2d71ee7665e12d72e2 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 30 Mar 2022 06:32:14 +0200 Subject: [PATCH] add cmake tools option to easy dynamic setup --- cmake/tools.cmake | 9 +++++++++ standalone/CMakeLists.txt | 5 ++++- test/CMakeLists.txt | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmake/tools.cmake b/cmake/tools.cmake index 2364da9..9ef0bb8 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -10,6 +10,10 @@ 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' +set(USE_SANITIZER + "Address;Undefined" + CACHE STRING "one or more of: Address, Memory, MemoryWithOrigins, Undefined, Thread, Leak" +) if(USE_SANITIZER OR USE_STATIC_ANALYZER) CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354") @@ -17,6 +21,10 @@ if(USE_SANITIZER OR USE_STATIC_ANALYZER) include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake) endif() + set(USE_STATIC_ANALYZER + "" + CACHE STRING "one or more of: clang-tidy, iwyu, cppcheck" + ) if(USE_STATIC_ANALYZER) if("clang-tidy" IN_LIST USE_STATIC_ANALYZER) set(CLANG_TIDY @@ -61,6 +69,7 @@ if(USE_SANITIZER OR USE_STATIC_ANALYZER) endif() # enables CCACHE support through the USE_CCACHE flag possible values are: YES, NO or equivalent +option(USE_CCACHE "enables ccache support" YES) if(USE_CCACHE) CPMAddPackage("gh:TheLartians/Ccache.cmake@1.2.3") endif() diff --git a/standalone/CMakeLists.txt b/standalone/CMakeLists.txt index 36b15db..1339192 100644 --- a/standalone/CMakeLists.txt +++ b/standalone/CMakeLists.txt @@ -24,7 +24,10 @@ file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp) add_executable(${PROJECT_NAME} ${sources}) -# TODO(CK): why is this needed? +# enable pedantic compiler warnings +include(../cmake/WarningsAsErrors.cmake) + +# TODO(CK): why is this needed on CI? set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME Greeter) target_link_libraries(${PROJECT_NAME} Greeter::Greeter cxxopts) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f9d009c..ffae656 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -31,7 +31,7 @@ add_executable(${PROJECT_NAME} ${sources}) target_link_libraries(${PROJECT_NAME} doctest::doctest Greeter::Greeter) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) -# enable compiler warnings +# enable pedantic compiler warnings include(../cmake/WarningsAsErrors.cmake) # ---- Add GreeterTests ----