[cmake-developers] [PATCH] ninja generator: don't initialize language for files marked, as header-only

Tim Blechmann tim at klingt.org
Wed Apr 8 07:38:30 EDT 2015


not sure if there is a better way to resolve this issue:
declaring .RC files as header-only break ninja builds on non-windows
platforms.

--->8---

cmake currently tries to initialize the language rules for all source
files. when HEADER_FILE_ONLY is used to mark files which should be added
to the generated project, but should not be compiled, this will
nevertheless try to initialize the language, which might fail on that
specific platform. this is a practical issue when declaring .RC files as
header-only on non-windows platforms.
-------------- next part --------------
From 5a49f37edf8d038dc759d46084d1c4be19b6a486 Mon Sep 17 00:00:00 2001
From: Tim Blechmann <tim at klingt.org>
Date: Wed, 8 Apr 2015 13:36:21 +0200
Subject: [PATCH] ninja generator: don't initialize language for files marked
 as header-only

cmake currently tries to initialize the language rules for all source files.
when HEADER_FILE_ONLY is used to mark files which should be added to the
generated project, but should not be compiled, this will nevertheless try
to initialize the language, which might fail on that specific platform.
this is a practical issue when declaring .RC files as header-only on
non-windows platforms.
---
 Source/cmNinjaNormalTargetGenerator.cxx | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index c352c1a..b5c0985 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -119,6 +119,9 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
   for(std::vector<cmSourceFile*>::const_iterator
         i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
     {
+    if((*i)->GetPropertyAsBool("HEADER_FILE_ONLY"))
+      continue;
+
     const std::string& lang = (*i)->GetLanguage();
     if(!lang.empty())
       {
-- 
2.3.5



More information about the cmake-developers mailing list