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  ed359fefbc80b68c3cdf91daa082cd74997f20e6 (commit)
       via  07fc7b75ef981300e7d873091ee90083b18d1c4a (commit)
       via  fdbfcfdf0173c34845e495f4c0bd407faafc45b4 (commit)
      from  f37cc80bffc7f2fabe0ffb0c290cd19384a88b7f (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=ed359fefbc80b68c3cdf91daa082cd74997f20e6
commit ed359fefbc80b68c3cdf91daa082cd74997f20e6
Merge: f37cc80 07fc7b7
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Tue Dec 23 08:18:00 2014 -0500
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Tue Dec 23 08:18:00 2014 -0500

    Merge topic 'ninja-fix-subdir-objlib-languages' into next
    
    07fc7b75 Tests: Test using objects from a language enabled in a 
subdirectory (#15325)
    fdbfcfdf Ninja: Generate rules only for languages compiled in a target 
(#15325)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=07fc7b75ef981300e7d873091ee90083b18d1c4a
commit 07fc7b75ef981300e7d873091ee90083b18d1c4a
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Mon Dec 22 19:55:08 2014 -0500
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Mon Dec 22 20:13:40 2014 -0500

    Tests: Test using objects from a language enabled in a subdirectory (#15325)
    
    Add a test case that enables CXX in the top level and C in a subdirectory.
    Create an executable in the top level that uses C objects compiled in the
    subdirectory.  Strictly speaking this is not defined behavior for all
    language combinations, but happens to work in this case.  Test this
    behavior since projects might try to use it.

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index a9cad14..f654330 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -255,6 +255,7 @@ if(BUILD_TESTING)
   endif()
   ADD_TEST_MACRO(COnly COnly)
   ADD_TEST_MACRO(CxxOnly CxxOnly)
+  ADD_TEST_MACRO(CxxSubdirC CxxSubdirC)
   ADD_TEST_MACRO(IPO COnly/COnly)
   ADD_TEST_MACRO(OutDir runtime/OutDir)
   ADD_TEST_MACRO(ObjectLibrary UseCshared)
diff --git a/Tests/CxxSubdirC/CMakeLists.txt b/Tests/CxxSubdirC/CMakeLists.txt
new file mode 100644
index 0000000..52474f8
--- /dev/null
+++ b/Tests/CxxSubdirC/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.0)
+project(CxxSubdirC CXX)
+add_subdirectory(Cdir)
+add_executable(CxxSubdirC main.cxx $<TARGET_OBJECTS:Cobj>)
diff --git a/Tests/CxxSubdirC/Cdir/CMakeLists.txt 
b/Tests/CxxSubdirC/Cdir/CMakeLists.txt
new file mode 100644
index 0000000..08a8757
--- /dev/null
+++ b/Tests/CxxSubdirC/Cdir/CMakeLists.txt
@@ -0,0 +1,2 @@
+enable_language(C)
+add_library(Cobj OBJECT Cobj.c)
diff --git a/Tests/CxxSubdirC/Cdir/Cobj.c b/Tests/CxxSubdirC/Cdir/Cobj.c
new file mode 100644
index 0000000..75a0045
--- /dev/null
+++ b/Tests/CxxSubdirC/Cdir/Cobj.c
@@ -0,0 +1 @@
+int Cobj(void) { return 0; }
diff --git a/Tests/CxxSubdirC/main.cxx b/Tests/CxxSubdirC/main.cxx
new file mode 100644
index 0000000..049220f
--- /dev/null
+++ b/Tests/CxxSubdirC/main.cxx
@@ -0,0 +1,2 @@
+extern "C" int Cobj(void);
+int main() { return Cobj(); }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fdbfcfdf0173c34845e495f4c0bd407faafc45b4
commit fdbfcfdf0173c34845e495f4c0bd407faafc45b4
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Mon Dec 22 19:41:17 2014 -0500
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Mon Dec 22 20:13:30 2014 -0500

    Ninja: Generate rules only for languages compiled in a target (#15325)
    
    Refactoring in commit v3.1.0-rc1~688^2~2 (cmTarget: Compute languages
    from object libraries on demand, 2014-03-18) taught cmTarget::GetLanguages
    to (correctly) include the languages of object library sources.  Previously
    this was done only in cmTarget::ComputeLinkImplementationLanguages to
    choose the linker language.
    
    The Ninja generator writes out generic build rules for each language
    compiled within a target using the rule variables defined in the
    directory of the target.  This only needs to be done for languages
    actually compiled within the current target.  Switch from using the
    cmTarget::GetLanguages method to get the list of languages over to
    using cmTarget::GetSourceFiles directly so we do not get the languages
    in object libraries.
    
    Strictly speaking this should make no difference because it is not safe
    to use objects from a language not enabled in the directory containing
    a target or else the link information for the language may not be
    considered.  However, in cases when no link information happens to be
    needed for a language it was possible in CMake 3.0 and below to enable
    a language only in a subdirectory providing an object library, and then
    use the objects from a containing directory.  The above change teaches
    the Ninja generator to continue working in this case.

diff --git a/Source/cmNinjaNormalTargetGenerator.cxx 
b/Source/cmNinjaNormalTargetGenerator.cxx
index e344df4..a05719d 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -110,13 +110,26 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
     << "\n\n";
 #endif
 
+  // Write rules for languages compiled in this target.
   std::set<std::string> languages;
-  this->GetTarget()->GetLanguages(languages,
-                  this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+  std::vector<cmSourceFile*> sourceFiles;
+  this->GetTarget()->GetSourceFiles(sourceFiles,
+    this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+  for(std::vector<cmSourceFile*>::const_iterator
+        i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
+    {
+    const std::string& lang = (*i)->GetLanguage();
+    if(!lang.empty())
+      {
+      languages.insert(lang);
+      }
+    }
   for(std::set<std::string>::const_iterator l = languages.begin();
       l != languages.end();
       ++l)
+    {
     this->WriteLanguageRules(*l);
+    }
 }
 
 const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const

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

Summary of changes:
 Source/cmNinjaNormalTargetGenerator.cxx |   17 +++++++++++++++--
 Tests/CMakeLists.txt                    |    1 +
 Tests/CxxSubdirC/CMakeLists.txt         |    4 ++++
 Tests/CxxSubdirC/Cdir/CMakeLists.txt    |    2 ++
 Tests/CxxSubdirC/Cdir/Cobj.c            |    1 +
 Tests/CxxSubdirC/main.cxx               |    2 ++
 6 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 Tests/CxxSubdirC/CMakeLists.txt
 create mode 100644 Tests/CxxSubdirC/Cdir/CMakeLists.txt
 create mode 100644 Tests/CxxSubdirC/Cdir/Cobj.c
 create mode 100644 Tests/CxxSubdirC/main.cxx


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

Reply via email to