From 90327eb02902a6858afca19cb8095c12d261db8d Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 16 Feb 2020 09:46:55 +0100 Subject: [PATCH] Recomment out-of-source build Prevent to overwrite the project config file .clang-tidy --- cmake/clang-tidy.cmake | 15 ++++++++++----- cmake/ide.cmake | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake index dad7ba20..ead9cd68 100644 --- a/cmake/clang-tidy.cmake +++ b/cmake/clang-tidy.cmake @@ -11,12 +11,17 @@ if(CLANG_TIDY_EXE) set(DCMAKE_EXPORT_COMPILE_COMMANDS ON) set(CLANG_TIDY_CMD ${CLANG_TIDY_EXE}) message(STATUS "cmake source dir: ${CMAKE_CURRENT_SOURCE_DIR}") - # NOTE: copy default checks config file .clang-tidy for later use - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy ${CMAKE_CURRENT_BINARY_DIR} @ONLY) + # recomment out-of-source build + if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(AUTHOR_WARNING "In-source build is not recommented!") + else() + # NOTE: copy project config file .clang-tidy for later use + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy ${CMAKE_CURRENT_BINARY_DIR} @ONLY) + endif() if(SPDLOG_ENABLE_TIDY) # NOTE: the project config file .clang-tidy is not found if the - # binary tree is not part of the source tree! CK + # binary tree is not part of the source tree! set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_CMD} CACHE STRING "" FORCE) else() set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it @@ -31,8 +36,8 @@ if(CLANG_TIDY_EXE) add_custom_command(TARGET check PRE_BUILD # -p BUILD_PATH Path used to read a compile command database (compile_commands.json). - # NOTE: we use default checks from .clang-tidy - COMMAND ${CLANG_TIDY_RUNNER} -p ${CMAKE_CURRENT_BINARY_DIR} + # NOTE: we use default checks from .clang-tidy and we check example tree only yet + COMMAND ${CLANG_TIDY_RUNNER} -p ${CMAKE_CURRENT_BINARY_DIR} example WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # location of compile_commands.json COMMENT "Running check on targets at ${CMAKE_CURRENT_SOURCE_DIR} ..." VERBATIM diff --git a/cmake/ide.cmake b/cmake/ide.cmake index 27472c38..b2080cd6 100644 --- a/cmake/ide.cmake +++ b/cmake/ide.cmake @@ -14,5 +14,5 @@ source_group("Header Files\\spdlog" FILES ${SPDLOG_TOP_HEADERS}) source_group("Header Files\\spdlog\\details" FILES ${SPDLOG_DETAILS_HEADERS}) source_group("Header Files\\spdlog\\sinks" FILES ${SPDLOG_SINKS_HEADERS}) source_group("Header Files\\spdlog\\fmt" FILES ${SPDLOG_FMT_HEADERS}) -source_group("Header Files\\spdlog\\fmt\\bundled\\" FILES ${SPDLOG_FMT_BUNDELED_HEADERS}) +source_group("Header Files\\spdlog\\fmt\\bundled" FILES ${SPDLOG_FMT_BUNDELED_HEADERS})