From fabfed6f22811084b041bbf06dc1428655c4f7f9 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 10 Sep 2017 09:51:27 +0300 Subject: [PATCH] Added support for "include-what-you-use" tool [#CLICKHOUSE-2]. --- CMakeLists.txt | 12 ++++++++++++ dbms/CMakeLists.txt | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87c4ef63e65..69b20377459 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,6 +156,18 @@ set (CMAKE_C_FLAGS_MSAN "${CMAKE_C_FLAGS_MSAN} ${SAN_FLAGS} set (CMAKE_CXX_FLAGS_TSAN "${CMAKE_CXX_FLAGS_TSAN} ${SAN_FLAGS} -fsanitize=thread") set (CMAKE_C_FLAGS_TSAN "${CMAKE_C_FLAGS_TSAN} ${SAN_FLAGS} -fsanitize=thread") +# Using "include-what-you-use" tool. +option (USE_INCLUDE_WHAT_YOU_USE "Use 'include-what-you-use' tool" OFF) +if (USE_INCLUDE_WHAT_YOU_USE) + find_program(IWYU_PATH NAMES include-what-you-use iwyu) + if (NOT IWYU_PATH) + message(FATAL_ERROR "Could not find the program include-what-you-use") + endif() + if (${CMAKE_VERSION} VERSION_LESS "3.3.0") + message(FATAL_ERROR "include-what-you-use requires CMake version at least 3.3.") + endif() +endif () + # Flags for test coverage if (TEST_COVERAGE) set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -DIS_DEBUG") diff --git a/dbms/CMakeLists.txt b/dbms/CMakeLists.txt index dbf23edc479..6ae88e0df3e 100644 --- a/dbms/CMakeLists.txt +++ b/dbms/CMakeLists.txt @@ -1,3 +1,7 @@ +if (USE_INCLUDE_WHAT_YOU_USE) + set (CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH}) +endif () + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/find_vectorclass.cmake) set (CONFIG_VERSION ${CMAKE_CURRENT_BINARY_DIR}/src/Common/config_version.h)