[CMake] Proposal for changing the visual studio generator

Gerhard Gappmeier gerhard.gappmeier at ascolab.com
Thu Feb 21 05:48:00 EST 2008


Hello,

I have a proposal to change the Visual Studio Generator.

The current version 2.4.8 works like this:
1.) CMake generates hardcoded paths for OutputFile, PDB File, Addition 
Library Directories etc.
e.g.
OutputDirectory=Debug (or Release, etc. depending on the config)
OutputFile=D:\work\cmake-2.4.8\build\bin\Debug\cmake.exe

2.) OutputDirectory does not contain a directory, it's used like a 
ConfigurationName.
Code Snippet (cmLocalVisualStudio7Generator.cxx):
0463 fout << "\t\t<Configuration\n"
0464 << "\t\t\tName=\"" << configName << "|" << this->PlatformName << "\"\n"
0465 << "\t\t\tOutputDirectory=\"" << configName << "\"\n";

3.) OutputFile contains a hardcoded path, that always contains the 
configurationname (Debug|Release|...).
Code Snippet (cmLocalVisualStudio7Generator.cxx):
0882 temp = this->ExecutableOutputPath;
0883 temp += configName;
0884 temp += "/";
0885 temp += targetNameFull;
0886 fout << "\t\t\t\tOutputFile=\""
0887 << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";

The problem is that this hardcoded paths are very unflexible.
It should better use the macros that are used when you generate a 
projects using the wizard.

My Proposal:
1.) Use the normal macros like its done by the wizard.
OutputDirectory=$(SolutionDir)$(ConfigurationName)
OutputFile=$(OutDir)\$(ProjectName).exe
Use this $(OutDir) also for pdb, manifest, etc.

This resolves to the same path as the hardcoded ones.
But you can easily change the output dir in the project by just changing 
this single OutputDirectory,
that's what it was intended for.

2.) Using
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/mypath)
or
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/mypath)
it should be possible to replace the default value of OutputDirectory.
This way you can easily change the output directory from CMakeLists.txt and
it's not necassary to change it afterwards in the VS Project.

This way you can get rid of the autogenerated Debug/Release folders if 
you don't want them,
but also keeps the current behaviour, or better the Visual Studio 
default behavior
as long as you don't overwrite the output paths.


-- 
mit freundlichen Grüßen / best regards

*Gerhard Gappmeier*
ascolab GmbH - automation systems communication laboratory
Tel.: +49 9131 691 123
Fax: +49 9131 691 128
Web: http://www.ascolab.com
GPG-Key: http://www.ascolab.com/gpg/gg.asc

--
*ascolab GmbH*
Geschäftsführer: Gerhard Gappmeier, Matthias Damm, Uwe Steinkrauß
Sitz der Gesellschaft: Am Weichselgarten 7 • 91058 Erlangen • Germany
Registernummer: HRB 9360
Registergericht: Amtsgericht Fürth



More information about the CMake mailing list