我有以下使用clang的扫描构建工具进行静态分析构建的脚本:
#!/usr/bin/env bash
export CC=clang
export CXX=clang++
export CCC_CC=$CC
export CCC_CXX=$CXX
mkdir -p static-analysis/build
cd static-analysis/build
cmake -DCMAKE_C_COMPILER=ccc-analyzer -DCMAKE_CXX_COMPILER=c++-analyzer ../..
scan-build -o .. --use-analyzer /usr/local/bin/clang --html-title="craft static analysis" make -j`getconf _NPROCESSORS_ONLN`该脚本在第一次执行时工作正常,但以下执行会导致无限循环:
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_CXX_COMPILER= c++-analyzer
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_CXX_COMPILER= c++-analyzer
.
.
.我没有做任何更改,只是删除了整个build目录,以便cmake调用再次工作。而且,只调用scan-build而不调用cmake也没有问题。
编辑
通过查看cmake生成的文件,我发现它引用的是-DCMAKE_CXX_COMPILER设置的完整路径,我只传递了c++-analyzer,因为它在我的路径上。我怀疑在c++analyzer和它的完整路径之间有一些失败的比较。解决方法是在调用cmake时使用绝对路径传递-DCMAKE_CXX_COMPILER,这样比较就会成功。这看起来像是个bug。
发布于 2013-06-28 10:25:07
如问题编辑中所述,解决此问题的方法是使用:
cmake -DCMAKE_C_COMPILER=`which ccc-analyzer` \
-DCMAKE_CXX_COMPILER=`which c++-analyzer` ../..https://stackoverflow.com/questions/17355798
复制相似问题