Eclipse: Add option to set the resource encoding

This commit is contained in:
Martin Gerhardy 2019-07-08 10:57:34 +02:00 committed by Brad King
parent 5f2f16319a
commit 09c1991895
6 changed files with 40 additions and 0 deletions

View File

@ -915,6 +915,7 @@ syn keyword cmakeVariable contained
\ CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
\ CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
\ CMAKE_ECLIPSE_MAKE_ARGUMENTS
\ CMAKE_ECLIPSE_RESOURCE_ENCODING
\ CMAKE_ECLIPSE_VERSION
\ CMAKE_EDIT_COMMAND
\ CMAKE_ENABLE_EXPORTS

View File

@ -157,6 +157,7 @@ Variables that Change Behavior
/variable/CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
/variable/CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
/variable/CMAKE_ECLIPSE_MAKE_ARGUMENTS
/variable/CMAKE_ECLIPSE_RESOURCE_ENCODING
/variable/CMAKE_ECLIPSE_VERSION
/variable/CMAKE_ERROR_DEPRECATED
/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION

View File

@ -0,0 +1,6 @@
eclipse-resource-encoding
-------------------------
* The :generator:`Eclipse CDT4` extra generator gained a new
:variable:`CMAKE_ECLIPSE_RESOURCE_ENCODING` option to specify
the resource encoding.

View File

@ -0,0 +1,6 @@
CMAKE_ECLIPSE_RESOURCE_ENCODING
-------------------------------
This cache variable tells the :generator:`Eclipse CDT4` project generator
to set the resource encoding to the given value in generated project files.
If no value is given, no encoding will be set.

View File

@ -164,6 +164,29 @@ void cmExtraEclipseCDT4Generator::Generate()
// create a .cproject file
this->CreateCProjectFile();
// create resource settings
this->CreateSettingsResourcePrefsFile();
}
void cmExtraEclipseCDT4Generator::CreateSettingsResourcePrefsFile()
{
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
cmMakefile* mf = lg->GetMakefile();
const std::string filename =
this->HomeOutputDirectory + "/.settings/org.eclipse.core.resources.prefs";
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
fout << "eclipse.preferences.version=1" << std::endl;
const char* encoding = mf->GetDefinition("CMAKE_ECLIPSE_RESOURCE_ENCODING");
if (encoding) {
fout << "encoding/<project>=" << encoding << std::endl;
}
}
void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()

View File

@ -43,6 +43,9 @@ private:
// create .project file in the source tree
void CreateSourceProjectFile();
// create .settings/org.eclipse.core.resources.prefs
void CreateSettingsResourcePrefsFile();
// create .project file
void CreateProjectFile();