Skip to contentSkip to conversation

cmake.bbclass: set archiver, linker and ranlib in toolchain.cmake

PATCH In review Pascal Bach 2 participants 4 messages Jul 17, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmake.bbclass: set archiver, linker and ranlib in toolchain.cmake

Setting CMAKE_AR, CMAKE_LINKER and CMAKE_RANLIB correctly in toolchain.cmake is necessary to correctly build -native packages using CMake.

The reason is that CMake is not able to find the above utilities by itself because CMAKE_FIND_ROOT_PATH_MODE_PROGRAM is set to ONLY so we need to tell it explicitly where to look.

---
 meta/classes/cmake.bbclass | 8 ++++++++
 1 file changed, 8 insertions(+)
meta/classes/cmake.bbclass +8 -0
index 995ddf1..cae0ad2 100644
@@ -13,6 +13,9 @@ inherit autotools
 # C/C++ Compiler (without cpu arch/tune arguments)
 OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
 OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_AR ?= "`echo ${AR} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_LINKER ?= "`echo ${LD} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_RANLIB ?= "`echo ${RANLIB} | sed 's/^\([^ ]*\).*/\1/'`"
 
 # Compiler flags
 OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}"
@@ -35,6 +38,11 @@ set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH} )
 set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )
 set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )
 set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} )
+# Force the use of cache here otherwise the values will be overridden (http://www.cmake.org/Bug/view.php?id=13038)
+set( CMAKE_AR ar CACHE FILEPATH "Archiver" FORCE )
+set( CMAKE_LINKER ld CACHE FILEPATH "Linker" FORCE )
+set( CMAKE_RANLIB ranlib CACHE FILEPATH "Ranlib" FORCE )
+
 set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" )
 set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" )
 set( CMAKE_ASM_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "ASM FLAGS" )
Signature · 1 line
1.9.1
#1 lore raw

Am 17.07.2015 um 09:44 schrieb Pascal Bach:

Quoted 7 lines

Setting CMAKE_AR, CMAKE_LINKER and CMAKE_RANLIB correctly in toolchain.cmake is necessary to correctly build -native packages using CMake.

The reason is that CMake is not able to find the above utilities by itself because CMAKE_FIND_ROOT_PATH_MODE_PROGRAM is set to ONLY so we need to tell it explicitly where to look.

Which version do you use? The master sets CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to BOTH for native packages.

If this don't work you could set the CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN path (without /bin).

Quoted 10 lines
---
  meta/classes/cmake.bbclass | 8 ++++++++
  1 file changed, 8 insertions(+)
meta/classes/cmake.bbclass +0 -0
index 995ddf1..cae0ad2 100644

meta/classes/cmake.bbclass inherit autotools · line 16

Quoted 4 lines
meta/classes/cmake.bbclass +1 -0
@@ -13,6 +13,9 @@ inherit autotools
  # C/C++ Compiler (without cpu arch/tune arguments)
  OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
  OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_AR ?= "`echo ${AR} | sed 's/^\([^ ]*\).*/\1/'`"

This is already set in master.

meta/classes/cmake.bbclass inherit autotools · line 18

Quoted 2 lines
meta/classes/cmake.bbclass +2 -0
+OECMAKE_LINKER ?= "`echo ${LD} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_RANLIB ?= "`echo ${RANLIB} | sed 's/^\([^ ]*\).*/\1/'`"

You don't need the sed for ranlib.

meta/classes/cmake.bbclass set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH} ) · line 45

Quoted 11 lines
meta/classes/cmake.bbclass +5 -0
  # Compiler flags
  OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}"
@@ -35,6 +38,11 @@ set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH} )
  set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )
  set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )
  set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} )
+# Force the use of cache here otherwise the values will be overridden (http://www.cmake.org/Bug/view.php?id=13038)
+set( CMAKE_AR ar CACHE FILEPATH "Archiver" FORCE )
+set( CMAKE_LINKER ld CACHE FILEPATH "Linker" FORCE )
+set( CMAKE_RANLIB ranlib CACHE FILEPATH "Ranlib" FORCE )
+

Why you generate OECMAKE_* and don't use them?

Furthermore the CMAKE_* should contain the full path and are generated in the CMakeFindBinUtils.cmake.

Quoted 3 lines
meta/classes/cmake.bbclass +0 -0
  set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" )
  set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" )
  set( CMAKE_ASM_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "ASM FLAGS" )
#2 lore raw

Hi

Quoted 12 lines

-----Original Message-----
From: Stefan Herbrechtsmeier [mailto:[email protected]]
Sent: Freitag, 17. Juli 2015 12:56
To: Bach, Pascal; [email protected]
Subject: Re: [OE-core] [PATCH] cmake.bbclass: set archiver, linker and ranlib in toolchain.cmake

Am 17.07.2015 um 09:44 schrieb Pascal Bach:

Quoted 4 lines

Setting CMAKE_AR, CMAKE_LINKER and CMAKE_RANLIB correctly in toolchain.cmake is necessary to correctly build -native packages using CMake.

Quoted 7 lines
Quoted 2 lines

The reason is that CMake is not able to find the above utilities by itself because CMAKE_FIND_ROOT_PATH_MODE_PROGRAM is set to

ONLY so we

Quoted 1 line

need to tell it explicitly where to look.

Which version do you use? The master sets CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to BOTH for native packages.

I tested it with 1.7.2. I didn't notice that change in master. So I retested with master and it is working there without modifications.

Quoted 9 lines

If this don't work you could set the
CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN
path (without /bin).

Quoted 5 lines
---
  meta/classes/cmake.bbclass | 8 ++++++++
  1 file changed, 8 insertions(+)
Quoted 11 lines

meta/classes/cmake.bbclass inherit autotools · line 16

Quoted 9 lines
meta/classes/cmake.bbclass +1 -0
index 995ddf1..cae0ad2 100644
@@ -13,6 +13,9 @@ inherit autotools
  # C/C++ Compiler (without cpu arch/tune arguments)
  OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
  OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_AR ?= "`echo ${AR} | sed 's/^\([^ ]*\).*/\1/'`"

This is already set in master.

Just saw this.

Quoted 4 lines

meta/classes/cmake.bbclass inherit autotools · line 18

Quoted 2 lines
meta/classes/cmake.bbclass +2 -0
+OECMAKE_LINKER ?= "`echo ${LD} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_RANLIB ?= "`echo ${RANLIB} | sed 's/^\([^ ]*\).*/\1/'`"

You don't need the sed for ranlib.

I wasn't sure it is needed I just keept it to be on the safe side.

The question is if the two above lines are needed at all. As I wrote above it is now working without them. For consistency reasons one could add them but currently I wouldn't do it.

So I think we can drop this patch.
Thanks for the feedback.

Quoted 26 lines

meta/classes/cmake.bbclass inherit autotools · line 20

Quoted 2 lines
meta/classes/cmake.bbclass +0 -0
  # Compiler flags
  OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}

${CFLAGS}"

meta/classes/cmake.bbclass set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH}

Quoted 1 line
meta/classes/cmake.bbclass +0 -0
@@ -35,6 +38,11 @@ set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH}

)

meta/classes/cmake.bbclass set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH} )

Quoted 6 lines
meta/classes/cmake.bbclass +3 -0
  set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )
  set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )
  set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} )
+# Force the use of cache here otherwise the values will be overridden
+(http://www.cmake.org/Bug/view.php?id=13038)
+set( CMAKE_AR ar CACHE FILEPATH "Archiver" FORCE ) set(

CMAKE_LINKER

meta/classes/cmake.bbclass set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH} · line 46

Quoted 3 lines
meta/classes/cmake.bbclass +3 -0
+ld CACHE FILEPATH "Linker" FORCE ) set( CMAKE_RANLIB ranlib CACHE
+FILEPATH "Ranlib" FORCE )
+

Why you generate OECMAKE_* and don't use them?

Furthermore the CMAKE_* should contain the full path and are generated in the CMakeFindBinUtils.cmake.

meta/classes/cmake.bbclass set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH} · line 47

Quoted 1 line
meta/classes/cmake.bbclass +0 -0
  set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS"

)

meta/classes/cmake.bbclass set( CMAKE_SYSTEM_PROCESSOR ${TARGET_ARCH} · line 48

Quoted 1 line
meta/classes/cmake.bbclass +0 -0
  set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING

"CXXFLAGS" )

Quoted 1 line
  set( CMAKE_ASM_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "ASM

FLAGS" )

#3 lore raw

Am 17.07.2015 um 14:23 schrieb Bach, Pascal:

Quoted 16 lines

Hi

Quoted 14 lines

-----Original Message-----
From: Stefan Herbrechtsmeier [mailto:[email protected]]
Sent: Freitag, 17. Juli 2015 12:56
To: Bach, Pascal; [email protected]
Subject: Re: [OE-core] [PATCH] cmake.bbclass: set archiver, linker and ranlib in toolchain.cmake

Am 17.07.2015 um 09:44 schrieb Pascal Bach:

Quoted 6 lines

Setting CMAKE_AR, CMAKE_LINKER and CMAKE_RANLIB correctly in toolchain.cmake is necessary to correctly build -native packages using CMake.

The reason is that CMake is not able to find the above utilities by itself because CMAKE_FIND_ROOT_PATH_MODE_PROGRAM is set to

Quoted 7 lines
Quoted 5 lines

ONLY so we

Quoted 1 line

need to tell it explicitly where to look.

Which version do you use? The master sets CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to BOTH for native packages.

I tested it with 1.7.2. I didn't notice that change in master. So I retested with master and it is working there without modifications.

Good

Quoted 22 lines
Quoted 9 lines

If this don't work you could set the
CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN
path (without /bin).

Quoted 5 lines
---
   meta/classes/cmake.bbclass | 8 ++++++++
   1 file changed, 8 insertions(+)
Quoted 11 lines

meta/classes/cmake.bbclass inherit autotools · line 16

Quoted 9 lines
meta/classes/cmake.bbclass +1 -0
index 995ddf1..cae0ad2 100644
@@ -13,6 +13,9 @@ inherit autotools
   # C/C++ Compiler (without cpu arch/tune arguments)
   OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
   OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_AR ?= "`echo ${AR} | sed 's/^\([^ ]*\).*/\1/'`"

This is already set in master.

Just saw this.

Quoted 8 lines
Quoted 4 lines

meta/classes/cmake.bbclass inherit autotools · line 18

Quoted 2 lines
meta/classes/cmake.bbclass +2 -0
+OECMAKE_LINKER ?= "`echo ${LD} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_RANLIB ?= "`echo ${RANLIB} | sed 's/^\([^ ]*\).*/\1/'`"

You don't need the sed for ranlib.

I wasn't sure it is needed I just keept it to be on the safe side.

The question is if the two above lines are needed at all. As I wrote above it is now working without them. For consistency reasons one could add them but currently I wouldn't do it.

They aren't needed because they aren't used anywhere.