How can I get CMAKE to create a VS solution with pdb files for static libraries?

Hi all,

I’ve checked out the blender git repository and was quickly able to build it for Win32 with CMAKE and Visual Studio 2013 Community Edition using the build instructions found here. Happy about the quick success I was eager to start debugging and see what is happening under the hood.
Then I realized that Visual Studio wasn’t able to hit the breakpoints I had set because it had no debugging information for the assemblies available, even though I built blender in “Debug” configuration.

After a bit of digging I found the solution for the projects “blender” and “blender-launcher”: Fill the advanced CMAKE option “CMAKE_EXE_LINKER_FLAGS_DEBUG” with “/DEBUG” and voilà: The pdb files with debugging symbols are generated and breakpoints start to work for these two projects.
(Is there a reason why this isn’t the default for CMAKE debug configuration?)

My joy was shortlived, because that didn’t enable breakpoints for any of the static libraries, like “blenkernel”. I found that you have to change the project option “C/C++ -> Output Files -> Program Database File Name” from the Visual Studio default to “$(OutDir)$(TargetName).pdb” and that specific static library starts hitting breakpoints.
“OK”, I thought, “there are a lot of projects and CMAKE is going to overwrite this change anyway on the next ‘Generate’ - I have to do this via CMAKE!”

And this is where I’m stuck. There is a CMAKE variable available called “CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG”, but it is only working for setting the output directory - a “” gets appended (hardcoded in CMAKE). A corresponding variable for setting the file name globally for all static library symbol files sadly does not exist.
One level below that there are the CMAKE “properties” called “COMPILE_PDB_NAME” and “COMPILE_PDB_OUTPUT_DIRECTORY”. The latter can be accessed by setting said variable, but the missing piece - “COMPILE_PDB_NAME” - I cannot seem to change via the CMAKE frontend.

What am I missing? How are you guys who work with MSVC generating the build system for blender so you can properly debug? I was not able to find any documentation about this. Any help is greatly appreciated.

Thank you in advance.