Bart Vandewoestyne
Bart Vandewoestyne

Reputation: 553

CMake Error: TARGET_PDB_FILE is not supported by the target linker

I am working on an older i386 laptop, and since no i386 builds of CMake are provided at https://cmake.org/download/ I have built my own i386 build of CMake 3.19.4. I am now using that to build an old OpenCV 2.3.1 on Ubuntu 18.04 using g++ 7.5.0. When I try that, I get lots of lines like the following one:

CMake Error:
  Error evaluating generator expression:

    $<TARGET_PDB_FILE:opencv_stitching>

  TARGET_PDB_FILE is not supported by the target linker.

After some investigation, I found that this is caused by the following line that appears in several CMakeLists.txt files scattered across OpenCV source directory:

install(FILES $<TARGET_PDB_FILE:${the_target}> DESTINATION bin COMPONENT main)

If I comment out these lines, then that seems to solve the problem. However, I prefer not to do that because this line is actually useful for my Windows OpenCV build. I prefer to have the PDB files installed for debugging purposes.

So what exactly is the reason for this error and how can I solve it in a clean way so that the build passes on Linux, and I still have my PDB files on Windows?

Upvotes: 1

Views: 2418

Answers (1)

vre
vre

Reputation: 6744

If an command is only suited for a special platform or compiler you can include that in an if clause, e.g. in your case

if (MSVC)
  install(FILES $<TARGET_PDB_FILE:${the_target}> DESTINATION bin COMPONENT main)
endif()

Upvotes: 3

Related Questions