Add oecore sysroot variable to CMAKE_FIND_ROOT_PATH
cover Add oecore sysroot variable to CMAKE_FIND_ROOT_PATH
From: Timo Mueller <[email protected]>
Hi,
we were not considering the oecore sysroot variables provided by the environment script when constructing the CMAKE_FIND_ROOT_PATH in the toolchain cmake. As the other used variables do not necessarily contain values the CMAKE_FIND_ROOT_PATH can be empty. This can lead to issues when searching paths or libraries with CMake.
By using the oecore sysroot variables we make sure, that the CMAKE_FIND_ROOT_PATH contains sane values and all the find methods of CMake are at least searching the provided sysroot.
01: Refactors the CMAKE_ROOT_PATH construction to ease the future addition or removal of variables
02: Adds the oecore sysroot varaibles
Best regards,
Timo
Timo Mueller (2):
plugins/cmake: Refactor creation of CMAKE_FIND_ROOT_PATH plugins/cmake: Add oecore sysroot variables to CMAKE_FIND_ROOT_PATH
.../YoctoCMakeMakefileGenerator.java | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-)
Signature · 1 line
1.9.0
PATCH 1/2 plugins/cmake: Refactor creation of CMAKE_FIND_ROOT_PATH
From: Timo Mueller <[email protected]>
Adding new environment variables to the list of variables that contribute to the the CMAKE_FIND_ROOT_PATH involved manually appending to the value string and also adding a whitespace to separate values.
The construction of the CMAKE_FIND_ROOT_PATH value is extracted to a separate method, which expects a list of environment variables. Adding or removing environment variables that contribute to the path is now achieved by modifying the entries of the list.
--- .../YoctoCMakeMakefileGenerator.java | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-)
plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMakefileGenerator.java +23 -12
@@ -12,6 +12,8 @@ package org.yocto.cmake.managedbuilder; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.Arrays; +import java.util.List; import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -226,18 +228,13 @@ public class YoctoCMakeMakefileGenerator implements IManagedBuilderMakefileGener toolchainCMakeFileContentAsString += "# only search in the paths provided so cmake doesnt pick\n"; //$NON-NLS-1$ toolchainCMakeFileContentAsString += "# up libraries and tools from the native build machine\n"; //$NON-NLS-1$ - String findRootPathValue = YoctoSDKUtils.getEnvValue(project, "STAGING_DIR_HOST"); //$NON-NLS-1$ - findRootPathValue += " "; //$NON-NLS-1$ - findRootPathValue += YoctoSDKUtils.getEnvValue(project, "STAGING_DIR_NATIVE"); //$NON-NLS-1$ - findRootPathValue += " "; //$NON-NLS-1$ - findRootPathValue += YoctoSDKUtils.getEnvValue(project, "CROSS_DIR"); //$NON-NLS-1$ - findRootPathValue += " "; //$NON-NLS-1$ - findRootPathValue += YoctoSDKUtils.getEnvValue(project, "OECMAKE_PERLNATIVE_DIR"); //$NON-NLS-1$ - findRootPathValue += " "; //$NON-NLS-1$ - findRootPathValue += YoctoSDKUtils.getEnvValue(project, "OECMAKE_EXTRA_ROOT_PATH"); //$NON-NLS-1$ - findRootPathValue += " "; //$NON-NLS-1$ - findRootPathValue += YoctoSDKUtils.getEnvValue(project, "EXTERNAL_TOOLCHAIN"); //$NON-NLS-1$ - toolchainCMakeFileContentAsString += createCMakeSetStatement("CMAKE_FIND_ROOT_PATH", findRootPathValue, null); //$NON-NLS-1$ + List<String> findRootPathValues = Arrays.asList("STAGING_DIR_HOST", //$NON-NLS-1$ + "STAGING_DIR_NATIVE", //$NON-NLS-1$ + "CROSS_DIR", //$NON-NLS-1$ + "OECMAKE_PERLNATIVE_DIR", //$NON-NLS-1$ + "OECMAKE_EXTRA_ROOT_PATH", //$NON-NLS-1$ + "EXTERNAL_TOOLCHAIN"); //$NON-NLS-1$ + toolchainCMakeFileContentAsString += createCMakeSetStatement("CMAKE_FIND_ROOT_PATH", getFindRootPath(findRootPathValues), null); //$NON-NLS-1$ toolchainCMakeFileContentAsString += createCMakeSetStatement("CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "ONLY", null); //$NON-NLS-1$ //$NON-NLS-2$ toolchainCMakeFileContentAsString += createCMakeSetStatement("CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "ONLY", null); //$NON-NLS-1$ //$NON-NLS-2$
@@ -278,4 +275,18 @@ public class YoctoCMakeMakefileGenerator implements IManagedBuilderMakefileGener e.printStackTrace(); } } + + private String getFindRootPath(List<String> values) { + String findRootPath = ""; + + for (String value : values) { + String pathValue = YoctoSDKUtils.getEnvValue(project, value); + + if (pathValue.length() > 0) { + findRootPath += pathValue + " "; + } + } + + return findRootPath; + } }
Signature · 1 line
1.9.0
PATCH 2/2 plugins/cmake: Add oecore sysroot variables to CMAKE_FIND_ROOT_PATH
From: Timo Mueller <[email protected]>
The sysroots provided by the toolchain were not added to the CMAKE_FIND_ROOT_PATH variable. This resolved into CMake searching on the host system breaking cross-compilation in some cases.
With the addition of the sysroot environment variables provided by oecore, we make sure that these sysroots are scanned when CMake is conducting searches.
[BUGFIX #6314]
--- .../org/yocto/cmake/managedbuilder/YoctoCMakeMakefileGenerator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMakefileGenerator.java +3 -1
@@ -228,7 +228,9 @@ public class YoctoCMakeMakefileGenerator implements IManagedBuilderMakefileGener toolchainCMakeFileContentAsString += "# only search in the paths provided so cmake doesnt pick\n"; //$NON-NLS-1$ toolchainCMakeFileContentAsString += "# up libraries and tools from the native build machine\n"; //$NON-NLS-1$ - List<String> findRootPathValues = Arrays.asList("STAGING_DIR_HOST", //$NON-NLS-1$ + List<String> findRootPathValues = Arrays.asList("OECORE_NATIVE_SYSROOT", //$NON-NLS-1$ + "OECORE_TARGET_SYSROOT", //$NON-NLS-1$ + "STAGING_DIR_HOST", //$NON-NLS-1$ "STAGING_DIR_NATIVE", //$NON-NLS-1$ "CROSS_DIR", //$NON-NLS-1$ "OECMAKE_PERLNATIVE_DIR", //$NON-NLS-1$
Signature · 1 line
1.9.0
Pulled into eclipse-poky-kepler master. Thanks for the contribution! - Jessica
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Timo Mueller
Sent: Thursday, May 22, 2014 3:05 AM
To: [email protected]
Cc: Timo Mueller
Subject: [yocto] [eclipse][PATCH 0/2] Add oecore sysroot variable to CMAKE_FIND_ROOT_PATH
From: Timo Mueller <[email protected]>
Hi,
we were not considering the oecore sysroot variables provided by the environment script when constructing the CMAKE_FIND_ROOT_PATH in the toolchain cmake. As the other used variables do not necessarily contain values the CMAKE_FIND_ROOT_PATH can be empty. This can lead to issues when searching paths or libraries with CMake.
By using the oecore sysroot variables we make sure, that the CMAKE_FIND_ROOT_PATH contains sane values and all the find methods of CMake are at least searching the provided sysroot.
01: Refactors the CMAKE_ROOT_PATH construction to ease the future addition or removal of variables 02: Adds the oecore sysroot varaibles
Best regards,
Timo
Timo Mueller (2):
plugins/cmake: Refactor creation of CMAKE_FIND_ROOT_PATH plugins/cmake: Add oecore sysroot variables to CMAKE_FIND_ROOT_PATH
.../YoctoCMakeMakefileGenerator.java | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-)
--
1.9.0
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto