From b9d5389bcaa89fa285551547bb177dada83ca284 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 13 Jan 2003 09:30:48 -0500 Subject: BUG: fix CMAKE_C_FLAGS for visual studio 6, and add a test case --- Source/cmLocalVisualStudio6Generator.cxx | 67 +++++++++++++++----------- Tests/Complex/Library/testConly.c | 2 - Tests/ComplexOneConfig/Library/testConly.c | 2 - Tests/ComplexRelativePaths/Library/testConly.c | 2 - 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index e6c75c0..894c89e 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -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") ) + // 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"); - 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 ) - { - flags += " "; - } - flags += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS"); - } - - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str()); + 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 += " "; } + // 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()); diff --git a/Tests/Complex/Library/testConly.c b/Tests/Complex/Library/testConly.c index d179b21..35d6a39 100644 --- a/Tests/Complex/Library/testConly.c +++ b/Tests/Complex/Library/testConly.c @@ -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; } diff --git a/Tests/ComplexOneConfig/Library/testConly.c b/Tests/ComplexOneConfig/Library/testConly.c index d179b21..35d6a39 100644 --- a/Tests/ComplexOneConfig/Library/testConly.c +++ b/Tests/ComplexOneConfig/Library/testConly.c @@ -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; } diff --git a/Tests/ComplexRelativePaths/Library/testConly.c b/Tests/ComplexRelativePaths/Library/testConly.c index d179b21..35d6a39 100644 --- a/Tests/ComplexRelativePaths/Library/testConly.c +++ b/Tests/ComplexRelativePaths/Library/testConly.c @@ -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; } -- cgit v0.12