2012-10-11 02:01:48 +04: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"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2013-02-12 02:23:02 +04:00
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmGeneratorTarget.h"
|
2012-10-11 02:01:48 +04:00
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
2013-02-12 02:23:02 +04:00
|
|
|
#include "cmLocalGenerator.h"
|
2012-10-11 02:01:48 +04:00
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSourceFile.h"
|
|
|
|
#include "cmSystemTools.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
2012-10-11 02:01:48 +04:00
|
|
|
|
|
|
|
#include <cmsys/SystemTools.hxx>
|
|
|
|
|
2012-10-13 13:20:09 +04:00
|
|
|
/*
|
|
|
|
Sublime Text 2 Generator
|
|
|
|
Author: Morné Chamberlain
|
|
|
|
This generator was initially based off of the CodeBlocks generator.
|
|
|
|
|
|
|
|
Some useful URLs:
|
2012-10-11 02:01:48 +04: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
|
|
|
|
*/
|
|
|
|
|
2016-07-20 19:28:39 +03:00
|
|
|
cmExternalMakefileProjectGeneratorFactory*
|
|
|
|
cmExtraSublimeTextGenerator::GetFactory()
|
2012-10-11 02:01:48 +04:00
|
|
|
{
|
2016-07-20 19:28:39 +03:00
|
|
|
static cmExternalMakefileProjectGeneratorSimpleFactory<
|
|
|
|
cmExtraSublimeTextGenerator>
|
|
|
|
factory("Sublime Text 2", "Generates Sublime Text 2 project files.");
|
|
|
|
|
|
|
|
if (factory.GetSupportedGlobalGenerators().empty()) {
|
|
|
|
#if defined(_WIN32)
|
|
|
|
factory.AddSupportedGlobalGenerator("MinGW Makefiles");
|
|
|
|
factory.AddSupportedGlobalGenerator("NMake Makefiles");
|
|
|
|
// disable until somebody actually tests it:
|
|
|
|
// factory.AddSupportedGlobalGenerator("MSYS Makefiles");
|
|
|
|
#endif
|
|
|
|
factory.AddSupportedGlobalGenerator("Ninja");
|
|
|
|
factory.AddSupportedGlobalGenerator("Unix Makefiles");
|
|
|
|
}
|
|
|
|
|
|
|
|
return &factory;
|
2012-10-11 02:01:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator()
|
2016-05-16 17:34:04 +03:00
|
|
|
: cmExternalMakefileProjectGenerator()
|
2012-10-11 02:01:48 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmExtraSublimeTextGenerator::Generate()
|
|
|
|
{
|
|
|
|
// for each sub project in the project create a sublime text 2 project
|
2014-02-10 09:21:34 +04:00
|
|
|
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
2016-05-16 17:34:04 +03:00
|
|
|
it = this->GlobalGenerator->GetProjectMap().begin();
|
|
|
|
it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
|
2012-10-11 02:01:48 +04:00
|
|
|
// create a project file
|
|
|
|
this->CreateProjectFile(it->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:01:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmExtraSublimeTextGenerator::CreateProjectFile(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::vector<cmLocalGenerator*>& lgs)
|
2012-10-11 02:01:48 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string outputDir = lgs[0]->GetCurrentBinaryDirectory();
|
|
|
|
std::string projectName = lgs[0]->GetProjectName();
|
2012-10-11 02:01:48 +04:00
|
|
|
|
2013-02-06 22:31:44 +04:00
|
|
|
const std::string filename =
|
2016-05-16 17:34:04 +03:00
|
|
|
outputDir + "/" + projectName + ".sublime-project";
|
2012-10-11 02:01:48 +04:00
|
|
|
|
|
|
|
this->CreateNewProjectFile(lgs, filename);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmExtraSublimeTextGenerator::CreateNewProjectFile(
|
|
|
|
const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
|
2012-10-11 02:01:48 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const cmMakefile* mf = lgs[0]->GetMakefile();
|
2012-10-11 02:01:48 +04:00
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fout) {
|
2012-10-11 02:01:48 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:01:48 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& sourceRootRelativeToOutput = cmSystemTools::RelativePath(
|
|
|
|
lgs[0]->GetBinaryDirectory(), lgs[0]->GetSourceDirectory());
|
2012-10-14 12:46:29 +04:00
|
|
|
// Write the folder entries to the project file
|
2012-10-12 00:53:40 +04:00
|
|
|
fout << "{\n";
|
|
|
|
fout << "\t\"folders\":\n\t[\n\t";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!sourceRootRelativeToOutput.empty()) {
|
|
|
|
fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\"";
|
|
|
|
const std::string& outputRelativeToSourceRoot =
|
|
|
|
cmSystemTools::RelativePath(lgs[0]->GetSourceDirectory(),
|
|
|
|
lgs[0]->GetBinaryDirectory());
|
|
|
|
if ((!outputRelativeToSourceRoot.empty()) &&
|
2012-10-19 00:54:19 +04:00
|
|
|
((outputRelativeToSourceRoot.length() < 3) ||
|
2016-05-16 17:34:04 +03:00
|
|
|
(outputRelativeToSourceRoot.substr(0, 3) != "../"))) {
|
|
|
|
fout << ",\n\t\t\t\"folder_exclude_patterns\": [\""
|
|
|
|
<< outputRelativeToSourceRoot << "\"]";
|
2012-10-14 19:37:51 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
fout << "\t{\n\t\t\t\"path\": \"./\"";
|
|
|
|
}
|
2012-10-14 19:37:51 +04:00
|
|
|
fout << "\n\t\t}";
|
2012-10-12 00:53:40 +04:00
|
|
|
// End of the folders section
|
2012-10-14 19:37:51 +04:00
|
|
|
fout << "\n\t]";
|
2012-10-12 00:53:40 +04: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-12 00:07:49 +04:00
|
|
|
MapSourceFileFlags sourceFileFlags;
|
|
|
|
AppendAllTargets(lgs, mf, fout, sourceFileFlags);
|
2013-02-06 22:31:44 +04:00
|
|
|
|
2012-10-12 00:53:40 +04:00
|
|
|
// End of build_systems
|
|
|
|
fout << "\n\t]";
|
2013-02-06 22:31:44 +04:00
|
|
|
fout << "\n\t}";
|
2012-11-24 22:19:35 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmExtraSublimeTextGenerator::AppendAllTargets(
|
|
|
|
const std::vector<cmLocalGenerator*>& lgs, const cmMakefile* mf,
|
|
|
|
cmGeneratedFileStream& fout, MapSourceFileFlags& sourceFileFlags)
|
2012-10-12 00:53:40 +04:00
|
|
|
{
|
2012-10-11 02:01:48 +04:00
|
|
|
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
std::string compiler = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!lgs.empty()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
this->AppendTarget(fout, "all", lgs[0], CM_NULLPTR, make.c_str(), mf,
|
2016-05-16 17:34:04 +03:00
|
|
|
compiler.c_str(), sourceFileFlags, true);
|
2016-06-27 23:44:16 +03:00
|
|
|
this->AppendTarget(fout, "clean", lgs[0], CM_NULLPTR, make.c_str(), mf,
|
2016-05-16 17:34:04 +03:00
|
|
|
compiler.c_str(), sourceFileFlags, false);
|
|
|
|
}
|
2012-10-11 02:01:48 +04:00
|
|
|
|
|
|
|
// add all executable and library targets and some of the GLOBAL
|
|
|
|
// and UTILITY targets
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
|
|
|
|
lg != lgs.end(); lg++) {
|
|
|
|
cmMakefile* makefile = (*lg)->GetMakefile();
|
|
|
|
std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
|
2015-10-18 18:06:14 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
ti != targets.end(); ti++) {
|
2015-10-18 18:06:14 +03:00
|
|
|
std::string targetName = (*ti)->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
switch ((*ti)->GetType()) {
|
|
|
|
case cmState::GLOBAL_TARGET: {
|
2012-10-11 02:01:48 +04:00
|
|
|
// Only add the global targets from CMAKE_BINARY_DIR,
|
|
|
|
// not from the subdirs
|
2015-10-07 02:17:48 +03:00
|
|
|
if (strcmp((*lg)->GetCurrentBinaryDirectory(),
|
2016-05-16 17:34:04 +03:00
|
|
|
(*lg)->GetBinaryDirectory()) == 0) {
|
2016-06-27 23:44:16 +03:00
|
|
|
this->AppendTarget(fout, targetName, *lg, CM_NULLPTR, make.c_str(),
|
2016-05-16 17:34:04 +03:00
|
|
|
makefile, compiler.c_str(), sourceFileFlags,
|
|
|
|
false);
|
2012-10-11 02:01:48 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::UTILITY:
|
2012-10-11 02:01:48 +04:00
|
|
|
// Add all utility targets, except the Nightly/Continuous/
|
|
|
|
// Experimental-"sub"targets as e.g. NightlyStart
|
2016-05-16 17:34:04 +03:00
|
|
|
if (((targetName.find("Nightly") == 0) &&
|
|
|
|
(targetName != "Nightly")) ||
|
|
|
|
((targetName.find("Continuous") == 0) &&
|
|
|
|
(targetName != "Continuous")) ||
|
|
|
|
((targetName.find("Experimental") == 0) &&
|
|
|
|
(targetName != "Experimental"))) {
|
2012-10-11 02:01:48 +04:00
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:01:48 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
this->AppendTarget(fout, targetName, *lg, CM_NULLPTR, make.c_str(),
|
|
|
|
makefile, compiler.c_str(), sourceFileFlags,
|
|
|
|
false);
|
2012-10-11 02:01:48 +04:00
|
|
|
break;
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::EXECUTABLE:
|
|
|
|
case cmState::STATIC_LIBRARY:
|
|
|
|
case cmState::SHARED_LIBRARY:
|
|
|
|
case cmState::MODULE_LIBRARY:
|
2016-05-16 17:34:04 +03:00
|
|
|
case cmState::OBJECT_LIBRARY: {
|
|
|
|
this->AppendTarget(fout, targetName, *lg, *ti, make.c_str(),
|
|
|
|
makefile, compiler.c_str(), sourceFileFlags,
|
|
|
|
false);
|
2015-10-18 18:06:14 +03:00
|
|
|
std::string fastTarget = targetName;
|
2012-10-11 02:01:48 +04:00
|
|
|
fastTarget += "/fast";
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AppendTarget(fout, fastTarget, *lg, *ti, make.c_str(),
|
|
|
|
makefile, compiler.c_str(), sourceFileFlags,
|
|
|
|
false);
|
|
|
|
} break;
|
2012-10-11 02:01:48 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:01:48 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmExtraSublimeTextGenerator::AppendTarget(
|
|
|
|
cmGeneratedFileStream& fout, const std::string& targetName,
|
|
|
|
cmLocalGenerator* lg, cmGeneratorTarget* target, const char* make,
|
|
|
|
const cmMakefile* makefile,
|
|
|
|
const char*, // compiler
|
|
|
|
MapSourceFileFlags& sourceFileFlags, bool firstTarget)
|
2012-10-11 02:01:48 +04:00
|
|
|
{
|
2013-02-12 02:23:02 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
if (target != CM_NULLPTR) {
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmSourceFile*> sourceFiles;
|
|
|
|
target->GetSourceFiles(sourceFiles,
|
|
|
|
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
|
|
|
std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
|
|
|
|
sourceFiles.end();
|
|
|
|
for (std::vector<cmSourceFile*>::const_iterator iter = sourceFiles.begin();
|
|
|
|
iter != sourceFilesEnd; ++iter) {
|
|
|
|
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);
|
|
|
|
std::string definesString = this->ComputeDefines(*iter, lg, target);
|
|
|
|
flags.clear();
|
|
|
|
cmsys::RegularExpression flagRegex;
|
|
|
|
// Regular expression to extract compiler flags from a string
|
|
|
|
// 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++;
|
2012-10-11 03:01:13 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
flags.push_back(workString.substr(start, flagRegex.end() - start));
|
|
|
|
if (flagRegex.end() < workString.size()) {
|
|
|
|
workString = workString.substr(flagRegex.end());
|
|
|
|
} else {
|
|
|
|
workString = "";
|
|
|
|
}
|
|
|
|
}
|
2012-10-11 03:01:13 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 03:01:13 +04:00
|
|
|
|
2012-10-13 13:20:09 +04:00
|
|
|
// Ninja uses ninja.build files (look for a way to get the output file name
|
2012-10-14 14:11:32 +04:00
|
|
|
// from cmMakefile or something)
|
|
|
|
std::string makefileName;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GlobalGenerator->GetName() == "Ninja") {
|
|
|
|
makefileName = "build.ninja";
|
|
|
|
} else {
|
|
|
|
makefileName = "Makefile";
|
|
|
|
}
|
|
|
|
if (!firstTarget) {
|
2012-10-11 02:01:48 +04:00
|
|
|
fout << ",\n\t";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
fout << "\t{\n\t\t\t\"name\": \"" << lg->GetProjectName() << " - "
|
|
|
|
<< targetName << "\",\n";
|
|
|
|
fout << "\t\t\t\"cmd\": ["
|
|
|
|
<< this->BuildMakeCommand(make, makefileName.c_str(), targetName)
|
|
|
|
<< "],\n";
|
2012-10-11 02:01:48 +04:00
|
|
|
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(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& make, const char* makefile, const std::string& target)
|
2012-10-11 02:01:48 +04:00
|
|
|
{
|
|
|
|
std::string command = "\"";
|
|
|
|
command += make + "\"";
|
2014-02-25 02:36:27 +04:00
|
|
|
std::string generator = this->GlobalGenerator->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (generator == "NMake Makefiles") {
|
2012-10-11 02:01:48 +04:00
|
|
|
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
|
|
|
|
command += ", \"/NOLOGO\", \"/f\", \"";
|
|
|
|
command += makefileName + "\"";
|
|
|
|
command += ", \"VERBOSE=1\", \"";
|
|
|
|
command += target;
|
|
|
|
command += "\"";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (generator == "Ninja") {
|
2012-10-13 13:20:09 +04:00
|
|
|
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
|
2012-10-11 02:01:48 +04:00
|
|
|
command += ", \"-f\", \"";
|
|
|
|
command += makefileName + "\"";
|
2012-10-13 13:20:09 +04:00
|
|
|
command += ", \"-v\", \"";
|
2012-10-11 02:01:48 +04:00
|
|
|
command += target;
|
|
|
|
command += "\"";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-10-13 13:20:09 +04:00
|
|
|
std::string makefileName;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (generator == "MinGW Makefiles") {
|
|
|
|
// 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-11 02:01:48 +04:00
|
|
|
command += ", \"-f\", \"";
|
|
|
|
command += makefileName + "\"";
|
|
|
|
command += ", \"VERBOSE=1\", \"";
|
|
|
|
command += target;
|
|
|
|
command += "\"";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:01:48 +04:00
|
|
|
return command;
|
|
|
|
}
|
2012-11-12 00:07:49 +04:00
|
|
|
|
|
|
|
// TODO: Most of the code is picked up from the Ninja generator, refactor it.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
|
|
|
|
cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* gtgt)
|
2012-11-12 00:07:49 +04:00
|
|
|
{
|
|
|
|
std::string flags;
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string language = source->GetLanguage();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (language.empty()) {
|
|
|
|
language = "C";
|
|
|
|
}
|
2016-06-10 19:09:13 +03:00
|
|
|
std::string const& config =
|
|
|
|
lg->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2012-11-12 00:07:49 +04:00
|
|
|
|
2016-06-10 19:09:13 +03:00
|
|
|
lg->GetTargetCompileFlags(gtgt, config, language, flags);
|
2012-11-12 00:07:49 +04:00
|
|
|
|
|
|
|
// Add include directory flags.
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string> includes;
|
|
|
|
lg->GetIncludeDirectories(includes, gtgt, language, config);
|
|
|
|
std::string includeFlags = lg->GetIncludeFlags(includes, gtgt, language,
|
|
|
|
true); // full include paths
|
|
|
|
lg->AppendFlags(flags, includeFlags);
|
2012-11-12 00:07:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add source file specific flags.
|
2013-05-16 20:58:58 +04:00
|
|
|
lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS"));
|
2012-11-12 00:07:49 +04:00
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Refactor with
|
|
|
|
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmExtraSublimeTextGenerator::ComputeDefines(
|
|
|
|
cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* target)
|
2012-11-12 00:07:49 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
std::set<std::string> defines;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakefile* makefile = lg->GetMakefile();
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& language = source->GetLanguage();
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2012-11-12 00:07:49 +04:00
|
|
|
|
|
|
|
// Add the export symbol definition for shared library objects.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* exportMacro = target->GetExportMacro()) {
|
2012-11-12 00:07:49 +04:00
|
|
|
lg->AppendDefines(defines, exportMacro);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-12 00:07:49 +04:00
|
|
|
|
|
|
|
// Add preprocessor definitions for this target and configuration.
|
2015-10-09 23:19:57 +03:00
|
|
|
lg->AddCompileDefinitions(defines, target, config, language);
|
2012-11-12 00:07:49 +04:00
|
|
|
lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string defPropName = "COMPILE_DEFINITIONS_";
|
|
|
|
defPropName += cmSystemTools::UpperCase(config);
|
|
|
|
lg->AppendDefines(defines, source->GetProperty(defPropName));
|
2012-11-12 00:07:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string definesString;
|
|
|
|
lg->JoinDefines(defines, definesString, language);
|
|
|
|
|
|
|
|
return definesString;
|
|
|
|
}
|