2016-09-12 2 views
1

clang 및 clang-tidy에 대한 새로운 기능이 여기에 있습니다.Clang-Tidy는 내 머리글 파일을 찾을 수 없습니다

나는 구조 이러한 유형의 프로젝트를 가지고 : project/ - build/ - cmake/ - component1/ - src/ - someFile.cpp - someFile2.cpp - someFile.hpp - someFile2.hpp - component2/ - etc... -

나는 그 소리-정돈이 명령 project/component1/에있는 모든 파일을 통해 갈 사용 clang-tidy project/component1/src/* -checks=-*,clang-analyzer-*,-clang-analyzer-alpha*

그것은 오류 등이 던지는 끝 이 : $HOME/project/component1/src/someFile.cpp:18:10: error: 'project/component1/someFile.hpp' file not found [clang-diagnostic-error] \#include "component1/someFile.hpp"

+0

동일한 레벨에 있지 않을 수 있습니까 ('someFile.hpp'는/src에 없습니다)? – Griffin

+0

@ Grif-fin 그 생각은했지만, 파일 구조를 망쳐 놓을 수는 없습니다. * .hpp 파일의 위치를 ​​알려주도록 설정할 수있는 명령 옵션이 있습니까? 각 옵션에 대한 설명이 항상 상황을 파악하기에 충분할만큼 높은 것은 아닙니다. * : -/ –

+0

'project/component1 /'디렉토리에서 clang-tidy 명령을 실행 해 보았습니다 만,'src /'아래에서 같은 오류가 발생합니다. –

답변

0

이 답변은 CMake를 사용하여 프로젝트를 관리하는 경우에만 도움이 될 것입니다.

CMake에는 명령 줄 옵션으로 모든 컴파일러 호출을 포함하는 .json 파일을 만드는 옵션이 있습니다. 이 파일은 그 소리-정돈을하는 옵션을 제공 할 수 있습니다

-p <build-path> is used to read a compile command database. 

    For example, it can be a CMake build directory in which a file named 
    compile_commands.json exists (use -DCMAKE_EXPORT_COMPILE_COMMANDS=ON 
    CMake option to get this output). When no build path is specified, 
    a search for compile_commands.json will be attempted through all 
    parent paths of the first input file . See: 
    http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an 
    example of setting up Clang Tooling on a source tree. 

으로 문서 상태, 당신은 CMake와 .json 파일을 생성 CMAKE_EXPORT_COMPILE_COMMANDS 변수를 설정 한 다음 clang-하기 위해 CMake 출력 디렉토리를 통과해야 잡동사니 그릇. Clang-tidy는 .json 파일의 명령에서 포함 된 pathes를 가져옵니다.

관련 문제