Combining callcatcher and cmake

104 Views Asked by At

My aim is to find procedures in our large and old codebase that are never called. Our code, called neci, is mostly Fortran and some C/C++ code. From the top answer to this question I stumbled over the wonderful tool callcatcher but I have difficulties in combining it with cmake.

When I use callcatcher by compiling manually a bunch of Fortran files, everything works correctly and finds unused procedures.

Now I wanted to embed this tool into our cmake compilation process and used.

cmake \
    -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_Fortran_COMPILER=mpifort -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx \
    -DCMAKE_Fortran_COMPILER_LAUNCHER=callcatcher -DCMAKE_C_COMPILER_LAUNCHER=callcatcher -DCMAKE_CXX_COMPILER_LAUNCHER=callcatcher \
    -DCMAKE_Fortran_LINKER_LAUNCHER=callcatcher -DCMAKE_C_LINKER_LAUNCHER=callcatcher -DCMAKE_CXX_LINKER_LAUNCHER=callcatcher \
     ~/code/neci

The computer then warns about:

CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_Fortran_LINKER_LAUNCHER

And indeed when I compile with VERBOSE=3 make -j neci I see that files are correctly compiled with callcatcher but the linking step does not prepend the call with callcatcher.

My questions are:

  1. How can I force cmake to prepend the linker command with callcatcher?
  2. If the first question hides an XY problem, how can I solve my original aim of finding uncalled procedures without callcatcher.

My cmake version is 3.21.3.

0

There are 0 best solutions below