Parcourir la source

ENH: enable test for java with IDE builds

Bill Hoffman il y a 19 ans
Parent
commit
ed4974da55
2 fichiers modifiés avec 43 ajouts et 4 suppressions
  1. 4 2
      Source/CMakeLists.txt
  2. 39 2
      Source/cmLocalGenerator.cxx

+ 4 - 2
Source/CMakeLists.txt

@@ -1014,6 +1014,8 @@ IF(BUILD_TESTING)
       --test-command ${CMake_BINARY_DIR}/Tests/BootstrapTest/Bootstrap.cmk/cmake)
   ENDIF(UNIX AND CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST)
 
+  # fortran does not work for IDE builds because 
+  # CMAKE_STANDARD_LIBRARIES needs to be per language
   IF(CMAKE_TEST_GENERATOR MATCHES "Makefiles")
     # see if we can find a fortran compiler on the machine
     # if so, add the fortran test and see if it works.
@@ -1033,7 +1035,7 @@ IF(BUILD_TESTING)
         --build-two-config
         --test-command testf)
     ENDIF(CMAKE_Fortran_COMPILER_FULLPATH)
-
+  ENDIF(CMAKE_TEST_GENERATOR MATCHES "Makefiles")
     INCLUDE(FindJava)
     IF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW)
       GET_FILENAME_COMPONENT(JNIPATH ${JAVA_COMPILE} PATH)
@@ -1056,7 +1058,7 @@ IF(BUILD_TESTING)
         ENDIF("${JNI_FILE}" MATCHES "JDK1_2")
       ENDIF(JNI_H) 
     ENDIF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW)
-  ENDIF(CMAKE_TEST_GENERATOR MATCHES "Makefiles")
+
     
   IF (CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE OR WXWINDOWS_INCLUDE_DIR)
     # Will be set if the wxwindows gui is on

+ 39 - 2
Source/cmLocalGenerator.cxx

@@ -565,7 +565,6 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
   std::string flags; // should be set
   std::string linkFlags; // should be set 
   this->GetTargetFlags(linkLibs, flags, linkFlags, target);
-  std::string rule = this->Makefile->GetRequiredDefinition(createRule.c_str());
   cmLocalGenerator::RuleVariables vars;
   vars.Language = llang;
   vars.Objects = objs.c_str();
@@ -573,7 +572,45 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
   vars.LinkLibraries = linkLibs.c_str();
   vars.Flags = flags.c_str();
   vars.LinkFlags = linkFlags.c_str();
-  this->ExpandRuleVariables(rule, vars);
+
+  cmCustomCommandLines commandLines;
+  std::vector<std::string> rules;
+  rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str()));
+  std::vector<std::string> commands;
+  cmSystemTools::ExpandList(rules, commands);  
+  for(std::vector<std::string>::iterator i = commands.begin();
+      i != commands.end(); ++i)
+    {
+    // Expand the full command line string.
+    this->ExpandRuleVariables(*i, vars);
+
+    // Parse the string to get the custom command line.
+    cmCustomCommandLine commandLine;
+    std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
+    for(std::vector<cmStdString>::iterator a = cmd.begin();
+        a != cmd.end(); ++a)
+      {
+      commandLine.push_back(*a);
+      }
+
+    // Store this command line.
+    commandLines.push_back(commandLine);
+    }
+  std::string targetFullPath = target.GetFullPath();
+  // Generate a meaningful comment for the command.
+  std::string comment = "Linking ";
+  comment += llang;
+  comment += " target ";
+  comment += this->Convert(targetFullPath.c_str(), START_OUTPUT);
+  this->Makefile->AddCustomCommandToOutput(
+    targetFullPath.c_str(),
+    objVector,
+    0,
+    commandLines,
+    comment.c_str(),
+    this->Makefile->GetStartOutputDirectory()
+    );
+  target.GetSourceFiles().push_back(this->Makefile->GetSource(targetFullPath.c_str()));
 }