1
0
Эх сурвалжийг харах

BUG: Fix aus source dir and add better testing of it

Andy Cedilnik 22 жил өмнө
parent
commit
482eef7112

+ 9 - 7
Source/cmSourceFile.cxx

@@ -30,12 +30,8 @@ void cmSourceFile::SetName(const char* name, const char* dir,
 
   this->SetProperty("HEADER_FILE_ONLY","1");
 
-  m_SourceName = cmSystemTools::GetFilenamePath(name);
-  if ( m_SourceName.size() > 0 )
-    {
-    m_SourceName += "/";
-    }
-  m_SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name);
+
+  m_SourceName = name;
 
   std::string pathname = dir;
 
@@ -58,6 +54,12 @@ void cmSourceFile::SetName(const char* name, const char* dir,
   std::string hname = pathname;
   if(cmSystemTools::FileExists(hname.c_str()))
     {
+    m_SourceName = cmSystemTools::GetFilenamePath(name);
+    if ( m_SourceName.size() > 0 )
+      {
+      m_SourceName += "/";
+      }
+    m_SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name);
     std::string::size_type pos = hname.rfind('.');
     if(pos != std::string::npos)
       {
@@ -74,7 +76,7 @@ void cmSourceFile::SetName(const char* name, const char* dir,
 
     // See if the file is a header file
     if(std::find( headerExts.begin(), headerExts.end(), m_SourceExtension ) ==
-       headerExts.end())
+      headerExts.end())
       {
       this->SetProperty("HEADER_FILE_ONLY","0");
       }

+ 6 - 0
Tests/SubDir/AnotherSubdir/pair+int.int.c

@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void pair_stuff()
+{
+  printf("Placeholder for a strange file in subdirectory\n");
+}

+ 4 - 2
Tests/SubDir/AnotherSubdir/secondone.c

@@ -1,4 +1,6 @@
-const char* secondone()
+#include <stdio.h>
+
+void secondone()
 {
-  return "Hello again";
+  printf("Hello again\n");
 }

+ 6 - 2
Tests/SubDir/AnotherSubdir/testfromsubdir.c

@@ -1,10 +1,14 @@
 #include <stdio.h>
 
-const char* secondone();
+void secondone();
+void pair_stuff();
+void vcl_stuff();
 
 int main()
 {
   printf("Hello from subdirectory\n");
-  printf("SO: %s\n", secondone());
+  secondone();
+  pair_stuff();
+  vcl_stuff();
   return 0;
 }

+ 12 - 1
Tests/SubDir/CMakeLists.txt

@@ -2,4 +2,15 @@ PROJECT(SUBDIR)
 SUBDIRS(Executable EXCLUDE_FROM_ALL Examples)
 WRITE_FILE(${SUBDIR_BINARY_DIR}/ShouldBeHere "This file should exist.")
 
-ADD_EXECUTABLE(TestFromSubdir AnotherSubdir/testfromsubdir.c AnotherSubdir/secondone)
+ADD_EXECUTABLE(TestFromSubdir
+  AnotherSubdir/testfromsubdir.c
+  AnotherSubdir/secondone
+  AnotherSubdir/pair+int.int.c
+  vcl_algorithm+vcl_pair+double.foo.c
+  )
+
+AUX_SOURCE_DIRECTORY(ThirdSubDir SOURCES)
+SET(SOURCES ${SOURCES} 
+  vcl_algorithm+vcl_pair+double.foo.c)
+MESSAGE("Sources: ${SOURCES}")
+ADD_EXECUTABLE(TestWithAuxSourceDir ${SOURCES})

+ 6 - 0
Tests/SubDir/ThirdSubDir/pair+int.int1.c

@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void pair_stuff()
+{
+  printf("Placeholder for a strange file in subdirectory\n");
+}

+ 14 - 0
Tests/SubDir/ThirdSubDir/testfromauxsubdir.c

@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+void secondone();
+void pair_stuff();
+void vcl_stuff();
+
+int main()
+{
+  printf("Hello from subdirectory\n");
+  secondone();
+  pair_stuff();
+  vcl_stuff();
+  return 0;
+}

+ 6 - 0
Tests/SubDir/ThirdSubDir/thirdone.c

@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void secondone()
+{
+  printf("Hello again\n");
+}

+ 6 - 0
Tests/SubDir/vcl_algorithm+vcl_pair+double.foo.c

@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void vcl_stuff()
+{
+  printf("Placeholder for a file with strange name\n");
+}