<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, "Hongxu Jia" <<a href="mailto:hongxu.jia@windriver.com">hongxu.jia@windriver.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">While '__FILE__' 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 && /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 && /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 <<a href="mailto:hongxu.jia@windriver.com">hongxu.jia@windriver.com</a>><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 += "bzip2-native zlib-native"<br>
<br>
SRC_URI += "\<br>
file://cmlibarchive-disable-ext2fs.patch \<br>
+ file://convert-source-file-to-relative-path.patch \<br>
"<br>
<br>
# Disable ccmake since we don'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 <<a href="mailto:hongxu.jia@windriver.com">hongxu.jia@windriver.com</a>><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 <<a href="mailto:steveire@gmail.com">steveire@gmail.com</a>><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 "Building ** object" message).<br>
+<br>
+Upstream-Status: Inappropriate [openembedded specific]<br>
+<br>
+Signed-off-by: Hongxu Jia <<a href="mailto:hongxu.jia@windriver.com">hongxu.jia@windriver.com</a>><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->LocalGenerator->Convert(source, relative, output);<br>
+ }<br>
+<br>
++std::string cmCommonTargetGenerator::Convert(<br>
++ std::string const& local,<br>
++ std::string const& remote,<br>
++ cmLocalGenerator::OutputFormat output)<br>
++{<br>
++ return this->LocalGenerator->Convert(local, remote, output);<br>
++}<br>
+ //----------------------------------------------------------------------------<br>
+ const char* cmCommonTargetGenerator::GetFeature(const std::string& 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& local,<br>
++ std::string const& remote,<br>
++ cmLocalGenerator::OutputFormat output =<br>
++ cmLocalGenerator::UNCHANGED);<br>
++<br>
+ void AppendFortranFormatFlags(std::string& flags,<br>
+ cmSourceFile const& 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->LocalGenerator->AppendEcho<br>
+ (commands, buildEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild,<br>
+ &progress);<br>
++<br>
++ //Convert sourceFile to relative path<br>
++ sourceFile = this->Convert(this->Makefile->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& local,<br>
++ const std::string& remote,<br>
++ OutputFormat output) const<br>
++{<br>
++ // Convert the path to a relative path.<br>
++ std::string result = remote;<br>
++<br>
++ std::vector<std::string> components;<br>
++ cmSystemTools::SplitPath(local, components);<br>
++ result = this->ConvertToRelativePath(components, result, true);<br>
++<br>
++ return this->ConvertToOutputFormat(result, output);<br>
++}<br>
++<br>
+ std::string cmOutputConverter::Convert(const std::string& 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& local,<br>
+ OutputFormat output = UNCHANGED,<br>
+ bool optional = false) const;<br>
++<br>
++ std::string Convert(const std::string& local,<br>
++ const std::string& remote,<br>
++ OutputFormat output = UNCHANGED) const;<br>
++<br>
+ std::string ConvertDirectorySeparatorsForShell(<br>
+ const std::string& 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>