Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

C/C++test + CMake -> bdf file generation issue

sanko
sanko Posts: 2
edited July 2021 in C/C++test

Hello,

I am using the CMake extension for creating C/C++ Test projects and what I noticed is, that the extension is also capturing commands which compile/link temporary files during a CMake build. This is especially, or maybe only, the case when the build has dependencies on other static libraries.

These commands will also make it into the bdf file, which in the end cause linking issues during test generation.

If I remove following entries from the bdf file, everything works as expected:

arg=--whole-archive
arg=CMakeFiles\MYAPPNAME.dir/objects.a

arg=--out-implib
arg=libMYAPPNAME.dll.a

Kind Regards
Konstantin

Tagged:

Comments

  • Andrey Madan
    Andrey Madan Posts: 388 ✭✭✭

    @sanko - are you running Unit Testing , Application level coverage or simply Static Analysis? If Static only - then there is an much easier way to get the .json file from CMake. Which tool distro are you using: Standard or Professional?

  • sanko
    sanko Posts: 2

    @Andrey Madan
    We are currently using only unit testing.
    Its actually not about a .json file, its about creating C/C++test projects during a cmake build. Of course I can generate a compile_commands.json file and use this inside a C/C++test project.
    I prefer to use "cpptest_add_executable" directly inside the CMakeLists.txt.

  • Mirek
    Mirek Posts: 141 admin

    Hello @sanko,

    If I'm correct, this is related to CMake's behavior on windows, where all the objects are first archived and then used for linking the final binary.

    C/C++test, when linking the test binary, assumes that objects.a is one of the user's third-party libraries and leaves it on the command line, generating linking errors.

    Please try to modify your test configuration using the following setting:
    TestConfiguration >Execution tab>Symbols tab>Ignore object/library files: [*/objects.a]

    Where "*/objects.a" is a value of the setting.

  • duclair3006
    duclair3006 Posts: 1

    hello I'm new in parasoft actually I want to generate the BDF file using Gitlab . on my current directory I have a cmakelist file . please help

Tagged