Skip to content

How can I run clang scan-build on this Cmake project? #6

@smcameron

Description

@smcameron

The internet seems to claim that I can do the following:

$ export CC=/usr/bin/clang
$ export CXX=/usr/bin/clang++
$ scan-build cmake ...
$ cd build_sdl_sim
$ scan-build make

However, this doesn't work in two different ways.

First, cmake (or perhaps our usage of cmake) does not seem to honor CC and CXX. Instead, it invariable uses /usr/bin/cc

On my system, /usr/bin/cc is a symlink to /etc/alternatives/cc, which is a symlink to /usr/bin/gcc

I tried changing this to link to /usr/bin/clang (a bit ham-fisted, but that seemed to work, and made Cmake compile with clang, though I did have to run cmake again, and it detected that it was using clang.)

However, when I ran

$ scan-build cmake ...
$ scan-build make ...

It didn't do the scan, instead it just compiled as usual. I suspect whatever cmake is doing is thwarting whatever interposing mechanism scan-build uses to make the build scan rather than compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions