瀏覽代碼

ENH: Properly propagate config type to test

Andy Cedilnik 19 年之前
父節點
當前提交
3206db15b3
共有 3 個文件被更改,包括 16 次插入10 次删除
  1. 12 9
      Source/cmCTest.cxx
  2. 3 0
      Source/cmCTest.h
  3. 1 1
      Tests/CTestTest2/test.cmake.in

+ 12 - 9
Source/cmCTest.cxx

@@ -1546,14 +1546,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
      i < args.size() - 1)
     {
     i++;
-    this->ConfigType = args[i];
-    cmSystemTools::ReplaceString(this->ConfigType, ".\\", "");
-    if ( !this->ConfigType.empty() )
-      {
-      std::string confTypeEnv
-        = "CMAKE_CONFIG_TYPE=" + this->ConfigType;
-      cmSystemTools::PutEnv(confTypeEnv.c_str());
-      }
+    this->SetConfigType(args[i].c_str());
     }
   
   if(this->CheckArgument(arg, "--debug"))
@@ -1848,7 +1841,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
 #ifdef  CMAKE_INTDIR
   if(this->ConfigType.size() == 0)
     {
-    this->ConfigType = CMAKE_INTDIR;
+    this->SetConfigType(CMAKE_INTDIR);
     }
 #endif
 
@@ -2292,6 +2285,16 @@ void cmCTest::AddCTestConfigurationOverwrite(const char* encstr)
   this->CTestConfigurationOverwrites[key] = value;
 }
 
+//----------------------------------------------------------------------
+void cmCTest::SetConfigType(const char* ct)
+{
+  this->ConfigType = ct?ct:"";
+  cmSystemTools::ReplaceString(this->ConfigType, ".\\", "");
+  std::string confTypeEnv
+    = "CMAKE_CONFIG_TYPE=" + this->ConfigType;
+  cmSystemTools::PutEnv(confTypeEnv.c_str());
+}
+
 //----------------------------------------------------------------------
 bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
   const char* dconfig, const char* cmake_var)

+ 3 - 0
Source/cmCTest.h

@@ -269,6 +269,9 @@ public:
   //! Set the output log file name
   void SetOutputLogFileName(const char* name);
 
+  //! Set the visual studio or Xcode config type
+  void SetConfigType(const char* ct);
+
   //! Various log types
   enum {
     DEBUG = 0,

+ 1 - 1
Tests/CTestTest2/test.cmake.in

@@ -9,7 +9,7 @@ SET(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Source/kwsys")
 SET(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTest2/kwsysBin")
 SET(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
 SET(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
-SET(CTEST_BUILD_CONFIGURATION           "Release")
+SET(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 SET(CTEST_MEMORYCHECK_COMMAND           "@MEMORYCHECK_COMMAND@")
 SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@")
 SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS   "@MEMORYCHECK_COMMAND_OPTIONS@")