1

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.

mcocdawc
  • 1,748
  • 1
  • 12
  • 21
  • 1
    According to CMake documentation, the variable [CMAKE__LINKER_LAUNCHER](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_LINKER_LAUNCHER.html) affects on the property [_LINKER_LAUNCHER](https://cmake.org/cmake/help/latest/prop_tgt/LANG_LINKER_LAUNCHER.html), which in turn exists only for C, CXX, OBJC, and OBJCXX languages. So CMake doesn't support `CMAKE_Fortran_LINKER_LAUNCHER` variable. – Tsyvarev Sep 28 '21 at 19:23

0 Answers0