make compile command output optional

This commit is contained in:
Manuel Klimek 2011-01-14 15:16:11 -08:00 committed by Brad King
parent fe07b0557b
commit 5674844de4
3 changed files with 6 additions and 2 deletions

View File

@ -50,6 +50,9 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles")
IF(DEFINED CMAKE_RULE_MESSAGES) IF(DEFINED CMAKE_RULE_MESSAGES)
SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES}) SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES})
ENDIF(DEFINED CMAKE_RULE_MESSAGES) ENDIF(DEFINED CMAKE_RULE_MESSAGES)
SET(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL
"Enable/Disable output of compile commands during generation."
)
ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") ENDIF(CMAKE_GENERATOR MATCHES "Makefiles")

View File

@ -216,7 +216,7 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
{ {
std::string commandDatabaseName = std::string commandDatabaseName =
std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) std::string(this->GetCMakeInstance()->GetHomeOutputDirectory())
+ "/cxx_commands.json"; + "/compile_commands.json";
this->CommandDatabase = this->CommandDatabase =
new cmGeneratedFileStream(commandDatabaseName.c_str()); new cmGeneratedFileStream(commandDatabaseName.c_str());
*this->CommandDatabase << "[" << std::endl; *this->CommandDatabase << "[" << std::endl;

View File

@ -671,7 +671,8 @@ cmMakefileTargetGenerator
std::vector<std::string> compileCommands; std::vector<std::string> compileCommands;
cmSystemTools::ExpandListArgument(compileRule, compileCommands); cmSystemTools::ExpandListArgument(compileRule, compileCommands);
if (lang_is_c_or_cxx && compileCommands.size() == 1) if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
lang_is_c_or_cxx && compileCommands.size() == 1)
{ {
std::string compileCommand = compileCommands[0]; std::string compileCommand = compileCommands[0];
this->LocalGenerator->ExpandRuleVariables(compileCommand, vars); this->LocalGenerator->ExpandRuleVariables(compileCommand, vars);