2012-10-10 22:01:48 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2004-2009 Kitware, Inc.
|
|
|
|
Copyright 2004 Alexander Neundorf (neundorf@kde.org)
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
#include "cmExtraSublimeTextGenerator.h"
|
2013-02-11 22:23:02 +00:00
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmGeneratorTarget.h"
|
2012-10-10 22:01:48 +00:00
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
2013-02-11 22:23:02 +00:00
|
|
|
#include "cmLocalGenerator.h"
|
2012-10-10 22:01:48 +00:00
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSourceFile.h"
|
|
|
|
#include "cmSystemTools.h"
|
2013-02-11 22:23:02 +00:00
|
|
|
#include "cmTarget.h"
|
2012-10-10 22:01:48 +00:00
|
|
|
#include "cmXMLSafe.h"
|
|
|
|
|
|
|
|
#include <cmsys/SystemTools.hxx>
|
|
|
|
|
2012-10-13 09:20:09 +00:00
|
|
|
/*
|
|
|
|
Sublime Text 2 Generator
|
|
|
|
Author: Morné Chamberlain
|
|
|
|
This generator was initially based off of the CodeBlocks generator.
|
|
|
|
|
|
|
|
Some useful URLs:
|
2012-10-10 22:01:48 +00:00
|
|
|
Homepage:
|
|
|
|
http://www.sublimetext.com/
|
|
|
|
|
|
|
|
File format docs:
|
|
|
|
http://www.sublimetext.com/docs/2/projects.html
|
|
|
|
http://sublimetext.info/docs/en/reference/build_systems.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraSublimeTextGenerator
|
2014-02-24 22:36:27 +00:00
|
|
|
::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
|
2012-10-10 22:01:48 +00:00
|
|
|
{
|
|
|
|
entry.Name = this->GetName();
|
|
|
|
entry.Brief = "Generates Sublime Text 2 project files.";
|
|
|
|
}
|
|
|
|
|
|
|
|
cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator()
|
|
|
|
:cmExternalMakefileProjectGenerator()
|
|
|
|
{
|
|
|
|
#if defined(_WIN32)
|
|
|
|
this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
|
|
|
|
this->SupportedGlobalGenerators.push_back("NMake Makefiles");
|
|
|
|
// disable until somebody actually tests it:
|
|
|
|
// this->SupportedGlobalGenerators.push_back("MSYS Makefiles");
|
|
|
|
#endif
|
|
|
|
this->SupportedGlobalGenerators.push_back("Ninja");
|
|
|
|
this->SupportedGlobalGenerators.push_back("Unix Makefiles");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmExtraSublimeTextGenerator::Generate()
|
|
|
|
{
|
|
|
|
// for each sub project in the project create a sublime text 2 project
|
2014-02-10 05:21:34 +00:00
|
|
|
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
2012-10-10 22:01:48 +00:00
|
|
|
it = this->GlobalGenerator->GetProjectMap().begin();
|
|
|
|
it!= this->GlobalGenerator->GetProjectMap().end();
|
|
|
|
++it)
|
|
|
|
{
|
|
|
|
// create a project file
|
|
|
|
this->CreateProjectFile(it->second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmExtraSublimeTextGenerator::CreateProjectFile(
|
|
|
|
const std::vector<cmLocalGenerator*>& lgs)
|
|
|
|
{
|
|
|
|
const cmMakefile* mf=lgs[0]->GetMakefile();
|
|
|
|
std::string outputDir=mf->GetStartOutputDirectory();
|
|
|
|
std::string projectName=mf->GetProjectName();
|
|
|
|
|
2013-02-06 18:31:44 +00:00
|
|
|
const std::string filename =
|
|
|
|
outputDir + "/" + projectName + ".sublime-project";
|
2012-10-10 22:01:48 +00:00
|
|
|
|
|
|
|
this->CreateNewProjectFile(lgs, filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmExtraSublimeTextGenerator
|
|
|
|
::CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
|
|
|
|
const std::string& filename)
|
|
|
|
{
|
|
|
|
const cmMakefile* mf=lgs[0]->GetMakefile();
|
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
|
|
|
if(!fout)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-14 08:46:29 +00:00
|
|
|
const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath(
|
2012-11-11 20:07:49 +00:00
|
|
|
mf->GetHomeOutputDirectory(),
|
|
|
|
mf->GetHomeDirectory());
|
2012-10-14 08:46:29 +00:00
|
|
|
// Write the folder entries to the project file
|
2012-10-11 20:53:40 +00:00
|
|
|
fout << "{\n";
|
|
|
|
fout << "\t\"folders\":\n\t[\n\t";
|
2012-10-14 15:37:51 +00:00
|
|
|
if (!sourceRootRelativeToOutput.empty())
|
|
|
|
{
|
|
|
|
fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\"";
|
|
|
|
const std::string &outputRelativeToSourceRoot =
|
2012-11-11 20:07:49 +00:00
|
|
|
cmSystemTools::RelativePath(mf->GetHomeDirectory(),
|
|
|
|
mf->GetHomeOutputDirectory());
|
2012-10-18 20:54:19 +00:00
|
|
|
if ((!outputRelativeToSourceRoot.empty()) &&
|
|
|
|
((outputRelativeToSourceRoot.length() < 3) ||
|
|
|
|
(outputRelativeToSourceRoot.substr(0, 3) != "../")))
|
|
|
|
{
|
|
|
|
fout << ",\n\t\t\t\"folder_exclude_patterns\": [\"" <<
|
|
|
|
outputRelativeToSourceRoot << "\"]";
|
|
|
|
}
|
2012-10-14 15:37:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fout << "\t{\n\t\t\t\"path\": \"./\"";
|
|
|
|
}
|
|
|
|
fout << "\n\t\t}";
|
2012-10-11 20:53:40 +00:00
|
|
|
// End of the folders section
|
2012-10-14 15:37:51 +00:00
|
|
|
fout << "\n\t]";
|
2012-10-11 20:53:40 +00:00
|
|
|
|
|
|
|
// Write the beginning of the build systems section to the project file
|
|
|
|
fout << ",\n\t\"build_systems\":\n\t[\n\t";
|
|
|
|
|
|
|
|
// Set of include directories over all targets (sublime text/sublimeclang
|
|
|
|
// doesn't currently support these settings per build system, only project
|
|
|
|
// wide
|
2012-11-11 20:07:49 +00:00
|
|
|
MapSourceFileFlags sourceFileFlags;
|
|
|
|
AppendAllTargets(lgs, mf, fout, sourceFileFlags);
|
2013-02-06 18:31:44 +00:00
|
|
|
|
2012-10-11 20:53:40 +00:00
|
|
|
// End of build_systems
|
|
|
|
fout << "\n\t]";
|
2013-02-06 18:31:44 +00:00
|
|
|
fout << "\n\t}";
|
2012-11-24 18:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-11 20:53:40 +00:00
|
|
|
void cmExtraSublimeTextGenerator::
|
|
|
|
AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
|
|
|
|
const cmMakefile* mf,
|
|
|
|
cmGeneratedFileStream& fout,
|
2012-11-11 20:07:49 +00:00
|
|
|
MapSourceFileFlags& sourceFileFlags)
|
2012-10-11 20:53:40 +00:00
|
|
|
{
|
2012-10-10 22:01:48 +00:00
|
|
|
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
std::string compiler = "";
|
2012-11-11 20:07:49 +00:00
|
|
|
if (!lgs.empty())
|
|
|
|
{
|
|
|
|
this->AppendTarget(fout, "all", lgs[0], 0, make.c_str(), mf,
|
|
|
|
compiler.c_str(), sourceFileFlags, true);
|
|
|
|
this->AppendTarget(fout, "clean", lgs[0], 0, make.c_str(), mf,
|
|
|
|
compiler.c_str(), sourceFileFlags, false);
|
|
|
|
}
|
2012-10-10 22:01:48 +00:00
|
|
|
|
|
|
|
// add all executable and library targets and some of the GLOBAL
|
|
|
|
// and UTILITY targets
|
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
|
|
|
|
lg!=lgs.end(); lg++)
|
|
|
|
{
|
|
|
|
cmMakefile* makefile=(*lg)->GetMakefile();
|
|
|
|
cmTargets& targets=makefile->GetTargets();
|
|
|
|
for (cmTargets::iterator ti = targets.begin();
|
|
|
|
ti != targets.end(); ti++)
|
|
|
|
{
|
|
|
|
switch(ti->second.GetType())
|
|
|
|
{
|
|
|
|
case cmTarget::GLOBAL_TARGET:
|
|
|
|
{
|
|
|
|
// Only add the global targets from CMAKE_BINARY_DIR,
|
|
|
|
// not from the subdirs
|
|
|
|
if (strcmp(makefile->GetStartOutputDirectory(),
|
|
|
|
makefile->GetHomeOutputDirectory())==0)
|
|
|
|
{
|
2014-03-10 23:04:11 +00:00
|
|
|
this->AppendTarget(fout, ti->first, *lg, 0,
|
2012-10-10 22:01:48 +00:00
|
|
|
make.c_str(), makefile, compiler.c_str(),
|
2012-11-11 20:07:49 +00:00
|
|
|
sourceFileFlags, false);
|
2012-10-10 22:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cmTarget::UTILITY:
|
|
|
|
// Add all utility targets, except the Nightly/Continuous/
|
|
|
|
// Experimental-"sub"targets as e.g. NightlyStart
|
|
|
|
if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly"))
|
|
|
|
|| ((ti->first.find("Continuous")==0)&&(ti->first!="Continuous"))
|
|
|
|
|| ((ti->first.find("Experimental")==0)
|
|
|
|
&& (ti->first!="Experimental")))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-03-10 23:04:11 +00:00
|
|
|
this->AppendTarget(fout, ti->first, *lg, 0,
|
2012-10-10 23:01:13 +00:00
|
|
|
make.c_str(), makefile, compiler.c_str(),
|
2012-11-11 20:07:49 +00:00
|
|
|
sourceFileFlags, false);
|
2012-10-10 22:01:48 +00:00
|
|
|
break;
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
case cmTarget::OBJECT_LIBRARY:
|
|
|
|
{
|
2014-03-10 23:04:11 +00:00
|
|
|
this->AppendTarget(fout, ti->first, *lg, &ti->second,
|
2012-10-10 23:01:13 +00:00
|
|
|
make.c_str(), makefile, compiler.c_str(),
|
2012-11-11 20:07:49 +00:00
|
|
|
sourceFileFlags, false);
|
2012-10-10 22:01:48 +00:00
|
|
|
std::string fastTarget = ti->first;
|
|
|
|
fastTarget += "/fast";
|
2014-03-10 23:04:11 +00:00
|
|
|
this->AppendTarget(fout, fastTarget, *lg, &ti->second,
|
2012-10-10 23:01:13 +00:00
|
|
|
make.c_str(), makefile, compiler.c_str(),
|
2012-11-11 20:07:49 +00:00
|
|
|
sourceFileFlags, false);
|
2012-10-10 22:01:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-18 20:54:19 +00:00
|
|
|
void cmExtraSublimeTextGenerator::
|
2012-11-11 20:07:49 +00:00
|
|
|
AppendTarget(cmGeneratedFileStream& fout,
|
2014-02-06 22:31:47 +00:00
|
|
|
const std::string& targetName,
|
2012-11-11 20:07:49 +00:00
|
|
|
cmLocalGenerator* lg,
|
|
|
|
cmTarget* target,
|
|
|
|
const char* make,
|
|
|
|
const cmMakefile* makefile,
|
2013-02-11 22:23:02 +00:00
|
|
|
const char*, //compiler
|
2012-11-11 20:07:49 +00:00
|
|
|
MapSourceFileFlags& sourceFileFlags,
|
|
|
|
bool firstTarget)
|
2012-10-10 22:01:48 +00:00
|
|
|
{
|
2013-02-11 22:23:02 +00:00
|
|
|
|
2012-10-10 23:01:13 +00:00
|
|
|
if (target != 0)
|
|
|
|
{
|
|
|
|
cmGeneratorTarget *gtgt = this->GlobalGenerator
|
|
|
|
->GetGeneratorTarget(target);
|
2013-07-14 16:22:57 +00:00
|
|
|
std::vector<cmSourceFile*> sourceFiles;
|
2014-02-13 16:25:00 +00:00
|
|
|
target->GetSourceFiles(sourceFiles,
|
|
|
|
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
2012-11-11 20:07:49 +00:00
|
|
|
std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
|
|
|
|
sourceFiles.end();
|
|
|
|
for (std::vector<cmSourceFile*>::const_iterator iter =
|
|
|
|
sourceFiles.begin(); iter != sourceFilesEnd; ++iter)
|
2012-10-10 23:01:13 +00:00
|
|
|
{
|
2012-11-11 20:07:49 +00:00
|
|
|
cmSourceFile* sourceFile = *iter;
|
|
|
|
MapSourceFileFlags::iterator sourceFileFlagsIter =
|
|
|
|
sourceFileFlags.find(sourceFile->GetFullPath());
|
|
|
|
if (sourceFileFlagsIter == sourceFileFlags.end())
|
|
|
|
{
|
|
|
|
sourceFileFlagsIter =
|
|
|
|
sourceFileFlags.insert(MapSourceFileFlags::value_type(
|
|
|
|
sourceFile->GetFullPath(), std::vector<std::string>())).first;
|
|
|
|
}
|
|
|
|
std::vector<std::string>& flags = sourceFileFlagsIter->second;
|
|
|
|
std::string flagsString =
|
|
|
|
this->ComputeFlagsForObject(*iter, lg, target, gtgt);
|
|
|
|
std::string definesString =
|
|
|
|
this->ComputeDefines(*iter, lg, target, gtgt);
|
|
|
|
flags.clear();
|
|
|
|
cmsys::RegularExpression flagRegex;
|
2012-11-24 18:19:35 +00:00
|
|
|
// Regular expression to extract compiler flags from a string
|
2012-11-11 20:07:49 +00:00
|
|
|
// https://gist.github.com/3944250
|
|
|
|
const char* regexString =
|
|
|
|
"(^|[ ])-[DIOUWfgs][^= ]+(=\\\"[^\"]+\\\"|=[^\"][^ ]+)?";
|
|
|
|
flagRegex.compile(regexString);
|
|
|
|
std::string workString = flagsString + " " + definesString;
|
|
|
|
while (flagRegex.find(workString))
|
|
|
|
{
|
|
|
|
std::string::size_type start = flagRegex.start();
|
|
|
|
if (workString[start] == ' ')
|
|
|
|
{
|
|
|
|
start++;
|
|
|
|
}
|
|
|
|
flags.push_back(workString.substr(start,
|
|
|
|
flagRegex.end() - start));
|
|
|
|
if (flagRegex.end() < workString.size())
|
|
|
|
{
|
|
|
|
workString = workString.substr(flagRegex.end());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
workString = "";
|
|
|
|
}
|
|
|
|
}
|
2012-10-10 23:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-13 09:20:09 +00:00
|
|
|
// Ninja uses ninja.build files (look for a way to get the output file name
|
2012-10-14 10:11:32 +00:00
|
|
|
// from cmMakefile or something)
|
|
|
|
std::string makefileName;
|
2014-02-24 22:36:27 +00:00
|
|
|
if (this->GlobalGenerator->GetName() == "Ninja")
|
2012-10-13 09:20:09 +00:00
|
|
|
{
|
2012-10-14 10:11:32 +00:00
|
|
|
makefileName = "build.ninja";
|
2012-10-13 09:20:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-14 10:11:32 +00:00
|
|
|
makefileName = "Makefile";
|
2012-10-13 09:20:09 +00:00
|
|
|
}
|
2012-10-10 22:01:48 +00:00
|
|
|
if (!firstTarget)
|
|
|
|
{
|
|
|
|
fout << ",\n\t";
|
|
|
|
}
|
|
|
|
fout << "\t{\n\t\t\t\"name\": \"" << makefile->GetProjectName() << " - " <<
|
|
|
|
targetName << "\",\n";
|
|
|
|
fout << "\t\t\t\"cmd\": [" <<
|
|
|
|
this->BuildMakeCommand(make, makefileName.c_str(), targetName) <<
|
|
|
|
"],\n";
|
|
|
|
fout << "\t\t\t\"working_dir\": \"${project_path}\",\n";
|
|
|
|
fout << "\t\t\t\"file_regex\": \"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$\"\n";
|
|
|
|
fout << "\t\t}";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the command line for building the given target using the selected
|
|
|
|
// make
|
|
|
|
std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
|
2014-02-06 22:31:47 +00:00
|
|
|
const std::string& make, const char* makefile,
|
|
|
|
const std::string& target)
|
2012-10-10 22:01:48 +00:00
|
|
|
{
|
|
|
|
std::string command = "\"";
|
|
|
|
command += make + "\"";
|
2014-02-24 22:36:27 +00:00
|
|
|
std::string generator = this->GlobalGenerator->GetName();
|
|
|
|
if (generator == "NMake Makefiles")
|
2012-10-10 22:01:48 +00:00
|
|
|
{
|
|
|
|
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
|
|
|
|
command += ", \"/NOLOGO\", \"/f\", \"";
|
|
|
|
command += makefileName + "\"";
|
|
|
|
command += ", \"VERBOSE=1\", \"";
|
|
|
|
command += target;
|
|
|
|
command += "\"";
|
|
|
|
}
|
2014-02-24 22:36:27 +00:00
|
|
|
else if (generator == "Ninja")
|
2012-10-10 22:01:48 +00:00
|
|
|
{
|
2012-10-13 09:20:09 +00:00
|
|
|
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
|
2012-10-10 22:01:48 +00:00
|
|
|
command += ", \"-f\", \"";
|
|
|
|
command += makefileName + "\"";
|
2012-10-13 09:20:09 +00:00
|
|
|
command += ", \"-v\", \"";
|
2012-10-10 22:01:48 +00:00
|
|
|
command += target;
|
|
|
|
command += "\"";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-13 09:20:09 +00:00
|
|
|
std::string makefileName;
|
2014-02-24 22:36:27 +00:00
|
|
|
if (generator == "MinGW Makefiles")
|
2012-10-13 09:20:09 +00:00
|
|
|
{
|
|
|
|
// no escaping of spaces in this case, see
|
|
|
|
// http://public.kitware.com/Bug/view.php?id=10014
|
|
|
|
makefileName = makefile;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
makefileName = cmSystemTools::ConvertToOutputPath(makefile);
|
|
|
|
}
|
2012-10-10 22:01:48 +00:00
|
|
|
command += ", \"-f\", \"";
|
|
|
|
command += makefileName + "\"";
|
|
|
|
command += ", \"VERBOSE=1\", \"";
|
|
|
|
command += target;
|
|
|
|
command += "\"";
|
|
|
|
}
|
|
|
|
return command;
|
|
|
|
}
|
2012-11-11 20:07:49 +00:00
|
|
|
|
|
|
|
// TODO: Most of the code is picked up from the Ninja generator, refactor it.
|
|
|
|
std::string
|
|
|
|
cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
|
|
|
|
cmLocalGenerator* lg,
|
|
|
|
cmTarget *target,
|
|
|
|
cmGeneratorTarget* gtgt)
|
|
|
|
{
|
|
|
|
std::string flags;
|
|
|
|
|
|
|
|
cmMakefile *makefile = lg->GetMakefile();
|
2014-02-04 02:20:56 +00:00
|
|
|
std::string language = source->GetLanguage();
|
|
|
|
if (language.empty())
|
2012-11-11 20:07:49 +00:00
|
|
|
{
|
|
|
|
language = "C";
|
|
|
|
}
|
2014-02-10 03:48:34 +00:00
|
|
|
const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2012-11-11 20:07:49 +00:00
|
|
|
// Add language-specific flags.
|
|
|
|
lg->AddLanguageFlags(flags, language, config);
|
|
|
|
|
|
|
|
lg->AddArchitectureFlags(flags, gtgt, language, config);
|
|
|
|
|
|
|
|
// TODO: Fortran support.
|
|
|
|
// // Fortran-specific flags computed for this target.
|
|
|
|
// if(*l == "Fortran")
|
|
|
|
// {
|
|
|
|
// this->AddFortranFlags(flags);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Add shared-library flags if needed.
|
2013-01-23 22:26:35 +00:00
|
|
|
lg->AddCMP0018Flags(flags, target, language, config);
|
2012-11-11 20:07:49 +00:00
|
|
|
|
|
|
|
// Add include directory flags.
|
|
|
|
{
|
|
|
|
std::vector<std::string> includes;
|
|
|
|
lg->GetIncludeDirectories(includes, gtgt, language, config);
|
|
|
|
std::string includeFlags =
|
2013-07-01 20:28:26 +00:00
|
|
|
lg->GetIncludeFlags(includes, gtgt, language, true); // full include paths
|
2014-05-01 20:07:26 +00:00
|
|
|
lg->AppendFlags(flags, includeFlags);
|
2012-11-11 20:07:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Append old-style preprocessor definition flags.
|
|
|
|
lg->AppendFlags(flags, makefile->GetDefineFlags());
|
|
|
|
|
|
|
|
// Add target-specific flags.
|
2014-02-10 04:20:18 +00:00
|
|
|
lg->AddCompileOptions(flags, target, language, config);
|
2012-11-11 20:07:49 +00:00
|
|
|
|
|
|
|
// Add source file specific flags.
|
2013-05-16 16:58:58 +00:00
|
|
|
lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS"));
|
2012-11-11 20:07:49 +00:00
|
|
|
|
|
|
|
// TODO: Handle Apple frameworks.
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Refactor with
|
|
|
|
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
|
|
|
|
std::string
|
|
|
|
cmExtraSublimeTextGenerator::
|
|
|
|
ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
|
2013-02-11 22:23:02 +00:00
|
|
|
cmGeneratorTarget*)
|
2012-11-11 20:07:49 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
std::set<std::string> defines;
|
|
|
|
cmMakefile *makefile = lg->GetMakefile();
|
2014-02-04 02:20:56 +00:00
|
|
|
const std::string& language = source->GetLanguage();
|
2014-02-10 03:48:34 +00:00
|
|
|
const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2012-11-11 20:07:49 +00:00
|
|
|
|
|
|
|
// Add the export symbol definition for shared library objects.
|
|
|
|
if(const char* exportMacro = target->GetExportMacro())
|
|
|
|
{
|
|
|
|
lg->AppendDefines(defines, exportMacro);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add preprocessor definitions for this target and configuration.
|
2013-06-06 16:13:35 +00:00
|
|
|
lg->AddCompileDefinitions(defines, target, config);
|
2012-11-11 20:07:49 +00:00
|
|
|
lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
|
|
|
|
{
|
|
|
|
std::string defPropName = "COMPILE_DEFINITIONS_";
|
|
|
|
defPropName += cmSystemTools::UpperCase(config);
|
2014-03-10 23:04:11 +00:00
|
|
|
lg->AppendDefines(defines, source->GetProperty(defPropName));
|
2012-11-11 20:07:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string definesString;
|
|
|
|
lg->JoinDefines(defines, definesString, language);
|
|
|
|
|
|
|
|
return definesString;
|
|
|
|
}
|