<p dir="ltr">We should submit these kind of changes upstream first and get an opinion before forking like this</p>
<div class="gmail_quote">On Mar 10, 2016 2:25 PM, &quot;Hongxu Jia&quot; &lt;<a href="mailto:hongxu.jia@windriver.com">hongxu.jia@windriver.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">While &#39;__FILE__&#39; is used in C/C++ source file, we need to<br>
compile with relative path to avoid build path issue.<br>
<br>
If a recipe(such as waffle) inherit cmake, it invoke native<br>
cmake to generate Makefile:<br>
Without the fix:<br>
vim ./build.make<br>
|    cd /Build/tmp/work/core2-64-poky-linux/waffle/1.5.2-r0/<br>
build/src/waffle &amp;&amp; /Build/tmp/sysroots/x86_64-linux/usr/bin/<br>
x86_64-poky-linux/x86_64-poky-linux-gcc  $(C_DEFINES) $(C_INCLUDES)<br>
$(C_FLAGS) -o glx/glx_context.c.o   -c /Build/tmp/work/core2-64-poky-linux/<br>
waffle/1.5.2-r0/waffle-1.5.2/src/waffle/glx/glx_context.c<br>
<br>
With the fix:<br>
vim ./build.make<br>
|    cd /Build/tmp/work/core2-64-poky-linux/waffle/1.5.2-r0/<br>
build/src/waffle &amp;&amp; /Build/tmp/sysroots/x86_64-linux/usr/bin/<br>
x86_64-poky-linux/x86_64-poky-linux-gcc  $(C_DEFINES) $(C_INCLUDES)<br>
$(C_FLAGS) -o glx/glx_context.c.o   -c ../../../waffle-1.5.2/src/waffle/glx/glx_context.c<br>
<br>
[YOCTO #7058]<br>
<br>
Signed-off-by: Hongxu Jia &lt;<a href="mailto:hongxu.jia@windriver.com">hongxu.jia@windriver.com</a>&gt;<br>
---<br>
 meta/recipes-devtools/cmake/<a href="http://cmake-native_3.4.3.bb" rel="noreferrer" target="_blank">cmake-native_3.4.3.bb</a>  |   1 +<br>
 .../convert-source-file-to-relative-path.patch     | 128 +++++++++++++++++++++<br>
 2 files changed, 129 insertions(+)<br>
 create mode 100644 meta/recipes-devtools/cmake/cmake/convert-source-file-to-relative-path.patch<br>
<br>
diff --git a/meta/recipes-devtools/cmake/<a href="http://cmake-native_3.4.3.bb" rel="noreferrer" target="_blank">cmake-native_3.4.3.bb</a> b/meta/recipes-devtools/cmake/<a href="http://cmake-native_3.4.3.bb" rel="noreferrer" target="_blank">cmake-native_3.4.3.bb</a><br>
index cb4e749..2939512 100644<br>
--- a/meta/recipes-devtools/cmake/<a href="http://cmake-native_3.4.3.bb" rel="noreferrer" target="_blank">cmake-native_3.4.3.bb</a><br>
+++ b/meta/recipes-devtools/cmake/<a href="http://cmake-native_3.4.3.bb" rel="noreferrer" target="_blank">cmake-native_3.4.3.bb</a><br>
@@ -6,6 +6,7 @@ DEPENDS += &quot;bzip2-native zlib-native&quot;<br>
<br>
 SRC_URI += &quot;\<br>
     file://cmlibarchive-disable-ext2fs.patch \<br>
+    file://convert-source-file-to-relative-path.patch \<br>
 &quot;<br>
<br>
 # Disable ccmake since we don&#39;t depend on ncurses<br>
diff --git a/meta/recipes-devtools/cmake/cmake/convert-source-file-to-relative-path.patch b/meta/recipes-devtools/cmake/cmake/convert-source-file-to-relative-path.patch<br>
new file mode 100644<br>
index 0000000..77a5155<br>
--- /dev/null<br>
+++ b/meta/recipes-devtools/cmake/cmake/convert-source-file-to-relative-path.patch<br>
@@ -0,0 +1,128 @@<br>
+From c272c82eaeed2ae4b72f40af2754e91f1450a705 Mon Sep 17 00:00:00 2001<br>
+From: Hongxu Jia &lt;<a href="mailto:hongxu.jia@windriver.com">hongxu.jia@windriver.com</a>&gt;<br>
+Date: Thu, 3 Mar 2016 04:48:46 -0500<br>
+Subject: [PATCH] convert source file to relative path<br>
+<br>
+Although there is CMAKE_USE_RELATIVE_PATHS, but upstream<br>
+explicitly did not support relative path.<br>
+In git://<a href="http://cmake.org/cmake.git" rel="noreferrer" target="_blank">cmake.org/cmake.git</a><br>
+...<br>
+commit 1335992c8f4e8b96f1a21d5dcc7d65a9fbd84c11<br>
+Author: Stephen Kelly &lt;<a href="mailto:steveire@gmail.com">steveire@gmail.com</a>&gt;<br>
+Date:   Mon Jun 1 19:56:46 2015 +0200<br>
+<br>
+    Remove CMAKE_USE_RELATIVE_PATHS variable.<br>
+...<br>
+The reason is in <a href="https://cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">https://cmake.org/Wiki/CMake_FAQ</a><br>
+(Why does CMake use full paths, or can I copy my build tree?)<br>
+<br>
+But oe-core need the source file path relative while compiling<br>
+to avoid build path issue. The fix partly refer the above commit,<br>
+but in order to minimize the influence, it only tweak gcc compiling<br>
+rule in generated Makefile (With &quot;Building ** object&quot; message).<br>
+<br>
+Upstream-Status: Inappropriate [openembedded specific]<br>
+<br>
+Signed-off-by: Hongxu Jia &lt;<a href="mailto:hongxu.jia@windriver.com">hongxu.jia@windriver.com</a>&gt;<br>
+---<br>
+ Source/cmCommonTargetGenerator.cxx   |  7 +++++++<br>
+ Source/cmCommonTargetGenerator.h     |  5 +++++<br>
+ Source/cmMakefileTargetGenerator.cxx |  5 +++++<br>
+ Source/cmOutputConverter.cxx         | 14 ++++++++++++++<br>
+ Source/cmOutputConverter.h           |  5 +++++<br>
+ 5 files changed, 36 insertions(+)<br>
+<br>
+diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx<br>
+index 252e231..f7d2d6b 100644<br>
+--- a/Source/cmCommonTargetGenerator.cxx<br>
++++ b/Source/cmCommonTargetGenerator.cxx<br>
+@@ -54,6 +54,13 @@ std::string cmCommonTargetGenerator::Convert(<br>
+   return this-&gt;LocalGenerator-&gt;Convert(source, relative, output);<br>
+ }<br>
+<br>
++std::string cmCommonTargetGenerator::Convert(<br>
++  std::string const&amp; local,<br>
++  std::string const&amp; remote,<br>
++  cmLocalGenerator::OutputFormat output)<br>
++{<br>
++  return this-&gt;LocalGenerator-&gt;Convert(local, remote, output);<br>
++}<br>
+ //----------------------------------------------------------------------------<br>
+ const char* cmCommonTargetGenerator::GetFeature(const std::string&amp; feature)<br>
+ {<br>
+diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h<br>
+index a4b2c10..6e6b724 100644<br>
+--- a/Source/cmCommonTargetGenerator.h<br>
++++ b/Source/cmCommonTargetGenerator.h<br>
+@@ -72,6 +72,11 @@ protected:<br>
+                       cmLocalGenerator::OutputFormat output =<br>
+                       cmLocalGenerator::UNCHANGED);<br>
+<br>
++  std::string Convert(std::string const&amp; local,<br>
++                      std::string const&amp; remote,<br>
++                      cmLocalGenerator::OutputFormat output =<br>
++                      cmLocalGenerator::UNCHANGED);<br>
++<br>
+   void AppendFortranFormatFlags(std::string&amp; flags,<br>
+                                 cmSourceFile const&amp; source);<br>
+<br>
+diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx<br>
+index b278087..84a6ed7 100644<br>
+--- a/Source/cmMakefileTargetGenerator.cxx<br>
++++ b/Source/cmMakefileTargetGenerator.cxx<br>
+@@ -530,6 +530,11 @@ cmMakefileTargetGenerator<br>
+     this-&gt;LocalGenerator-&gt;AppendEcho<br>
+       (commands, buildEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild,<br>
+        &amp;progress);<br>
++<br>
++    //Convert sourceFile to relative path<br>
++    sourceFile = this-&gt;Convert(this-&gt;Makefile-&gt;GetCurrentBinaryDirectory(),<br>
++                               sourceFile,<br>
++                               cmLocalGenerator::SHELL);<br>
+     }<br>
+<br>
+   std::string targetOutPathReal;<br>
+diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx<br>
+index 5acae2f..3d71739 100644<br>
+--- a/Source/cmOutputConverter.cxx<br>
++++ b/Source/cmOutputConverter.cxx<br>
+@@ -94,6 +94,20 @@ const char* cmOutputConverter::GetRelativeRootPath(RelativeRoot relroot) const<br>
+   return 0;<br>
+ }<br>
+<br>
++std::string cmOutputConverter::Convert(const std::string&amp; local,<br>
++                                       const std::string&amp; remote,<br>
++                                       OutputFormat output) const<br>
++{<br>
++  // Convert the path to a relative path.<br>
++  std::string result = remote;<br>
++<br>
++  std::vector&lt;std::string&gt; components;<br>
++  cmSystemTools::SplitPath(local, components);<br>
++  result = this-&gt;ConvertToRelativePath(components, result, true);<br>
++<br>
++  return this-&gt;ConvertToOutputFormat(result, output);<br>
++}<br>
++<br>
+ std::string cmOutputConverter::Convert(const std::string&amp; source,<br>
+                                        RelativeRoot relative,<br>
+                                        OutputFormat output) const<br>
+diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h<br>
+index 852df5d..d887a99 100644<br>
+--- a/Source/cmOutputConverter.h<br>
++++ b/Source/cmOutputConverter.h<br>
+@@ -45,6 +45,11 @@ public:<br>
+   std::string Convert(RelativeRoot remote, const std::string&amp; local,<br>
+                       OutputFormat output = UNCHANGED,<br>
+                       bool optional = false) const;<br>
++<br>
++  std::string Convert(const std::string&amp; local,<br>
++                      const std::string&amp; remote,<br>
++                      OutputFormat output = UNCHANGED) const;<br>
++<br>
+   std::string ConvertDirectorySeparatorsForShell(<br>
+                                              const std::string&amp; source) const;<br>
+<br>
+--<br>
+1.9.1<br>
+<br>
--<br>
1.9.1<br>
<br>
--<br>
_______________________________________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/openembedded-core</a><br>
</blockquote></div>