Merge topic 'EclipseImprovedSourceProject'

982b766 Eclipse: use new variable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
1110e45 Eclipse: create links to subprojects also in the source-project (#12579)
This commit is contained in:
David Cole 2011-11-22 16:23:56 -05:00 committed by CMake Topic Stage
commit 7b1b13c8f0
3 changed files with 30 additions and 10 deletions

View File

@ -70,8 +70,8 @@ ENDIF()
SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j<some_number> to get parallel builds") SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j<some_number> to get parallel builds")
# This variable is used by the Eclipse generator in out-of-source builds only. # This variable is used by the Eclipse generator in out-of-source builds only.
SET(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR") SET(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")
MARK_AS_ADVANCED(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT) MARK_AS_ADVANCED(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT)
# Determine builtin macros and include dirs: # Determine builtin macros and include dirs:
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake) INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake)

View File

@ -85,7 +85,16 @@ void cmExtraEclipseCDT4Generator::Generate()
this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory); this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory);
this->GenerateSourceProject = (this->IsOutOfSourceBuild && this->GenerateSourceProject = (this->IsOutOfSourceBuild &&
mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT")); mf->IsOn("CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT"));
if ((this->GenerateSourceProject == false)
&& (mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT")))
{
mf->IssueMessage(cmake::WARNING,
"ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT is set to TRUE, "
"but this variable is not supported anymore since CMake 2.8.7.\n"
"Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead.");
}
if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(),
this->HomeDirectory.c_str())) this->HomeDirectory.c_str()))
@ -113,7 +122,7 @@ void cmExtraEclipseCDT4Generator::Generate()
this->CreateCProjectFile(); this->CreateCProjectFile();
} }
void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
{ {
assert(this->HomeDirectory != this->HomeOutputDirectory); assert(this->HomeDirectory != this->HomeOutputDirectory);
@ -141,6 +150,16 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const
"\t</buildSpec>\n" "\t</buildSpec>\n"
"\t<natures>\n" "\t<natures>\n"
"\t</natures>\n" "\t</natures>\n"
"\t<linkedResources>\n";
if (this->SupportsVirtualFolders)
{
this->CreateLinksToSubprojects(fout, this->HomeDirectory);
this->SrcLinkedResources.clear();
}
fout <<
"\t</linkedResources>\n"
"</projectDescription>\n" "</projectDescription>\n"
; ;
} }
@ -434,7 +453,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
if (this->SupportsVirtualFolders) if (this->SupportsVirtualFolders)
{ {
this->CreateLinksToSubprojects(fout); this->CreateLinksToSubprojects(fout, this->HomeOutputDirectory);
this->CreateLinksForTargets(fout); this->CreateLinksForTargets(fout);
} }
@ -541,7 +560,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
cmGeneratedFileStream& fout) cmGeneratedFileStream& fout, const std::string& baseDir)
{ {
// for each sub project create a linked resource to the source dir // for each sub project create a linked resource to the source dir
// - only if it is an out-of-source build // - only if it is an out-of-source build
@ -557,8 +576,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
it->second[0]->GetMakefile()->GetStartDirectory()); it->second[0]->GetMakefile()->GetStartDirectory());
// a linked resource must not point to a parent directory of .project or // a linked resource must not point to a parent directory of .project or
// .project itself // .project itself
if ((this->HomeOutputDirectory != linkSourceDirectory) && if ((baseDir != linkSourceDirectory) &&
!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), !cmSystemTools::IsSubDirectory(baseDir.c_str(),
linkSourceDirectory.c_str())) linkSourceDirectory.c_str()))
{ {
std::string linkName = "[Subprojects]/"; std::string linkName = "[Subprojects]/";

View File

@ -46,7 +46,7 @@ public:
private: private:
// create .project file in the source tree // create .project file in the source tree
void CreateSourceProjectFile() const; void CreateSourceProjectFile();
// create .project file // create .project file
void CreateProjectFile(); void CreateProjectFile();
@ -104,7 +104,8 @@ private:
static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar, static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar,
cmMakefile* mf); cmMakefile* mf);
void CreateLinksToSubprojects(cmGeneratedFileStream& fout); void CreateLinksToSubprojects(cmGeneratedFileStream& fout,
const std::string& baseDir);
void CreateLinksForTargets(cmGeneratedFileStream& fout); void CreateLinksForTargets(cmGeneratedFileStream& fout);
std::vector<std::string> SrcLinkedResources; std::vector<std::string> SrcLinkedResources;