ENH: make command line flags more consistent with ide settings

This commit is contained in:
Bill Hoffman 2006-02-21 12:19:32 -05:00
parent 74d315077c
commit 0a0e459102
2 changed files with 39 additions and 96 deletions

View File

@ -33,11 +33,11 @@ SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY})
# compile a C++ file into an object file
SET(CMAKE_CXX_COMPILE_OBJECT
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /TP -DWIN32 /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /TP /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
# compile a C file into an object file
SET(CMAKE_C_COMPILE_OBJECT
"<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> -DWIN32 /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
"<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_C_LINK_EXECUTABLE
@ -150,15 +150,15 @@ ENDIF(CMAKE_GENERATOR MATCHES "NMake Makefiles")
IF(CMAKE_COMPILER_2005)
SET(CMAKE_BUILD_TYPE_INIT Debug)
SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /EHsc /GR")
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MDd /Zi /Od /RTC1")
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/DWIN32 /D_DEBUG /D_WINDOWS /MDd /Zi /Ob0 /Od /RTC1")
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/DWIN32 /D_WINDOWS /MD /O1 /Ob1 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/DWIN32 /D_WINDOWS /MD /O2 /Ob2 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/DWIN32 /D_WINDOWS /MD /Zi /O2 /Ob1 /D NDEBUG")
SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000")
SET (CMAKE_C_FLAGS_DEBUG_INIT "/MDd /Zi /Od /RTC1")
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG")
SET (CMAKE_C_FLAGS_DEBUG_INIT "/DWIN32 /D_DEBUG /D_WINDOWS /MDd /Zi /Ob0 /Od /RTC1")
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/DWIN32 /D_WINDOWS /MD /O1 /Ob1 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELEASE_INIT "/DWIN32 /D_WINDOWS /MD /O2 /Ob2 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/DWIN32 /D_WINDOWS /MD /Zi /O2 /Ob1 /D NDEBUG")
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib " CACHE STRING
"Libraries linked by defalut with all applications.")
ELSE(CMAKE_COMPILER_2005)
@ -166,15 +166,15 @@ ELSE(CMAKE_COMPILER_2005)
MESSAGE(STATUS "Using FREE VC TOOLS, NO DEBUG available")
SET(CMAKE_BUILD_TYPE_INIT Release)
SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /GX /GR")
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MTd /Zi /Od /GZ")
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1")
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2")
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/DWIN32 /D_DEBUG /D_WINDOWS /MTd /Zi /Ob0 /Od /GZ")
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/DWIN32 /D_WINDOWS /MT /O1 /Ob1")
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/DWIN32 /D_WINDOWS /MT /O2 /Ob2")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/DWIN32 /D_WINDOWS /MT /Zi /O2 /Ob1")
SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000 /GX /GR")
SET (CMAKE_C_FLAGS_DEBUG_INIT "/MTd /Zi /Od /GZ")
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1")
SET (CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2")
SET (CMAKE_C_FLAGS_DEBUG_INIT "/DWIN32 /D_DEBUG /D_WINDOWS /MTd /Zi /Ob0 /Od /GZ")
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/DWIN32 /D_WINDOWS /MT /O1 /Ob1")
SET (CMAKE_C_FLAGS_RELEASE_INIT "/DWIN32 /D_WINDOWS /MT /O2 /Ob2")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/DWIN32 /D_WINDOWS /MT /Zi /O2 /Ob1")
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib advapi32.lib rpcrt4.lib" CACHE STRING
"Libraries linked by defalut with all applications.")
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib advapi32.lib rpcrt4.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib" CACHE STRING
@ -182,15 +182,15 @@ ELSE(CMAKE_COMPILER_2005)
ELSE(CMAKE_USING_VC_FREE_TOOLS)
SET(CMAKE_BUILD_TYPE_INIT Debug)
SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /GX /GR")
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ")
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/DWIN32 /D_DEBUG /D_WINDOWS /MDd /Zi /Ob0 /Od /GZ")
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/DWIN32 /D_WINDOWS /MD /O1 /Ob1 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/DWIN32 /D_WINDOWS /MD /O2 /Ob2 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/DWIN32 /D_WINDOWS /MD /Zi /O2 /Ob1 /D NDEBUG")
SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000")
SET (CMAKE_C_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ")
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG")
SET (CMAKE_C_FLAGS_DEBUG_INIT "/DWIN32 /D_DEBUG /D_WINDOWS /MDd /Zi /Ob0 /Od /GZ")
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/DWIN32 /D_WINDOWS /MD /O1 /Ob1 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELEASE_INIT "/DWIN32 /D_WINDOWS /MD /O2 /Ob2 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/DWIN32 /D_WINDOWS /MD /Zi /O2 /Ob1 /D NDEBUG")
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING
"Libraries linked by defalut with all applications.")
ENDIF(CMAKE_USING_VC_FREE_TOOLS)

View File

@ -438,10 +438,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
}
std::string flags;
std::string flagsRelease = " ";
std::string flagsMinSize = " ";
std::string flagsDebug = " ";
std::string flagsDebugRel = " ";
if(strcmp(configType, "10") != 0)
{
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
@ -457,69 +453,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
baseFlagVar += linkLanguage;
baseFlagVar += "_FLAGS";
flags = m_Makefile->GetRequiredDefinition(baseFlagVar.c_str());
std::string flagVar = baseFlagVar + "_RELEASE";
flagsRelease += m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagVar = baseFlagVar + "_MINSIZEREL";
flagsMinSize += m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagVar = baseFlagVar + "_DEBUG";
flagsDebug += m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagVar = baseFlagVar + "_RELWITHDEBINFO";
flagsDebugRel += m_Makefile->GetRequiredDefinition(flagVar.c_str());
std::string flagVar = baseFlagVar + std::string("_") +
cmSystemTools::UpperCase(configName);
flags += " ";
flags += m_Makefile->GetRequiredDefinition(flagVar.c_str());
}
}
std::string programDatabase;
const char* pre = "WIN32,_DEBUG,_WINDOWS";
// fill the flagMap for Debug, Release, MinSizeRel, and RelWithDebInfo
// also set the flags, and pre-defined macros
if(strcmp(configName, "Debug") == 0)
{
flagMap["InlineFunctionExpansion"] = "0";
flagMap["Optimization"] = "0";
flagMap["RuntimeLibrary"] = "3";
flags += flagsDebug;
pre = "WIN32,_DEBUG,_WINDOWS";
std::string libpath = m_LibraryOutputPath +
"$(OutDir)/" + libName + ".pdb";
programDatabase = "\t\t\t\tProgramDatabaseFileName=\"";
programDatabase += libpath;
programDatabase += "\"";
}
else if (strcmp(configName, "Release") == 0)
{
flagMap["InlineFunctionExpansion"] = "1";
flagMap["Optimization"] = "2";
flagMap["RuntimeLibrary"] = "2";
flags += flagsRelease;
pre = "WIN32,_WINDOWS";
flags += flagsRelease;
}
else if(strcmp(configName, "MinSizeRel") == 0)
{
flagMap["InlineFunctionExpansion"] = "1";
flagMap["Optimization"] = "1";
flagMap["RuntimeLibrary"] = "2";
pre = "WIN32,_WINDOWS";
flags += flagsMinSize;
}
else if(strcmp(configName, "RelWithDebInfo") == 0)
{
flagMap["InlineFunctionExpansion"] = "1";
flagMap["Optimization"] = "2";
flagMap["RuntimeLibrary"] = "2";
pre = "WIN32,_WINDOWS";
flags += flagsDebugRel;
std::string libpath = m_LibraryOutputPath +
"$(OutDir)/" + libName + ".pdb";
programDatabase = "\t\t\t\tProgramDatabaseFileName=\"";
programDatabase += libpath;
programDatabase += "\"";
}
// Add the target-specific flags.
if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
{
@ -598,7 +538,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
{
fout << "\t\t\t\t" << m->first << "=\"" << m->second << "\"\n";
}
fout << "\t\t\t\tPreprocessorDefinitions=\"" << pre;
fout << "\t\t\t\tPreprocessorDefinitions=\"";
if(target.GetType() == cmTarget::SHARED_LIBRARY
|| target.GetType() == cmTarget::MODULE_LIBRARY)
{
@ -619,9 +559,12 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
fout << "\"\n";
fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
if(programDatabase.size())
{
fout << programDatabase << "\n";
std::map<cmStdString, cmStdString>::iterator mi = flagMap.find("DebugInformationFormat");
if(mi != flagMap.end() && mi->second != "1")
{
fout << "\t\t\t\tProgramDatabaseFileName=\""
<< m_LibraryOutputPath
<< "$(OutDir)/" << libName << ".pdb\"\n";
}
fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n";
@ -634,12 +577,12 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
}
// add the -D flags to the RC tool
fout << "\"\n"
<< "\t\t\t\tPreprocessorDefinitions=\"" << pre;
<< "\t\t\t\tPreprocessorDefinitions=\"";
this->OutputDefineFlags(defineFlags.c_str(), fout);
fout << "\" />\n";
fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n";
fout << "\t\t\t\tPreprocessorDefinitions=\"" << pre;
fout << "\t\t\t\tPreprocessorDefinitions=\"";
this->OutputDefineFlags(defineFlags.c_str(), fout);
fout << "\"\n";
fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n";