cmake.bbclass: set ar/ld/nm/objcopy/objdump/ranlib/strip native paths
PATCH 1/1 cmake.bbclass: set ar/ld/nm/objcopy/objdump/ranlib/strip native paths
The CMAKE_{AR,LINKER,NM,OBJCOPY,OBJDUMP,RANLIB,STRIP} cmake variables are currently set to values like CMAKE_LINKER-NOTFOUND for native recipes because the host paths are not searched. This is because the CMAKE_FIND_ROOT_PATH_MODE_PROGRAM cmake variable is set to ONLY.
To resolve this, explicitly set the variables using FIND_PROGRAM and pass the CMAKE_FIND_ROOT_PATH_BOTH option so the host paths are also searched.
--- meta/classes/cmake.bbclass | 12 ++++++++++++ 1 file changed, 12 insertions(+)
meta/classes/cmake.bbclass +12 -0
@@ -69,6 +69,18 @@ set( CMAKE_LIBRARY_PATH ${libdir} ${base_libdir}) EOF } +cmake_do_generate_toolchain_file_append_class-native() { + cat >> ${WORKDIR}/toolchain.cmake <<EOF +FIND_PROGRAM(CMAKE_AR ${AR} CMAKE_FIND_ROOT_PATH_BOTH) +FIND_PROGRAM(CMAKE_LINKER ${LD} CMAKE_FIND_ROOT_PATH_BOTH) +FIND_PROGRAM(CMAKE_NM ${NM} CMAKE_FIND_ROOT_PATH_BOTH) +FIND_PROGRAM(CMAKE_OBJCOPY ${OBJCOPY} CMAKE_FIND_ROOT_PATH_BOTH) +FIND_PROGRAM(CMAKE_OBJDUMP ${OBJDUMP} CMAKE_FIND_ROOT_PATH_BOTH) +FIND_PROGRAM(CMAKE_RANLIB ${RANLIB} CMAKE_FIND_ROOT_PATH_BOTH) +FIND_PROGRAM(CMAKE_STRIP ${STRIP} CMAKE_FIND_ROOT_PATH_BOTH) +EOF +} + addtask generate_toolchain_file after do_patch before do_configure cmake_do_configure() {
Signature · 1 line
1.8.3.2
Am 17.07.2013 10:40, schrieb Jonathan Liu:
Quoted 8 lines
The CMAKE_{AR,LINKER,NM,OBJCOPY,OBJDUMP,RANLIB,STRIP} cmake variables are currently set to values like CMAKE_LINKER-NOTFOUND for native recipes because the host paths are not searched. This is because the
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMcmake variable is set to ONLY.To resolve this, explicitly set the variables using
FIND_PROGRAMand pass theCMAKE_FIND_ROOT_PATH_BOTHoption so the host paths are also searched.
Can you please debug the issue. Regarding my current check the variables are set in CMakeFindBinUtils.cmake and this is included by CMakeDetermineCCompiler.cmake. The later set _CMAKE_TOOLCHAIN_LOCATION based on the CMAKE_C_COMPILER variable and this is used as search location for the find_program calls. Can you check the value of _CMAKE_TOOLCHAIN_LOCATION?
Quoted 11 lines · Stefan Herbrechtsmeier
Am 17.07.2013 10:40, schrieb Jonathan Liu:
Quoted 8 lines
The CMAKE_{AR,LINKER,NM,OBJCOPY,OBJDUMP,RANLIB,STRIP} cmake variables are currently set to values like CMAKE_LINKER-NOTFOUND for native recipes because the host paths are not searched. This is because the
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMcmake variable is set to ONLY.To resolve this, explicitly set the variables using
FIND_PROGRAMand pass theCMAKE_FIND_ROOT_PATH_BOTHoption so the host paths are also searched.Can you please debug the issue. Regarding my current check the variables are set in CMakeFindBinUtils.cmake and this is included by CMakeDetermineCCompiler.cmake. The later set
_CMAKE_TOOLCHAIN_LOCATIONbased on theCMAKE_C_COMPILERvariable and this is used as search location for thefind_programcalls. Can you check the value of_CMAKE_TOOLCHAIN_LOCATION?
Within the context of the CMakeLists.txt file:CMAKE_C_COMPILER is /usr/bin/gcc._CMAKE_TOOLCHAIN_LOCATION is not set to anything.
If I add message(test) to build/tmp/sysroots/x86_64-linux/usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake, it doesn't get printed out when running cmake on CMakeLists.txt (cmake is build/tmp/sysroots/x86_64-linux/usr/bin/cmake).
Regards,
Jonathan
Quoted 12 lines · Jonathan Liu
Quoted 11 lines · Stefan Herbrechtsmeier
Am 17.07.2013 10:40, schrieb Jonathan Liu:
Quoted 8 lines
The CMAKE_{AR,LINKER,NM,OBJCOPY,OBJDUMP,RANLIB,STRIP} cmake variables are currently set to values like CMAKE_LINKER-NOTFOUND for native recipes because the host paths are not searched. This is because the
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMcmake variable is set to ONLY.To resolve this, explicitly set the variables using
FIND_PROGRAMand pass theCMAKE_FIND_ROOT_PATH_BOTHoption so the host paths are also searched.Can you please debug the issue. Regarding my current check the variables are set in CMakeFindBinUtils.cmake and this is included by CMakeDetermineCCompiler.cmake. The later set
_CMAKE_TOOLCHAIN_LOCATIONbased on theCMAKE_C_COMPILERvariable and this is used as search location for thefind_programcalls. Can you check the value of_CMAKE_TOOLCHAIN_LOCATION?
Quoted 8 lines
Within the context of the CMakeLists.txt file:
CMAKE_C_COMPILERis/usr/bin/gcc._CMAKE_TOOLCHAIN_LOCATIONis not set to anything.If I add message(test) to build/tmp/sysroots/x86_64-linux/usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake, it doesn't get printed out when running cmake on CMakeLists.txt (cmake is build/tmp/sysroots/x86_64-linux/usr/bin/cmake).
Regards,
Jonathan
For:
find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
It seems the ${_CMAKE_TOOLCHAIN_LOCATION} hint is not used when CMAKE_FIND_ROOT_PATH_MODE_PROGRAM is set to ONLY.
Test case (CMakeLists.txt):cmake_minimum_required(VERSION 2.8)set(CMAKE_FIND_ROOT_PATH /var/empty)set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)FIND_PROGRAM(LD NAMES ld HINTS /usr/bin)
message(${LD})
Running cmake displays:
LD-NOTFOUND
If "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)" is commented out, it displays /usr/bin/ld.
Regards,
Jonathan
Am 17.07.2013 12:57, schrieb Jonathan Liu:
Quoted 17 lines · Jonathan Liu
Quoted 16 lines · Stefan Herbrechtsmeier
Quoted 11 lines
Am 17.07.2013 10:40, schrieb Jonathan Liu:
Quoted 8 lines
The CMAKE_{AR,LINKER,NM,OBJCOPY,OBJDUMP,RANLIB,STRIP} cmake variables are currently set to values like CMAKE_LINKER-NOTFOUND for native recipes because the host paths are not searched. This is because the
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMcmake variable is set to ONLY.To resolve this, explicitly set the variables using
FIND_PROGRAMand pass theCMAKE_FIND_ROOT_PATH_BOTHoption so the host paths are also searched.Can you please debug the issue. Regarding my current check the variables are set in CMakeFindBinUtils.cmake and this is included by CMakeDetermineCCompiler.cmake. The later set
_CMAKE_TOOLCHAIN_LOCATIONbased on theCMAKE_C_COMPILERvariable and this is used as search location for thefind_programcalls. Can you check the value of_CMAKE_TOOLCHAIN_LOCATION?Within the context of the CMakeLists.txt file:
CMAKE_C_COMPILERis/usr/bin/gcc._CMAKE_TOOLCHAIN_LOCATIONis not set to anything.
Quoted 8 lines
Quoted 4 lines
If I add message(test) to build/tmp/sysroots/x86_64-linux/usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake, it doesn't get printed out when running cmake on CMakeLists.txt (cmake is build/tmp/sysroots/x86_64-linux/usr/bin/cmake).
Regards,
JonathanFor:
find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})It seems the ${_CMAKE_TOOLCHAIN_LOCATION} hint is not used when
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMis set to ONLY.
You are right. The CMAKE_FIND_ROOT_PATH is used also as base for the HINTS paths.
You can use _CMAKE_TOOLCHAIN_LOCATION to pass NO_CMAKE_FIND_ROOT_PATH to the find_program calls:set(_CMAKE_TOOLCHAIN_LOCATION "" NO_CMAKE_FIND_ROOT_PATH)
This should work but I am not sure if it is a good solution.
Quoted 43 lines · Stefan Herbrechtsmeier
Am 17.07.2013 12:57, schrieb Jonathan Liu:
Quoted 33 lines · Jonathan Liu
Quoted 24 lines · Stefan Herbrechtsmeier
Quoted 12 lines
Am 17.07.2013 10:40, schrieb Jonathan Liu:
Quoted 9 lines
The CMAKE_{AR,LINKER,NM,OBJCOPY,OBJDUMP,RANLIB,STRIP} cmake variables are currently set to values like CMAKE_LINKER-NOTFOUND for native recipes because the host paths are not searched. This is because the
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMcmake variable is set to ONLY.To resolve this, explicitly set the variables using
FIND_PROGRAMand pass theCMAKE_FIND_ROOT_PATH_BOTHoption so the host paths are also searched.Quoted 6 lines
Can you please debug the issue. Regarding my current check the variables are set in CMakeFindBinUtils.cmake and this is included by CMakeDetermineCCompiler.cmake. The later set
_CMAKE_TOOLCHAIN_LOCATIONbased on theCMAKE_C_COMPILERvariable and this is used as search location for thefind_programcalls. Can you check the value of_CMAKE_TOOLCHAIN_LOCATION?Within the context of the CMakeLists.txt file:
CMAKE_C_COMPILERis/usr/bin/gcc._CMAKE_TOOLCHAIN_LOCATIONis not set to anything.Quoted 7 lines
If I add message(test) to build/tmp/sysroots/x86_64-linux/usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake, it doesn't get printed out when running cmake on CMakeLists.txt (cmake is build/tmp/sysroots/x86_64-linux/usr/bin/cmake).
Regards,
JonathanQuoted 7 lines
For:
find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})It seems the ${_CMAKE_TOOLCHAIN_LOCATION} hint is not used when
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMis set to ONLY.
Quoted 9 lines
You are right. The
CMAKE_FIND_ROOT_PATHis used also as base for the HINTS paths.You can use
_CMAKE_TOOLCHAIN_LOCATIONto passNO_CMAKE_FIND_ROOT_PATHto thefind_programcalls:set(_CMAKE_TOOLCHAIN_LOCATION "" NO_CMAKE_FIND_ROOT_PATH)This should work but I am not sure if it is a good solution.
I prefer setting documented variables rather than hacking the undocumented _CMAKE_TOOLCHAIN_LOCATION variable to add the NO_CMAKE_FIND_ROOT_PATH flag for FIND_PROGRAM.
Regards,
Jonathan
Am 18.07.2013 02:47, schrieb Jonathan Liu:
Quoted 46 lines
Quoted 44 lines · Stefan Herbrechtsmeier
Am 17.07.2013 12:57, schrieb Jonathan Liu:
Quoted 28 lines · Jonathan Liu
Quoted 20 lines · Stefan Herbrechtsmeier
Quoted 6 lines
Am 17.07.2013 10:40, schrieb Jonathan Liu:
Quoted 5 lines
The CMAKE_{AR,LINKER,NM,OBJCOPY,OBJDUMP,RANLIB,STRIP} cmake variables are currently set to values like CMAKE_LINKER-NOTFOUND for native recipes because the host paths are not searched. This is because the
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMcmake variable is set to ONLY.Quoted 9 lines
Quoted 3 lines
To resolve this, explicitly set the variables using
FIND_PROGRAMand pass theCMAKE_FIND_ROOT_PATH_BOTHoption so the host paths are also searched.Can you please debug the issue. Regarding my current check the variables are set in CMakeFindBinUtils.cmake and this is included by CMakeDetermineCCompiler.cmake. The later set
_CMAKE_TOOLCHAIN_LOCATIONbased on theCMAKE_C_COMPILERvariable and this is used as search location for thefind_programcalls. Can you check the value of_CMAKE_TOOLCHAIN_LOCATION?Within the context of the CMakeLists.txt file:
CMAKE_C_COMPILERis/usr/bin/gcc._CMAKE_TOOLCHAIN_LOCATIONis not set to anything.Quoted 7 lines
If I add message(test) to build/tmp/sysroots/x86_64-linux/usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake, it doesn't get printed out when running cmake on CMakeLists.txt (cmake is build/tmp/sysroots/x86_64-linux/usr/bin/cmake).
Regards,
JonathanQuoted 7 lines
For:
find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})It seems the ${_CMAKE_TOOLCHAIN_LOCATION} hint is not used when
CMAKE_FIND_ROOT_PATH_MODE_PROGRAMis set to ONLY.You are right. The
CMAKE_FIND_ROOT_PATHis used also as base for the HINTS paths.You can use
_CMAKE_TOOLCHAIN_LOCATIONto passNO_CMAKE_FIND_ROOT_PATHto thefind_programcalls:set(_CMAKE_TOOLCHAIN_LOCATION "" NO_CMAKE_FIND_ROOT_PATH)
Quoted 5 lines
Quoted 2 lines
This should work but I am not sure if it is a good solution.
I prefer setting documented variables rather than hacking the undocumented
_CMAKE_TOOLCHAIN_LOCATIONvariable to add theNO_CMAKE_FIND_ROOT_PATHflag forFIND_PROGRAM.
I think it is a issue in cmake and the _CMAKE_TOOLCHAIN_LOCATION don't work with CMAKE_FIND_ROOT_PATH_MODE_PROGRAM set to ONLY. I have open an issue in cmake to get some feedback. The could patch all find_program calls in CMakeFindBinUtils.cmake modules:
- find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} PATHS "${_CMAKE_TOOLCHAIN_LOCATION}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
+ find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX})Additionally there is a second issue as cmake fails to add the paths to the CMAKE_C*_COMPILER variables in CMakeDetermineC*Compiler modules and thereby couldn't set the _CMAKE_TOOLCHAIN_LOCATION. But this is a issue of oe as we should pass the full path of the compilers.