[CMake] Proposal for changing the visual studio generator

Olivier Tournaire olitour at gmail.com
Thu Feb 21 05:54:24 EST 2008


Hello,

I am also very intersted in this change. I usually put all my *.exe in 
one folder, say "bin". For release version, with the name 
$(ProjectName).exe, and Debug version $(ProjectName)-D.exe.

As far as I understand, this is not possible with the current version of 
CMake.

Regards,

Olivier

Gerhard Gappmeier a écrit :
> 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.
>
>

-- 
Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des noyaux. Courage.



More information about the CMake mailing list