Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: unable to handle compilation, expected exactly one compiler job in '' [clang-diagnostic-error]

Build fails without much helpful information after I've added this into my CmakeLists.txt to enable clang-tidy checks:

if(ENABLE_CLANG_TIDY)
  find_program(CLANGTIDY clang-tidy)
  if(CLANGTIDY)
    set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
    set(CMAKE_CXX_CLANG_TIDY "${CLANGTIDY};-extra-arg=-Wno-unknown-warning-option;-header-filter=${CMAKE_SOURCE_DIR}/src/*;")
  else()
    message(SEND_ERROR "clang-tidy requested but executable not found")
  endif()
endif()

but then, when I call cmake -DENABLE_CLANG_TIDY=ON .. && make the build process stops on 2% with minimum explanations of what is wrong. Here is the most meaningful parts of it:

make[2]: Leaving directory '/path/to/module/build'
make  -f src/CMakeFiles/module.dir/build.make src/CMakeFiles/module.dir/build
make[2]: Entering directory '/path/to/module/build'
[  2%] Building CXX object src/CMakeFiles/module.dir/api/base_controller.cpp.o
cd /path/to/module/build/src && ccache /usr/local/bin/cmake -E __run_co_compile --tidy="/usr/bin/clang-tidy;-extra-arg=-Wno-unknown-warning-option;-header-filter=/path/to/module/src/*;-p=/path/to/module/src;;--extra-arg-before=--driver-mode=g++" --source=/path/to/module/src/api/base_controller.cpp -- /usr/lib64/ccache/c++  -I/path/to/module/src -I/home/vagrant/.conan/data/catch2/2.11.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -DFAST_LOCK -D__CPU_x86_64 -DPKG_MALLOC -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN -DUSE_RAW_SOCKS -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND -DUSE_FUTEX -DHAVE_SELECT  -D_GNU_SOURCE -DCUSTOM_LOG_FMT -fPIC -Wall -Werror -Wextra -Wno-write-strings -Wno-format -g -Wextra -Wno-error=class-memaccess -Wno-error=implicit-fallthrough -O3 -DNDEBUG  -D_GLIBCXX_USE_CXX11_ABI=1 -o CMakeFiles/module.dir/api/base_controller.cpp.o -c /path/to/module/src/api/base_controller.cpp
error: unable to handle compilation, expected exactly one compiler job in '' [clang-diagnostic-error]
Error while processing some/path/src/.
5481 warnings and 1 error generated.
Error while processing some/path/src/api/file.cpp.
Suppressed 5481 warnings (5403 in non-user code, 78 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).

Some notes:

  1. Without ENABLE_CLANG_TIDY flag, the project compiles just fine
  2. I've fixed errors that clang-tidy was reporting
like image 617
Maksym Rudenko Avatar asked Aug 28 '20 10:08

Maksym Rudenko


1 Answers

I got the same problem and solution is simple - remove the last semicolon in your CMAKE_CXX_CLANG_TIDY string:

Your line:

set(CMAKE_CXX_CLANG_TIDY "${CLANGTIDY};-extra-arg=-Wno-unknown-warning-option;-header-filter=${CMAKE_SOURCE_DIR}/src/*;")

To be replaced with:

set(CMAKE_CXX_CLANG_TIDY "${CLANGTIDY};-extra-arg=-Wno-unknown-warning-option;-header-filter=${CMAKE_SOURCE_DIR}/src/*")
like image 107
iburyl Avatar answered Oct 06 '22 23:10

iburyl