clang-tidy cannot locate headers?

已回答

Hello, 

I'm having a hard time troubleshooting a non-issue I'm having within CMake integration in CLion.

The project I'm working on is configured to run clang-tidy per file, and sometimes yield an "error" on file inclusions (but builds regardless):  
`error: 'SomeHeader.hpp' file not found [clang-diagnostic-error]`

I've added to my main CMakeLists.txt :

set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-p=${CMAKE_BINARY_DIR},-config=")

Error occurs under MSVC and GNU compilers in CLion but not with CLI. What am I missing? 

Regards,
Rémy

0

Hello!

Just in case, starting from CLion 2017.2 we have a build-in Clang-Tidy support which doesn't need any changes in CMakeLists.txt. More information in the web-help: https://www.jetbrains.com/help/clion/clang-tidy-integration.html.

If for some reason you need to enable Clang-Tidy in the way you do it currently, probably the error "error: 'SomeHeader.hpp' file not found [clang-diagnostic-error]" appears due to the fact that this file cannot be found during the analysis process, as it most likely is located in a different directory. You might want to specify the path to this file with the `-I` option explicitly.

0

请先登录再写评论。