nmake/jom: Only warn about bad VS environment if compiler not found.

nmake and jom generators no longer warn about missing INCLUDE/LIB
environment variables unless the C/CXX compiler cannot be found.  This
is useful if the user does not want to use these generators with the
Visual C++ compiler, or they do not want to enable any language.
This commit is contained in:
James Johnston 2015-08-05 21:23:07 +00:00
parent 22590805bf
commit afeb4eb243
12 changed files with 192 additions and 26 deletions

View File

@ -374,6 +374,8 @@ protected:
void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf);
void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf); void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf);
void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf); void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf);
virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
const char* envVar) const;
virtual bool ComputeTargetDepends(); virtual bool ComputeTargetDepends();
@ -462,8 +464,6 @@ private:
virtual void ForceLinkerLanguages(); virtual void ForceLinkerLanguages();
virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
const char* envVar) const;
void CheckCompilerIdCompatibility(cmMakefile* mf, void CheckCompilerIdCompatibility(cmMakefile* mf,
std::string const& lang) const; std::string const& lang) const;

View File

@ -36,18 +36,6 @@ void cmGlobalJOMMakefileGenerator
// pick a default // pick a default
mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
if(!(cmSystemTools::GetEnv("INCLUDE") &&
cmSystemTools::GetEnv("LIB"))
)
{
std::string message = "To use the JOM generator, cmake must be run "
"from a shell that can use the compiler cl from the command line. "
"This environment does not contain INCLUDE, LIB, or LIBPATH, and "
"these must be set for the cl compiler to work. ";
mf->IssueMessage(cmake::WARNING,
message);
}
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
} }
@ -58,3 +46,19 @@ void cmGlobalJOMMakefileGenerator
entry.Name = cmGlobalJOMMakefileGenerator::GetActualName(); entry.Name = cmGlobalJOMMakefileGenerator::GetActualName();
entry.Brief = "Generates JOM makefiles."; entry.Brief = "Generates JOM makefiles.";
} }
//----------------------------------------------------------------------------
void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
std::string const& lang,
const char* envVar) const
{
if(lang == "CXX" || lang == "C")
{
os <<
"To use the JOM generator with Visual C++, cmake must be run from a "
"shell that can use the compiler cl from the command line. This "
"environment is unable to invoke the cl compiler. To fix this problem, "
"run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n";
}
this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar);
}

View File

@ -42,6 +42,9 @@ public:
*/ */
virtual void EnableLanguage(std::vector<std::string>const& languages, virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *, bool optional); cmMakefile *, bool optional);
private:
void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
const char* envVar) const;
}; };
#endif #endif

View File

@ -36,18 +36,6 @@ void cmGlobalNMakeMakefileGenerator
// pick a default // pick a default
mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
if(!(cmSystemTools::GetEnv("INCLUDE") &&
cmSystemTools::GetEnv("LIB"))
)
{
std::string message = "To use the NMake generator, cmake must be run "
"from a shell that can use the compiler cl from the command line. "
"This environment does not contain INCLUDE, LIB, or LIBPATH, and "
"these must be set for the cl compiler to work. ";
mf->IssueMessage(cmake::WARNING,
message);
}
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
} }
@ -58,3 +46,19 @@ void cmGlobalNMakeMakefileGenerator
entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName(); entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName();
entry.Brief = "Generates NMake makefiles."; entry.Brief = "Generates NMake makefiles.";
} }
//----------------------------------------------------------------------------
void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
std::string const& lang,
const char* envVar) const
{
if(lang == "CXX" || lang == "C")
{
os <<
"To use the NMake generator with Visual C++, cmake must be run from a "
"shell that can use the compiler cl from the command line. This "
"environment is unable to invoke the cl compiler. To fix this problem, "
"run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n";
}
this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar);
}

View File

@ -40,6 +40,9 @@ public:
*/ */
virtual void EnableLanguage(std::vector<std::string>const& languages, virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *, bool optional); cmMakefile *, bool optional);
private:
void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
const char* envVar) const;
}; };
#endif #endif

View File

@ -0,0 +1,17 @@
CMake Error at BadCompilerC.cmake:2 \(enable_language\):
The CMAKE_C_COMPILER:
no-C-compiler
is not a full path and was not found in the PATH.
To use the JOM generator with Visual C\+\+, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt \(vcvarsall.bat\).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@ -0,0 +1,17 @@
CMake Error at BadCompilerC.cmake:2 \(enable_language\):
The CMAKE_C_COMPILER:
no-C-compiler
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C\+\+, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt \(vcvarsall.bat\).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@ -0,0 +1,17 @@
CMake Error at BadCompilerCXX.cmake:2 \(enable_language\):
The CMAKE_CXX_COMPILER:
no-CXX-compiler
is not a full path and was not found in the PATH.
To use the JOM generator with Visual C\+\+, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt \(vcvarsall.bat\).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@ -0,0 +1,17 @@
CMake Error at BadCompilerCXX.cmake:2 \(enable_language\):
The CMAKE_CXX_COMPILER:
no-CXX-compiler
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C\+\+, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt \(vcvarsall.bat\).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@ -0,0 +1,35 @@
CMake Error at BadCompilerCandCXX.cmake:3 \(project\):
The CMAKE_C_COMPILER:
no-C-compiler
is not a full path and was not found in the PATH.
To use the JOM generator with Visual C\+\+, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt \(vcvarsall.bat\).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadCompilerCandCXX.cmake:3 \(project\):
The CMAKE_CXX_COMPILER:
no-CXX-compiler
is not a full path and was not found in the PATH.
To use the JOM generator with Visual C\+\+, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt \(vcvarsall.bat\).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@ -0,0 +1,35 @@
CMake Error at BadCompilerCandCXX.cmake:3 \(project\):
The CMAKE_C_COMPILER:
no-C-compiler
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C\+\+, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt \(vcvarsall.bat\).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at BadCompilerCandCXX.cmake:3 \(project\):
The CMAKE_CXX_COMPILER:
no-CXX-compiler
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C\+\+, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt \(vcvarsall.bat\).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@ -4,6 +4,20 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode")
run_cmake(NoCompilerC-IDE) run_cmake(NoCompilerC-IDE)
run_cmake(NoCompilerCXX-IDE) run_cmake(NoCompilerCXX-IDE)
run_cmake(NoCompilerCandCXX-IDE) run_cmake(NoCompilerCandCXX-IDE)
elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles")
set(RunCMake-stderr-file BadCompilerC-stderr-NMake.txt)
run_cmake(BadCompilerC)
set(RunCMake-stderr-file BadCompilerCXX-stderr-NMake.txt)
run_cmake(BadCompilerCXX)
set(RunCMake-stderr-file BadCompilerCandCXX-stderr-NMake.txt)
run_cmake(BadCompilerCandCXX)
elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles JOM")
set(RunCMake-stderr-file BadCompilerC-stderr-JOM.txt)
run_cmake(BadCompilerC)
set(RunCMake-stderr-file BadCompilerCXX-stderr-JOM.txt)
run_cmake(BadCompilerCXX)
set(RunCMake-stderr-file BadCompilerCandCXX-stderr-JOM.txt)
run_cmake(BadCompilerCandCXX)
else() else()
run_cmake(BadCompilerC) run_cmake(BadCompilerC)
run_cmake(BadCompilerCXX) run_cmake(BadCompilerCXX)