0

When I install my libraries for debug builds, the pdb files get copied as well.

I want the same thing for release builds too, but CMake doesnot do that. So I have to manually pick the *.pdb files in the CMAKE_BINARY_DIR and copy them.

Basically, how do i do that? Or is there any other way to solve this problem?

Nick
  • 1,692
  • 3
  • 21
  • 35

1 Answers1

2

One way to do this is to use Cmake's "file" function like so.

if(CMAKE_BUILD_TYPE EQUAL "RELEASE")
    file(GLOB filelist ${PATH_TO_PDB_FILES}/*.pdb)
    file(COPY ${filelist} DESTINATION ${PATH_TO_PDB_DESTINATION})
endif(CMAKE_BUILD_TYPE EQUAL "RELEASE")

The first "file" function call uses the "GLOB" option and that generates a list (called "filelist") of .pdb files located in the "PATH_TO_PDB_FILES" directory.

The second "file" function call uses the "COPY" option and it uses the file list generated by the first "file" function call and copies those file in the "PATH_TO_PDB_DESTINATION" directory.

I also put the if statement to check if you are doing a release build. (Assuming you only want to do this on release builds.)

EDIT: If I understand correctly you want to copy the pdb files at the installation phase. If this is the case this should do it:

INSTALL(DIRECTORY ${PATH_TO_PDB_FILES}
    DESTINATION ${PATH_TO_PDB_DESTINATION}
    CONFIGURATIONS Release
    FILES_MATCHING
    PATTERN *.pdb
)
Cyberunner23
  • 128
  • 1
  • 7
  • pdb files are not generated until the library is built.. This should run as a post build task, how to do that?? – Nick Jan 19 '15 at 03:18
  • About `if(CMAKE_BUILD_TYPE EQUAL "RELEASE")`: http://stackoverflow.com/questions/24460486/cmake-build-type-not-being-used-in-cmakelists-txt –  Jan 19 '15 at 09:35
  • Please look at my edit, this new solution should do the trick. – Cyberunner23 Jan 20 '15 at 22:03