From b1f3e1043915666079a9ca4b82d0fe3548c50d36 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 15 Sep 2004 11:31:54 -0400 Subject: [PATCH] BUG: make sure env CC and CXX are not set for VS IDE builds --- Source/cmGlobalGenerator.cxx | 34 +++++++++++++---------- Source/cmGlobalVisualStudio6Generator.cxx | 3 ++ Source/cmGlobalVisualStudio7Generator.cxx | 1 + 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 54b7264a1..ccff33bc8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -198,21 +198,25 @@ void cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, { cmSystemTools::Error("Could not find cmake module file:", determineFile.c_str()); } - - // put ${CMake_(LANG)_COMPILER_ENV_VAR}=${CMAKE_(LANG)_COMPILER into the - // environment, in case user scripts want to run configure, or sub cmakes - std::string compilerName = "CMAKE_"; - compilerName += lang; - compilerName += "_COMPILER"; - std::string compilerEnv = "CMAKE_"; - compilerEnv += lang; - compilerEnv += "_COMPILER_ENV_VAR"; - std::string envVar = mf->GetRequiredDefinition(compilerEnv.c_str()); - std::string envVarValue = mf->GetRequiredDefinition(compilerName.c_str()); - std::string env = envVar; - env += "="; - env += envVarValue; - cmSystemTools::PutEnv(env.c_str()); + // Some generators like visual studio should not use the env variables + // So the global generator can specify that in this variable + if(!mf->GetDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV")) + { + // put ${CMake_(LANG)_COMPILER_ENV_VAR}=${CMAKE_(LANG)_COMPILER into the + // environment, in case user scripts want to run configure, or sub cmakes + std::string compilerName = "CMAKE_"; + compilerName += lang; + compilerName += "_COMPILER"; + std::string compilerEnv = "CMAKE_"; + compilerEnv += lang; + compilerEnv += "_COMPILER_ENV_VAR"; + std::string envVar = mf->GetRequiredDefinition(compilerEnv.c_str()); + std::string envVarValue = mf->GetRequiredDefinition(compilerName.c_str()); + std::string env = envVar; + env += "="; + env += envVarValue; + cmSystemTools::PutEnv(env.c_str()); + } } // **** Step 5, Load the configured language compiler file, if not loaded. diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index e40e77d06..474d91191 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -30,6 +30,9 @@ void cmGlobalVisualStudio6Generator::EnableLanguage(std::vectorcons mf->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)"); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); + mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); + mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); + mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort"); this->GenerateConfigurations(mf); this->cmGlobalGenerator::EnableLanguage(lang, mf); } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index cda991b6a..f3db0cc5e 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -35,6 +35,7 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(std::vectorcons mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); + mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort"); // Create list of configurations requested by user's cache, if any.