diff options
author | Brad King <brad.king@kitware.com> | 2014-12-24 11:38:24 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-12-24 11:38:24 (GMT) |
commit | 661622f011810093433afa5c9a4795b3d2f19070 (patch) | |
tree | 0f5bf633e9eacfde5787cbf881921b16faf1b841 | |
parent | c20d3d319cb97da5793beebe42a80361b2d247c4 (diff) | |
parent | 07fc7b75ef981300e7d873091ee90083b18d1c4a (diff) | |
download | CMake-661622f011810093433afa5c9a4795b3d2f19070.zip CMake-661622f011810093433afa5c9a4795b3d2f19070.tar.gz CMake-661622f011810093433afa5c9a4795b3d2f19070.tar.bz2 |
Merge topic 'ninja-fix-subdir-objlib-languages'
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)
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 17 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CxxSubdirC/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/CxxSubdirC/Cdir/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CxxSubdirC/Cdir/Cobj.c | 1 | ||||
-rw-r--r-- | Tests/CxxSubdirC/main.cxx | 2 |
6 files changed, 25 insertions, 2 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 25931f3..53b7a8e 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 diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8df27f4..dea30e4 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -251,6 +251,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(); } |