Browse Source

make compile command output optional

Manuel Klimek 15 years ago
parent
commit
5674844de4

+ 3 - 0
Modules/CMakeGenericSystem.cmake

@@ -50,6 +50,9 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles")
   IF(DEFINED CMAKE_RULE_MESSAGES)
     SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES ${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")
 
 

+ 1 - 1
Source/cmGlobalUnixMakefileGenerator3.cxx

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

+ 2 - 1
Source/cmMakefileTargetGenerator.cxx

@@ -671,7 +671,8 @@ cmMakefileTargetGenerator
   std::vector<std::string> 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];
     this->LocalGenerator->ExpandRuleVariables(compileCommand, vars);