Skip to content
Snippets Groups Projects
Commit aff38945 authored by Alexander Neundorf's avatar Alexander Neundorf
Browse files

Eclipse: only add C/CXX macros if the language is enabled

With this patch, the builtin macros and include dirs are only
added to the project file if the C/CXX langauges are really enabled.
I.e. before this patch the CXX-stuff was in the project file as soon
as CXX had been enabled at least once for this build tree.
I.e. disabling CXX later on did not remove the CXX macros etc.
from the project file (related to #15150)

Alex
parent 6ee6b17e
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,8 @@ cmExtraEclipseCDT4Generator
this->GenerateLinkedResources = true;
this->SupportsGmakeErrorParser = true;
this->SupportsMachO64Parser = true;
this->CEnabled = false;
this->CXXEnabled = false;
}
//----------------------------------------------------------------------------
......@@ -64,10 +66,12 @@ void cmExtraEclipseCDT4Generator
{
this->Natures.insert("org.eclipse.cdt.core.ccnature");
this->Natures.insert("org.eclipse.cdt.core.cnature");
this->CXXEnabled = true;
}
else if (*lit == "C")
{
this->Natures.insert("org.eclipse.cdt.core.cnature");
this->CEnabled = true;
}
else if (*lit == "Java")
{
......@@ -890,7 +894,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// add system defined c macros
const char* cDefs=mf->GetDefinition(
"CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS");
if(cDefs)
if(this->CEnabled && cDefs)
{
// Expand the list.
std::vector<std::string> defs;
......@@ -925,7 +929,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// add system defined c++ macros
const char* cxxDefs = mf->GetDefinition(
"CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS");
if(cxxDefs)
if(this->CXXEnabled && cxxDefs)
{
// Expand the list.
std::vector<std::string> defs;
......@@ -979,7 +983,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// CMakeSystemSpecificInformation.cmake. This makes Eclipse find the
// standard headers.
std::string compiler = mf->GetSafeDefinition("CMAKE_C_COMPILER");
if (!compiler.empty())
if (this->CEnabled && !compiler.empty())
{
std::string systemIncludeDirs = mf->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
......@@ -988,7 +992,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
this->AppendIncludeDirectories(fout, dirs, emmited);
}
compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
if (!compiler.empty())
if (this->CXXEnabled && !compiler.empty())
{
std::string systemIncludeDirs = mf->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
......
......@@ -116,6 +116,8 @@ private:
bool SupportsVirtualFolders;
bool SupportsGmakeErrorParser;
bool SupportsMachO64Parser;
bool CEnabled;
bool CXXEnabled;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment