@@ -15,16 +15,32 @@ include("cmake/compat_find.cmake")
1515find_package (CapnProto REQUIRED )
1616find_package (Threads REQUIRED )
1717
18- option (Libmultiprocess_ENABLE_CLANG_TIDY "Run clang-tidy with the compiler." OFF )
19- if (Libmultiprocess_ENABLE_CLANG_TIDY)
18+ set (MPGEN_EXECUTABLE "" CACHE FILEPATH "If specified, should be full path to an external mpgen binary to use rather than the one built internally." )
19+
20+ option (MP_ENABLE_CLANG_TIDY "Run clang-tidy with the compiler." OFF )
21+ if (MP_ENABLE_CLANG_TIDY)
2022 find_program (CLANG_TIDY_EXECUTABLE NAMES clang-tidy )
2123 if (NOT CLANG_TIDY_EXECUTABLE)
22- message (FATAL_ERROR "Libmultiprocess_ENABLE_CLANG_TIDY is ON but clang-tidy is not found." )
24+ message (FATAL_ERROR "MP_ENABLE_CLANG_TIDY is ON but clang-tidy is not found." )
2325 endif ()
2426 set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE} " )
27+
28+ # Workaround for nix from https://gitlab.kitware.com/cmake/cmake/-/issues/20912#note_793338
29+ # Nix injects header paths via $NIX_CFLAGS_COMPILE; CMake tags these as
30+ # CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES and omits them from the compile
31+ # database, so clang-tidy, which ignores $NIX_CFLAGS_COMPILE, can't find capnp
32+ # headers. Setting them as standard passes them to clang-tidy.
33+ set (CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} )
2534endif ()
2635
27- set (MPGEN_EXECUTABLE "" CACHE FILEPATH "If specified, should be full path to an external mpgen binary to use rather than the one built internally." )
36+ option (MP_ENABLE_IWYU "Run include-what-you-use with the compiler." OFF )
37+ if (MP_ENABLE_IWYU)
38+ find_program (IWYU_EXECUTABLE NAMES include -what-you-use iwyu )
39+ if (NOT IWYU_EXECUTABLE)
40+ message (FATAL_ERROR "MP_ENABLE_IWYU is ON but include-what-you-use was not found." )
41+ endif ()
42+ set (CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${IWYU_EXECUTABLE} ;-Xiwyu;--error" )
43+ endif ()
2844
2945include ("cmake/compat_config.cmake" )
3046include ("cmake/pthread_checks.cmake" )
@@ -51,6 +67,7 @@ configure_file(include/mp/config.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/mp/co
5167
5268# Generated C++ Capn'Proto schema files
5369capnp_generate_cpp (MP_PROXY_SRCS MP_PROXY_HDRS include /mp/proxy.capnp )
70+ set_source_files_properties ("${MP_PROXY_SRCS} " PROPERTIES SKIP_LINTING TRUE )
5471
5572# util library
5673add_library (mputil OBJECT src/mp/util.cpp )
0 commit comments