Commit b9d5389b authored by Bill Hoffman's avatar Bill Hoffman
Browse files

BUG: fix CMAKE_C_FLAGS for visual studio 6, and add a test case

parent c6323d15
......@@ -842,41 +842,52 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
"EXTRA_DEFINES",
m_Makefile->GetDefineFlags());
cmGlobalGenerator* gen = this->GetGlobalGenerator();
if ( gen->GetLanguageEnabled("C") ||gen->GetLanguageEnabled("CXX") )
{
std::string flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE");
flags += " -DCMAKE_INTDIR=\\\"Release\\\"";
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", flags.c_str());
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flags += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\"";
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", flags.c_str());
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG");
flags += " -DCMAKE_INTDIR=\\\"Debug\\\"";
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", flags.c_str());
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
flags += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\"";
cmSystemTools::ReplaceString(line,"CMAKE_CXX_FLAGS_RELWITHDEBINFO", flags.c_str());
flags = "";
if ( m_Makefile->GetDefinition("CMAKE_C_FLAGS") )
{
flags += m_Makefile->GetDefinition("CMAKE_C_FLAGS");
}
if ( m_Makefile->GetDefinition("CMAKE_CXX_FLAGS") )
{
if ( flags.size() > 0 )
{
// stroe flags for each configuration
std::string flags = " ";
std::string flagsRelease = " ";
std::string flagsMinSize = " ";
std::string flagsDebug = " ";
std::string flagsDebugRel = " ";
// if CXX is on and the target contains cxx code then add the cxx flags
if ( gen->GetLanguageEnabled("CXX") && target.HasCxx() )
{
flagsRelease = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE");
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
flagsMinSize = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
flagsDebug = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG");
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
flagsDebugRel = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
flags = " ";
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS");
flags += " ";
}
flags += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS");
}
// if C and the target is not CXX
else if(gen->GetLanguageEnabled("C") && !target.HasCxx())
{
flagsRelease += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE");
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\"";
flagsMinSize += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\"";
flagsDebug += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG");
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\"";
flagsDebugRel += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\"";
flags = " ";
flags = m_Makefile->GetDefinition("CMAKE_C_FLAGS");
}
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", flagsRelease.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", flagsMinSize.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", flagsDebug.c_str());
cmSystemTools::ReplaceString(line,"CMAKE_CXX_FLAGS_RELWITHDEBINFO", flagsDebugRel.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
}
fout << line.c_str() << std::endl;
}
}
void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
{
std::ifstream fin(m_DSPFooterTemplate.c_str());
......
......@@ -2,13 +2,11 @@
int CsharedFunction()
{
#if !defined(_WIN32) || defined(__CYGWIN__)
#ifndef TEST_C_FLAGS
printf("TEST_C_FLAGS failed\n");
return 0;
#else
printf("Passed: TEST_C_FLAGS passed\n");
#endif
#endif
return 1;
}
......@@ -2,13 +2,11 @@
int CsharedFunction()
{
#if !defined(_WIN32) || defined(__CYGWIN__)
#ifndef TEST_C_FLAGS
printf("TEST_C_FLAGS failed\n");
return 0;
#else
printf("Passed: TEST_C_FLAGS passed\n");
#endif
#endif
return 1;
}
......@@ -2,13 +2,11 @@
int CsharedFunction()
{
#if !defined(_WIN32) || defined(__CYGWIN__)
#ifndef TEST_C_FLAGS
printf("TEST_C_FLAGS failed\n");
return 0;
#else
printf("Passed: TEST_C_FLAGS passed\n");
#endif
#endif
return 1;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment