添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I could not get CMake to build with Coverity. I am new to CMake and not sure how to fix this problem. I am able to build sample program with this command:

cov-build --dir . gcc sample.cc -o sample.o

However, when I tried to build with CMake

cov-build --dir . cmake ../

I am getting the no emit error:

Coverity Build Capture (64-bit) version 2017.07 on Linux 3.10.0-693.21.1.el7.x86_64 x86_64
Internal version numbers: 7a4de27b47 p-milo-push-30112.654
-- Using Build Type provided on command line
-- Library config4cpp Found
-- CONFIG4CPP_INCLUDE_DIRS=/opt/config4cpp/include
-- CONFIG4CPP_LIBRARIES=/opt/config4cpp/lib/libconfig4cpp.a
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hitp6130/pulsar
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
 For more details, please look at:
    /home/hitp6130/pulsar/build/build-log.txt
                cmake doesn't build the project - it just configures it. For build configured project you need to run make from the build directory.
– Tsyvarev
                Jul 18, 2018 at 7:33
                alright, thanks for the answer.  I tried the following and still got the "No files were emitted" warning: cmake . then cov-build --dir . make
– long
                Jul 18, 2018 at 18:19
                Probably, you CMake project actually don't compile any file. Without viewing that project (in form of minimal reproducible example) we can only guess.
– Tsyvarev
                Jul 18, 2018 at 22:07
                my project can build fine using cmake then make-j;  the executable was created using these 2 commands.  I just need to incoorporate coverity to do thread analysis
– long
                Jul 18, 2018 at 22:11
                <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE coverity SYSTEM "coverity_config.dtd"> <coverity> <!-- Version 2017.07 -->     <cit_version>1</cit_version>     <config>       <include>$CONFIGDIR$/template-gcc-config-0/coverity_config.xml</include>       <include>$CONFIGDIR$/template-g++-config-0/coverity_config.xml</include>       <include>$CONFIGDIR$/template-gcc-config-1/coverity_config.xml</include>       <include>$CONFIGDIR$/template-gcc-config-2/coverity_config.xml</include>       <include>$CONFIGDIR$/template-g++-config-
– long
                Jul 19, 2018 at 21:30
                <include>$CONFIGDIR$/template-ld-config-0/coverity_config.xml</include>     </config> </coverity>
– long
                Jul 19, 2018 at 21:31

Arcoding to the coverity guidline, I think cmake is not the simple case, and you need the full version of the command as bellow:

cov-configure  --template --compiler <compiler-binary-name> --comptype <compiler-type>

Example:

cov-configure --config cc-config.xml --template --comptype gcc --compiler cc
cmake ..
cov-build --dir <build-dir> --config cc-config.xml make
  • cc-config.xml is the configuration file which coverity generate. You can use different name as you need.
  • Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.