TARGET_PDB_FILE defined when C# project created directly, not defined when C# project created within function
The enclosed attachment demonstrates a problem I've run into generating C# projects.
If I define a C# project outside of a function, TARGET_PDB_FILE is valid. If I define a C# project inside of a function, TARGET_PDB_FILE is not valid, i.e. I get the error "TARGET_PDB_FILE is not supported by the target linker", as reported at line 2073 of cmGeneratorExpressionNode.cxx. Obviously, our complex build system would like to define projects within functions, so that we can generate common projects using a nested series of functions that apply settings.
Put Test/CSharpBug/CMakeLists.txt.working in place of Test/CSharpBug/CMakeLists.txt and the problem doesn't happen. Test/CSharpBug/CMakeLists.txt.working and Test/Test.cmake are identical except the latter is designed to be called as a function.
I've been digging through the source for some time. The file "CMakeCSharpInformation.cmake" is loaded near line 951 of cmGlobalGenerator.cxx, and defines CMAKE_CSharp_LINKER_SUPPORTS_PDB. The cmMakefile that it's loaded into is also the one that's found at line 2071 of cmGeneratorExpressionNode.cxx, i.e. the pointer values are identical. But somehow, CMAKE_CSharp_LINKER_SUPPORTS_PDB isn't defined any more.
Also, from what I can tell, the C# settings aren't loaded into a "global" makefile, but a project-specific one. If I hack "CSharp" into the list on line 341 of cmProjectCommand.cxx, the problem goes away.
Somehow, makefiles created for a single project are handled differently than makefiles created globally, but I've been unable to figure out how. Hopefully someone more familiar with the CMake source can find this quickly.