This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  ff31bfedbf86e48fae4533080de1ff969ea51d20 (commit)
       via  d207f1bf8fd697ae6521a1336dd27222168f548e (commit)
      from  8c3c22b94e9e01e787d0db17ae67a18d63c6ff27 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff31bfedbf86e48fae4533080de1ff969ea51d20
commit ff31bfedbf86e48fae4533080de1ff969ea51d20
Merge: 8c3c22b d207f1b
Author:     Peter Kuemmel <syntheti...@gmx.net>
AuthorDate: Tue Nov 26 12:26:26 2013 -0500
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Tue Nov 26 12:26:26 2013 -0500

    Merge topic 'experimental-pch-properties' into next
    
    d207f1b add source file properties EXTERNAL_SOURCE and OBJECT_LOCATION


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d207f1bf8fd697ae6521a1336dd27222168f548e
commit d207f1bf8fd697ae6521a1336dd27222168f548e
Author:     Peter Kümmel <syntheti...@gmx.net>
AuthorDate: Tue Nov 26 17:44:21 2013 +0100
Commit:     Peter Kümmel <syntheti...@gmx.net>
CommitDate: Tue Nov 26 18:06:02 2013 +0100

    add source file properties EXTERNAL_SOURCE and OBJECT_LOCATION
    
    With these two properties it is much easier to support
    precompiled headers. See test SourceFileProperties.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index d26d6e9..563caa3 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3074,6 +3074,21 @@ cmLocalGenerator
                                  std::string const& dir_max,
                                  bool* hasSourceExtension)
 {
+  // A specified OBJECT_LOCATION overwrites the generated file name
+  if (const char* location = source.GetProperty("OBJECT_LOCATION"))
+    {
+    std::string fullPath;
+    if (cmSystemTools::FileIsFullPath(location))
+      {
+      fullPath = location;
+      }
+    else
+      {
+      fullPath = this->Convert(location, FULL);
+      }
+    return this->Convert(fullPath.c_str(), HOME_OUTPUT);
+    }
+
   // Construct the object file name using the full path to the source
   // file which is its only unique identification.
   const char* fullPath = source.GetFullPath().c_str();
diff --git a/Source/cmMakefileTargetGenerator.cxx 
b/Source/cmMakefileTargetGenerator.cxx
index 2063a24..8c4ef91 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -181,7 +181,14 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
         si = this->GeneratorTarget->ExternalObjects.begin();
       si != this->GeneratorTarget->ExternalObjects.end(); ++si)
     {
-    this->ExternalObjects.push_back((*si)->GetFullPath());
+    if (const char* path = (*si)->GetProperty("OBJECT_LOCATION"))
+      {
+      this->Objects.push_back(path);
+      }
+    else
+      {
+      this->ExternalObjects.push_back((*si)->GetFullPath());
+      }
     }
   for(std::vector<cmSourceFile*>::const_iterator
         si = this->GeneratorTarget->ObjectSources.begin();
@@ -422,10 +429,19 @@ void 
cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
     }
 
   // Get the full path name of the object file.
-  std::string const& objectName = this->GeneratorTarget->Objects[&source];
-  std::string obj = this->LocalGenerator->GetTargetDirectory(*this->Target);
-  obj += "/";
-  obj += objectName;
+  std::string obj;
+  if (source.GetProperty("OBJECT_LOCATION"))
+    {
+    // path is already absolute or HOME_OUTPUT relative
+    obj = this->GeneratorTarget->Objects[&source];
+    }
+  else
+    {
+    std::string const& objectName = this->GeneratorTarget->Objects[&source];
+    obj = this->LocalGenerator->GetTargetDirectory(*this->Target);
+    obj += "/";
+    obj += objectName;
+    }
 
   // Avoid generating duplicate rules.
   if(this->ObjectFiles.find(obj) == this->ObjectFiles.end())
@@ -451,7 +467,10 @@ void 
cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
     (this->LocalGenerator->ConvertToFullPath(dir).c_str());
 
   // Save this in the target's list of object files.
-  this->Objects.push_back(obj);
+  if (!source.GetPropertyAsBool("EXTERNAL_SOURCE"))
+    {
+    this->Objects.push_back(obj);
+    }
   this->CleanFiles.push_back(obj);
 
   // TODO: Remove
@@ -733,6 +752,27 @@ cmMakefileTargetGenerator
       }
     }
 
+  if(const char* object_location_str =
+     source.GetProperty("OBJECT_LOCATION"))
+    {
+    if (relativeObj != object_location_str)
+      {
+      std::vector<std::string> extra_outputs;
+      cmSystemTools::ExpandListArgument(object_location_str, extra_outputs);
+      for(std::vector<std::string>::const_iterator eoi = extra_outputs.begin();
+          eoi != extra_outputs.end(); ++eoi)
+        {
+        // Register this as an extra output for the object file rule.
+        // This will cause the object file to be rebuilt if the extra
+        // output is missing.
+        this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false);
+
+        // Register this as an extra file to clean.
+        this->CleanFiles.push_back(eoi->c_str());
+        }
+      }
+    }
+
   bool do_preprocess_rules = lang_is_c_or_cxx &&
     this->LocalGenerator->GetCreatePreprocessedSourceRules();
   bool do_assembly_rules = lang_is_c_or_cxx &&
diff --git a/Source/cmNinjaTargetGenerator.cxx 
b/Source/cmNinjaTargetGenerator.cxx
index e3c058f..5fc79cb 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -273,6 +273,12 @@ std::string
 cmNinjaTargetGenerator
 ::GetObjectFilePath(cmSourceFile* source) const
 {
+  if (source->GetProperty("OBJECT_LOCATION"))
+    {
+    // path is already absolute or HOME_OUTPUT relative
+    return this->GeneratorTarget->Objects[source];
+    }
+
   std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
   if(!path.empty())
     path += "/";
@@ -475,7 +481,14 @@ cmNinjaTargetGenerator
         si = this->GeneratorTarget->ExternalObjects.begin();
       si != this->GeneratorTarget->ExternalObjects.end(); ++si)
     {
-    this->Objects.push_back(this->GetSourceFilePath(*si));
+    if (const char* path = (*si)->GetProperty("OBJECT_LOCATION"))
+      {
+      this->Objects.push_back(this->ConvertToNinjaPath(path));
+      }
+    else
+      {
+      this->Objects.push_back(this->GetSourceFilePath(*si));
+      }
     }
   for(std::vector<cmSourceFile*>::const_iterator
         si = this->GeneratorTarget->ObjectSources.begin();
@@ -514,8 +527,10 @@ cmNinjaTargetGenerator
   cmNinjaDeps outputs;
   std::string objectFileName = this->GetObjectFilePath(source);
   outputs.push_back(objectFileName);
+
   // Add this object to the list of object files.
-  this->Objects.push_back(objectFileName);
+  if (!source->GetPropertyAsBool("EXTERNAL_SOURCE"))
+    this->Objects.push_back(objectFileName);
 
   cmNinjaDeps explicitDeps;
   std::string sourceFileName;
@@ -642,6 +657,23 @@ cmNinjaTargetGenerator
                                                 outputList,
                                                 outputs);
   }
+
+  if(const char* objectLocationStr = source->GetProperty("OBJECT_LOCATION")) {
+    std::string objectLocation =
+            this->GetLocalGenerator()
+                  ->Convert(objectLocationStr, cmLocalGenerator::HOME_OUTPUT);
+    if (std::find(outputs.begin(), outputs.end(), objectLocation)
+            == outputs.end()) {
+      std::vector<std::string> outputList;
+      cmSystemTools::ExpandListArgument(objectLocation, outputList);
+      std::transform(outputList.begin(), outputList.end(), outputList.begin(),
+                     MapToNinjaPath());
+      this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
+                                                  "Location output file.",
+                                                  outputList,
+                                                  outputs);
+    }
+  }
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index ec98c2c..a851e2a 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -392,3 +392,22 @@ void cmSourceFile::SetCustomCommand(cmCustomCommand* cc)
   this->CustomCommand = cc;
   delete old;
 }
+
+
+
+/*
+  //TODO
+
+  cm->DefineProperty
+    ("EXTERNAL_SOURCE", cmProperty::SOURCE_FILE,
+     "If set to true then this is a source file.",
+     "If this property is set to true then file is a source file"
+     "and will be compiled but it will not be linked into the target");
+
+
+  cm->DefineProperty
+    ("OBJECT_LOCATION", cmProperty::SOURCE_FILE,
+     "Path to output file name.",
+     "The output will be created at the given path."
+     "A relative path is interpreted as relative to CMAKE_BINARY_DIR.");
+*/
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index f7a320a..e6294e7 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -249,6 +249,7 @@ if(BUILD_TESTING)
   ADD_TEST_MACRO(SetLang SetLang)
   ADD_TEST_MACRO(EmptyProperty EmptyProperty)
   ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
+  ADD_TEST_MACRO(SourceFileProperties SourceFileProperties)
   ADD_TEST_MACRO(LoadCommand LoadedCommand)
   ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
   ADD_TEST_MACRO(LinkLanguage LinkLanguage)
diff --git a/Tests/SourceFileProperties/CMakeLists.txt 
b/Tests/SourceFileProperties/CMakeLists.txt
new file mode 100644
index 0000000..553ac66
--- /dev/null
+++ b/Tests/SourceFileProperties/CMakeLists.txt
@@ -0,0 +1,80 @@
+cmake_minimum_required (VERSION 2.8)
+
+project (SourceFileProperties)
+
+
+
+# linking with external would fail because of two main() definitions
+set(src ${CMAKE_CURRENT_BINARY_DIR}/src)
+file(WRITE ${src}1.cpp "int main() { return 0; }\n")
+file(WRITE ${src}2.cpp "int main() { return 0; }\n")
+
+set_source_files_properties(${src}2.cpp PROPERTIES EXTERNAL_SOURCE TRUE)
+
+add_executable(SourceFileProperties ${src}1.cpp ${src}2.cpp)
+
+
+
+# build with manual set object file name
+file(WRITE ${src}3.cpp "int main() { return 0; }\n")
+set(obj ${CMAKE_CURRENT_BINARY_DIR}/object_location${CMAKE_C_OUTPUT_EXTENSION})
+
+set_source_files_properties(${src}3.cpp PROPERTIES OBJECT_LOCATION ${obj})
+
+add_executable(SourceFileProperties2 ${src}3.cpp)
+
+
+
+# ensure the defined object filenname was used
+set_source_files_properties(external_object PROPERTIES
+    EXTERNAL_OBJECT TRUE
+    GENERATED TRUE
+    OBJECT_LOCATION ${obj}
+    LANGUAGE CXX)
+
+add_executable(SourceFileProperties3 external_object)
+
+
+
+
+###########################################
+# Precompiled header like tests
+
+set(all_headers ${CMAKE_CURRENT_BINARY_DIR}/all_headers.h)
+set(gch ${all_headers}.gch)
+
+file(WRITE ${all_headers} "#include <string>\n")
+file(WRITE ${src}4.cpp "std::string foo() { return std::string(); }\n")
+
+
+if(NOT MSVC)
+
+    set_source_files_properties(${all_headers} PROPERTIES
+        HEADER_FILE_ONLY FALSE
+        LANGUAGE CXX
+        EXTERNAL_SOURCE TRUE
+        OBJECT_LOCATION ${gch})
+
+    set_source_files_properties(${src}4.cpp PROPERTIES
+        COMPILE_FLAGS "-Winvalid-pch -include ${all_headers}"
+        OBJECT_DEPENDS ${gch})
+
+    set(pch_support ${all_headers})
+
+else()
+
+    file(WRITE ${all_headers}.cpp "#include \"${all_headers}\"\n")
+
+    set_source_files_properties(${all_headers}.cpp PROPERTIES
+        COMPILE_FLAGS "/Yc\"${all_headers}\" /Fp${gch}"
+        OBJECT_OUTPUTS ${gch})
+
+     set_source_files_properties(${src}4.cpp PROPERTIES
+        COMPILE_FLAGS "/FI${all_headers} /Yu${all_headers} /Fp${gch}"
+        OBJECT_DEPENDS ${gch})
+
+     set(pch_support ${all_headers}.cpp)
+
+endif()
+
+add_library(test_with_pch ${src}4.cpp ${pch_support})

-----------------------------------------------------------------------

Summary of changes:
 Source/cmLocalGenerator.cxx               |   15 +++++
 Source/cmMakefileTargetGenerator.cxx      |   52 ++++++++++++++++--
 Source/cmNinjaTargetGenerator.cxx         |   36 ++++++++++++-
 Source/cmSourceFile.cxx                   |   19 +++++++
 Tests/CMakeLists.txt                      |    1 +
 Tests/SourceFileProperties/CMakeLists.txt |   80 +++++++++++++++++++++++++++++
 6 files changed, 195 insertions(+), 8 deletions(-)
 create mode 100644 Tests/SourceFileProperties/CMakeLists.txt


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-commits

Reply via email to