[CMake] linker parameters for VS2005
Sylvain Benner
benner at virtools.com
Fri Dec 15 06:00:40 EST 2006
This kind of option is not fully supported by CMake. Although it still
works because it is placed in the command line.
To handle this kind of flags, I attached several files.
The flags must be declared like this in the array cmVS7FlagTable
cmLocalVisualStudio7GeneratorLinkerFlagTable[]
// Input
{"IgnoreDefaultLibraryNames", "NODEFAULTLIB", "default libraries to
ignore", "PARAMETERS"},
{"DelayLoadDLLs", "DELAYLOAD", "delayed laoding of
the DLLS", "PARAMETERS"},
Attached you'll find an updated flag table and the new parser function.
This new function supports:
-the override of a flag.
eg.
a CMakeLists.txt sets default settings like this:
SET(CMAKE_EXE_LINKER_FLAGS /SUBSYSTEM:WINDOWS /MACHINE:X86)
a sub-level CMakeLists.txt can override the SUBSYSTEM flag like this :
SET(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE)
-the flag /FLAG:"param1;param2"
Sylvain
Yianis Nikolaou a écrit :
> hi all,
>
> I would like to exclude some libraries from my project
>
> The command
>
> SET(CMAKE_EXE_LINKER_FLAGS /NODEFAULTLIB:LIBC;LIBCMT;MSVCRT)
>
> used to work for VS6 but it does not for VS2005
>
> When the project is created this parameter is included in the [Command
> Line] section of the Project's Linker properties, but not in the
> section [Linker\Input\Ignore Specific Library] where the value should
> be placed.
>
> Note that the syntax of the parameter is
> /NODEFAULTLIB:[name,name,...], but the explanation says that multiple
> libraries should separated by semi-colons.
>
> environment:
> Windows XP, VS2005, CMake 2.4.5
>
> thanks!
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
--
Sylvain Benner
www.virtools.com <http://www.virtools.com> | benner at virtools.com
<mailto:benner at virtools.com>
*Virtools SA* | Developer | R&D department
93 rue vieille du temple
75003 PARIS
France
*Tel:* +33 1 42 71 46 86
*Fax:* +33 1 42 71 86 53
-------------- next part --------------
void cmLocalVisualStudio7Generator::FillFlagMapFromCommandFlags(
std::map<cmStdString, cmStdString>& flagMap,
cmVS7FlagTable* flagTable,
std::string& flags)
{
std::string option;
std::string optionwithSpace;
const int POS_MAX = 65535;
int iBestPos = POS_MAX;
int iCurPos = 0;
std::string curCommand(flagTable->IDEName);
std::string value;
while(flagTable->IDEName)
{
while(flagTable->IDEName && (curCommand == flagTable->IDEName))
{
// while it's the same command, we seek the best flag to write
option.reserve(strlen(flagTable->commandFlag)+1);
optionwithSpace.reserve(strlen(flagTable->commandFlag)+2);
// first do the - version
option = "-";
option += flagTable->commandFlag;
optionwithSpace = option + " ";
// check the option with a space first
while((iCurPos = flags.find(optionwithSpace)) != flags.npos)
{
// replace the flag
cmSystemTools::ReplaceString(flags, optionwithSpace.c_str(), "");
// now put value into flag map
if (iCurPos < iBestPos)
{
value = flagTable->value;
iBestPos = iCurPos;
}
}
// now do the / version
optionwithSpace[0] = '/';
while((iCurPos = flags.find(optionwithSpace)) != flags.npos)
{
// replace the flag
cmSystemTools::ReplaceString(flags, optionwithSpace.c_str(), "");
// now put value into flag map
if (iCurPos < iBestPos)
{
value = flagTable->value;
iBestPos = iCurPos;
}
}
while((iCurPos = flags.find(option)) != flags.npos)
{
// replace the flag
cmSystemTools::ReplaceString(flags, option.c_str(), "");
// now put value into flag map
if (iCurPos < iBestPos)
{
value = flagTable->value;
iBestPos = iCurPos;
}
}
// now do the / version
option[0] = '/';
while((iCurPos = flags.find(option)) != flags.npos)
{
// replace the flag
cmSystemTools::ReplaceString(flags, option.c_str(), "");
// now put value into flag map
if (iCurPos < iBestPos)
{
value = flagTable->value;
iBestPos = iCurPos;
}
}
flagTable++;
}
if(iBestPos != POS_MAX)
{
if(0 == strcmp(value.c_str(), "PARAMETERS"))
{
// flags with parameters
int firstPos = flags.find("\"", iBestPos) + 1;
int lastPos = flags.find("\"", firstPos);
std::string parameters = flags.substr(firstPos, lastPos-firstPos);
value = parameters;
std::string stringToReplace = ":\"" + parameters + "\"";
cmSystemTools::ReplaceString(flags, stringToReplace.c_str(), "");
}
flagMap[curCommand] = value;
}
if (flagTable->IDEName)
{
curCommand = flagTable->IDEName;
iBestPos = POS_MAX;
}
}
// If verbose makefiles have been requested and the /nologo option
// was not given explicitly in the flags we want to add an attribute
// to the generated project to disable logo suppression. Otherwise
// the GUI default is to enable suppression.
if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
{
if(flagMap.find("SuppressStartupBanner") == flagMap.end())
{
flagMap["SuppressStartupBanner"] = "FALSE";
}
}
}
-------------- next part --------------
cmVS7FlagTable cmLocalVisualStudio7GeneratorCompilerFlagTable[] =
{
// option flags (some flags map to the same option)
// C/C++ ----------------------------------------------------------------------------------------------
// General
{"DebugInformationFormat", "Z7", "debug format", "1"},
{"DebugInformationFormat", "Zd", "debug format", "2"},
{"DebugInformationFormat", "Zi", "debug format", "3"},
{"DebugInformationFormat", "ZI", "debug format", "4"},
{"SuppressStartupBanner", "logo", "DO not SuppressStartupBanner", "FALSE"},
{"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE"},
{"WarningLevel", "W1", "Warning level", "1"},
{"WarningLevel", "W2", "Warning level", "2"},
{"WarningLevel", "W3", "Warning level", "3"},
{"WarningLevel", "W4", "Warning level", "4"},
{"Detect64BitPortabilityProblems", "Wp64", "Detect 64-bit Portability Issues", "TRUE"},
{"Detect64BitPortabilityProblems", "noWp64", "Do not Detect 64-bit Portability Issues", "FALSE"},
{"WarnAsError", "WX", "Treat warnings as errors", "TRUE"},
{"WarnAsError", "noWX", "Do not Treat warnings as errors", "FALSE"},
// Optimization
{"Optimization", "Od", "Non Debug", "0"},
{"Optimization", "O1", "Min Size", "1"},
{"Optimization", "O2", "Max Speed", "2"},
{"Optimization", "Ox", "Max Optimization", "3"},
{"GlobalOptimizations", "Og", "Global Optimizations", "TRUE"},
{"GlobalOptimizations", "noOg", "Do not Global Optimizations", "FALSE"},
{"InlineFunctionExpansion", "Ob0", "no inlines", "0"},
{"InlineFunctionExpansion", "Ob1", "when inline keyword", "1"},
{"InlineFunctionExpansion", "Ob2", "any time you can inline", "2"},
{"EnableIntrinsicFunctions", "Oi", "EnableIntrinsicFunctions", "TRUE"},
{"EnableIntrinsicFunctions", "noOi", "Do not EnableIntrinsicFunctions", "FALSE"},
{"ImproveFloatingPointConsistency", "Op", "ImproveFloatingPointConsistency", "TRUE"},
{"ImproveFloatingPointConsistency", "noOp", "Do not ImproveFloatingPointConsistency", "FALSE"},
{"FavorSizeOrSpeed", "Ot", "Favor fast code", "1"},
{"FavorSizeOrSpeed", "Os", "Favor small code", "2"},
{"OmitFramePointers", "Oy", "OmitFramePointers", "TRUE"},
{"OmitFramePointers", "noOy", "Do not OmitFramePointers", "FALSE"},
{"EnableFibreSafeOptimization", "GT", "OmitFramePointers", "TRUE"},
{"EnableFibreSafeOptimization", "noGT", "Don't OmitFramePointers", "FALSE"},
{"OptimizeForProcessor", "GB", "Blended processor mode", "0"},
{"OptimizeForProcessor", "G5", "Pentium", "1"},
{"OptimizeForProcessor", "G6", "PPro PII PIII", "2"},
{"OptimizeForProcessor", "G7", "Pentium 4 or Athlon", "3"},
{"OptimizeForWindowsApplication", "GA", "Optimize for windows", "TRUE"},
{"OptimizeForWindowsApplication", "noGA", "Do not Optimize for windows", "FALSE"},
// Code Generation
{"StringPooling", "noGF", "Disable read-only string pooling", "FALSE"},
{"StringPooling", "GF", "Enable read-only string pooling", "TRUE"},
{"MinimalRebuild", "Gm", "minimal rebuild", "TRUE"},
{"MinimalRebuild", "noGm", "Do not minimal rebuild", "FALSE"},
{"ExceptionHandling", "EHsc2005", "Enable c++ exceptions", "1"},
{"ExceptionHandling", "noEHsc2005", "Do not enable c++ exceptions", "0"},
{"ExceptionHandling", "EHa", "Enable c++ exceptions with SEH exceptions", "2"},
{"ExceptionHandling", "EHsc", "enable c++ exceptions", "TRUE"},
{"ExceptionHandling", "noEHsc", "Do not enable c++ exceptions", "FALSE"},
{"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE"},
{"ExceptionHandling", "noGX", "Do not enable c++ exceptions", "FALSE"},
{"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE"},
{"SmallerTypeCheck", "noRTCc", "Do not smaller type check", "FALSE"},
{"BasicRuntimeChecks", "GZ", "Stack frame checks", "1"},
{"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks ", "3"},
{"BasicRuntimeChecks", "RTC1", "Both stack and uninitialized checks ", "3"},
{"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1"},
{"BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2"},
{"RuntimeLibrary", "MTd", "Multithreded debug", "1"},
{"RuntimeLibrary", "MT", "Multithreded", "0"},
{"RuntimeLibrary", "MDd", "Multithreded dll debug", "3"},
{"RuntimeLibrary", "MD", "Multithreded dll", "2"},
{"RuntimeLibrary", "MLd", "Sinble Thread debug", "5"},
{"RuntimeLibrary", "ML", "Sinble Thread", "4"},
{"StructMemberAlignment", "Zp16", "struct align 16 byte ", "5"},
{"StructMemberAlignment", "Zp1", "struct align 1 byte ", "1"},
{"StructMemberAlignment", "Zp2", "struct align 2 byte ", "2"},
{"StructMemberAlignment", "Zp4", "struct align 4 byte ", "3"},
{"StructMemberAlignment", "Zp8", "struct align 8 byte ", "4"},
{"BufferSecurityCheck", "GS", "Buffer security check", "TRUE"},
{"BufferSecurityCheck", "noGS", "Don't Buffer security check", "FALSE"},
{"EnableFunctionLevelLinking", "Gy", "EnableFunctionLevelLinking", "TRUE"},
{"EnableFunctionLevelLinking", "noGy", "Do not EnableFunctionLevelLinking", "FALSE"},
{"EnableEnhancedInstructionSet", "arch:SSE2", "Use sse2 instructions", "2"},
{"EnableEnhancedInstructionSet", "arch:SSE", "Use sse instructions", "1"},
{"OpenMP", "openmp", "Enable OpenMP support", "TRUE"},
{"OpenMP", "noopenmp", "Do not enable OpenMP support", "FALSE"},
// Language
{"TreatWChar_tAsBuiltInType", "Zc:wchar_t", "Treats wchar_t as a built-in type", "TRUE"},
{"TreatWChar_tAsBuiltInType", "noZc:wchar_t", "Do not Treats wchar_t as a built-in type", "FALSE"},
{"ForceConformanceInForLoopScope", "Zc:forScope", "force conform local scope in for loop", "TRUE"},
{"ForceConformanceInForLoopScope", "noZc:forScope", "No force conform local scope in for loop", "FALSE"},
{"RuntimeTypeInfo", "GR", "Turn on Run time type information for c++", "TRUE"},
{"RuntimeTypeInfo", "noGR", "Turn off Run time type information for c++", "FALSE"},
// Precompiled Headers
{"UsePrecompiledHeader", "Yc", "Create precompiled header", "1"},
{"UsePrecompiledHeader", "YX", "Automatically generate precompiled header", "2"},
{"UsePrecompiledHeader", "Yu2005", "Use precompiled header", "2"},
{"UsePrecompiledHeader", "Yu", "Use precompiled header", "3"},
// Xbox 360
{"RegisterReservation", "QVMXReserve", "VMX registers reservation", "TRUE"},
{"RegisterReservation", "noQVMXReserve", "VMX registers reservation", "FALSE"},
{"TrapIntegerDivides", "Oc", "trap instructions around integer divides", "TRUE"},
{"TrapIntegerDivides", "noOc", "trap instructions around integer divides", "FALSE"},
{"Prescheduling", "Ou", "perform an additional code scheduling pass", "TRUE"},
{"Prescheduling", "noOu", "perform an additional code scheduling pass", "FALSE"},
{"InlineAssembly", "Oz", "reorder inline assembly instruction", "TRUE"},
{"InlineAssembly", "noOz", "reorder inline assembly instruction", "FALSE"},
{"Stalls", "QXSTALLS", "listing with cycle count from pipeline emu", "TRUE"},
{"Stalls", "noQXSTALLS", "listing with cycle count from pipeline emu", "FALSE"},
{"CallAttributedProfiling", "fastcap", "Call profiler around function calls", "1"},
{"CallAttributedProfiling", "callcap", "Call profiler within function calls", "2"},
{0,0,0,0 }
};
cmVS7FlagTable cmLocalVisualStudio7GeneratorMPLinkerFlagTable[] =
{
// Linker ----------------------------------------------------------------------------------------------
// General
{"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1"},
{"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2"},
{"LinkIncremental", "INCREMENTAL", "link incremental", "2"},
{"IgnoreImportLibrary", "IGNOREIMPORTLIBRARY", "IgnoreImportLibrary", "TRUE"},
{"IgnoreImportLibrary", "NOIGNOREIMPORTLIBRARY", "IgnoreImportLibrary", "FALSE"},
{"RegisterOutput", "REGISTEROUTPUT", "Register the primary output", "TRUE"},
{"RegisterOutput", "NOREGISTEROUTPUT", "Register the primary output", "FALSE"},
// Input
{"IgnoreDefaultLibraryNames", "NODEFAULTLIB", "default libraries to ignore", "PARAMETERS"},
{"DelayLoadDLLs", "DELAYLOAD", "delayed laoding of the DLLS", "PARAMETERS"},
// Debugging
{"GenerateDebugInformation", "DEBUG", "Generate Debug Info", "TRUE"},
{"GenerateDebugInformation", "NODEBUG", "Don't Generate Debug Info", "FALSE"},
// System
{"SubSystem", "SUBSYSTEM:CONSOLE", "Sub system", "1"},
{"SubSystem", "SUBSYSTEM:WINDOWS", "Sub system", "2"},
// Optimization
{"OptimizeReferences", "OPT:NOREF", "Keep Unreferenced Data", "1"},
{"OptimizeReferences", "OPT:REF", "Eliminate Unreferenced Data", "2"},
{"EnableCOMDATFolding", "OPT:NOICF", "Do not Remove Redundant COMDATs", "1"},
{"EnableCOMDATFolding", "OPT:ICF", "Remove Redundant COMDATs", "2"},
// Advanced
{"TargetMachine", "MACHINE:X86", "Target Machine", "1"},
{0,0,0,0 }
};
More information about the CMake
mailing list