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 ...@@ -842,41 +842,52 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
"EXTRA_DEFINES", "EXTRA_DEFINES",
m_Makefile->GetDefineFlags()); m_Makefile->GetDefineFlags());
cmGlobalGenerator* gen = this->GetGlobalGenerator(); cmGlobalGenerator* gen = this->GetGlobalGenerator();
if ( gen->GetLanguageEnabled("C") ||gen->GetLanguageEnabled("CXX") ) // 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() )
{ {
std::string flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE"); flagsRelease = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE");
flags += " -DCMAKE_INTDIR=\\\"Release\\\""; flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", flags.c_str()); flagsMinSize = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL"); flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
flags += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\""; flagsDebug = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG");
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", flags.c_str()); flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG"); flagsDebugRel = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
flags += " -DCMAKE_INTDIR=\\\"Debug\\\""; flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", flags.c_str()); flags = " ";
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO"); flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS");
flags += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\""; flags += " ";
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 )
{
flags += " ";
}
flags += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS");
}
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
} }
// 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; fout << line.c_str() << std::endl;
} }
} }
void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout) void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
{ {
std::ifstream fin(m_DSPFooterTemplate.c_str()); std::ifstream fin(m_DSPFooterTemplate.c_str());
......
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
int CsharedFunction() int CsharedFunction()
{ {
#if !defined(_WIN32) || defined(__CYGWIN__)
#ifndef TEST_C_FLAGS #ifndef TEST_C_FLAGS
printf("TEST_C_FLAGS failed\n"); printf("TEST_C_FLAGS failed\n");
return 0; return 0;
#else #else
printf("Passed: TEST_C_FLAGS passed\n"); printf("Passed: TEST_C_FLAGS passed\n");
#endif #endif
#endif
return 1; return 1;
} }
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
int CsharedFunction() int CsharedFunction()
{ {
#if !defined(_WIN32) || defined(__CYGWIN__)
#ifndef TEST_C_FLAGS #ifndef TEST_C_FLAGS
printf("TEST_C_FLAGS failed\n"); printf("TEST_C_FLAGS failed\n");
return 0; return 0;
#else #else
printf("Passed: TEST_C_FLAGS passed\n"); printf("Passed: TEST_C_FLAGS passed\n");
#endif #endif
#endif
return 1; return 1;
} }
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
int CsharedFunction() int CsharedFunction()
{ {
#if !defined(_WIN32) || defined(__CYGWIN__)
#ifndef TEST_C_FLAGS #ifndef TEST_C_FLAGS
printf("TEST_C_FLAGS failed\n"); printf("TEST_C_FLAGS failed\n");
return 0; return 0;
#else #else
printf("Passed: TEST_C_FLAGS passed\n"); printf("Passed: TEST_C_FLAGS passed\n");
#endif #endif
#endif
return 1; 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