diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-11-15 10:55:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-15 10:55:07 +0100 |
commit | 4b02291f81b76eda029d4eae1c1d59c1a946a032 (patch) | |
tree | 1c80f329c147d3a1caa254a12ea2f3e613018358 /CMakeLists.txt | |
parent | c6c265a86ce86e99fdb6d4375219b56dc293c832 (diff) | |
parent | 66360675cf4d091b7460e4a8e1435c13216c1929 (diff) | |
download | rneovim-4b02291f81b76eda029d4eae1c1d59c1a946a032.tar.gz rneovim-4b02291f81b76eda029d4eae1c1d59c1a946a032.tar.bz2 rneovim-4b02291f81b76eda029d4eae1c1d59c1a946a032.zip |
Merge pull request #20157 from dundargoc/build/iwyu
build: allow IWYU to fix includes for all .c files
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a6e0ee017a..10106f9499 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,6 +192,20 @@ if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG) string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") endif() +option(ENABLE_IWYU "Run include-what-you-use with the compiler." OFF) +if(ENABLE_IWYU) + find_program(IWYU_PRG NAMES include-what-you-use iwyu) + if(NOT IWYU_PRG) + message(FATAL_ERROR "ENABLE_IWYU is ON but include-what-you-use is not found!") + endif() + set(CMAKE_C_INCLUDE_WHAT_YOU_USE ${IWYU_PRG} + -Xiwyu --mapping_file=${PROJECT_SOURCE_DIR}/cmake.config/iwyu/mapping.imp + -Xiwyu --mapping_file=${PROJECT_SOURCE_DIR}/cmake.config/iwyu/gcc.libc.imp + -Xiwyu --mapping_file=${PROJECT_SOURCE_DIR}/cmake.config/iwyu/gcc.symbols.imp + -Xiwyu --no_default_mappings) + add_definitions(-DEXITFREE) +endif() + # gcc 4.0+ sets _FORTIFY_SOURCE=2 automatically. This currently # does not work with Neovim due to some uses of dynamically-sized structures. # https://github.com/neovim/neovim/issues/223 |