diff mbox

[1/1] pkg-cmake.mk: Set CMAKE_SYSTEM_PROCESSOR.

Message ID 1416067219-30211-1-git-send-email-volker.krause@kdab.com
State Superseded
Headers show

Commit Message

Volker Krause Nov. 15, 2014, 4 p.m. UTC
This is rarely needed by packages, but convenient to have when it is.

Signed-off-by: Volker Krause <volker.krause@kdab.com>
---
 package/pkg-cmake.mk                | 1 +
 support/misc/toolchainfile.cmake.in | 1 +
 2 files changed, 2 insertions(+)

Comments

Samuel Martin Nov. 15, 2014, 5:26 p.m. UTC | #1
Hi Volker,

On Sat, Nov 15, 2014 at 5:00 PM, Volker Krause <volker.krause@kdab.com> wrote:
> This is rarely needed by packages, but convenient to have when it is.
>
> Signed-off-by: Volker Krause <volker.krause@kdab.com>
> ---
>  package/pkg-cmake.mk                | 1 +
>  support/misc/toolchainfile.cmake.in | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
> index c8735ef..57a6d29 100644
> --- a/package/pkg-cmake.mk
> +++ b/package/pkg-cmake.mk
> @@ -193,5 +193,6 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
>                 -e 's:@@TARGET_LDFLAGS@@:$(call qstrip,$(TARGET_LDFLAGS)):' \
>                 -e 's:@@TARGET_CC_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CC_NOCCACHE))):' \
>                 -e 's:@@TARGET_CXX_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CXX_NOCCACHE))):' \
> +               -e 's:@@BR2_ARCH@@:$(BR2_ARCH):' \

You should qstrip the variable here.

>                 $(TOPDIR)/support/misc/toolchainfile.cmake.in \
>                 > $@
> diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
> index 4ca3d35..86ef0b4 100644
> --- a/support/misc/toolchainfile.cmake.in
> +++ b/support/misc/toolchainfile.cmake.in
> @@ -11,6 +11,7 @@
>  string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST_DIR})
>
>  set(CMAKE_SYSTEM_NAME Linux)
> +set(CMAKE_SYSTEM_PROCESSOR @@BR2_ARCH@@)
>
>  set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS")
>  set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS")
> --
> 1.8.4.5
>
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

Otherwise, it looks good.

Regards,
Romain Naour Nov. 15, 2014, 5:52 p.m. UTC | #2
Hi Volker,

Le 15/11/2014 18:26, Samuel Martin a écrit :
> Hi Volker,
> 
> On Sat, Nov 15, 2014 at 5:00 PM, Volker Krause <volker.krause@kdab.com> wrote:
>> This is rarely needed by packages, but convenient to have when it is.
>>

There is only one package (openpowerlink) that set this variable in buildroot
and the expected value is "x86" or "x86_64".

Are you sure that the BR2_ARCH can be used by other packages that need
CMAKE_SYSTEM_PROCESSOR ?
If so, I can send a patch for openpowerlink to fix that.

Best regards,
Romain Naour
Samuel Martin Nov. 15, 2014, 6:20 p.m. UTC | #3
Romain, Volker,

On Sat, Nov 15, 2014 at 6:52 PM, Romain Naour <romain.naour@openwide.fr> wrote:
> Hi Volker,
>
> Le 15/11/2014 18:26, Samuel Martin a écrit :
>> Hi Volker,
>>
>> On Sat, Nov 15, 2014 at 5:00 PM, Volker Krause <volker.krause@kdab.com> wrote:
>>> This is rarely needed by packages, but convenient to have when it is.
>>>
>
> There is only one package (openpowerlink) that set this variable in buildroot
> and the expected value is "x86" or "x86_64".

Hmm... this is in the openpowerlink source?
I think it'd better do (to be more robust):
---
string(REGEX REPLACE "i*86" "x86" CMAKE_SYSTEM_PROCESSOR
${CMAKE_SYSTEM_PROCESSOR})
---
But that's another story ;-)

>
> Are you sure that the BR2_ARCH can be used by other packages that need
> CMAKE_SYSTEM_PROCESSOR ?

According to CMake doc [1], CMAKE_SYSTEM_PROCESSOR is set to the
output of the command "uname -p" (in fact it is the output of "uname
-m").
This is only true for native compilation.

In the case of cross-compilation, the CMake code does not set anything
[2], it just expects the CMAKE_SYSTEM_* variables to be set in the
toolchain file.

> If so, I can send a patch for openpowerlink to fix that.
>
> Best regards,
> Romain Naour

Regards,


[1] http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_SYSTEM_PROCESSOR.html
[2] http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakeDetermineSystem.cmake;hb=HEAD#l110
Bernd Kuhls Nov. 16, 2014, 5:33 a.m. UTC | #4
Volker Krause <volker.krause@kdab.com> wrote in 
news:1416067219-30211-1-git-send-email-volker.krause@kdab.com:

> This is rarely needed by packages, but convenient to have when it is.

Hi,

the x265 package (patch in patchworks: 
http://patchwork.ozlabs.org/patch/408501/) also needs CMAKE_SYSTEM_PROCESSOR.

Regards, Bernd
Volker Krause Nov. 16, 2014, 11:25 a.m. UTC | #5
Hi,

On Saturday 15 November 2014 19:20:49 Samuel Martin wrote:
> On Sat, Nov 15, 2014 at 6:52 PM, Romain Naour <romain.naour@openwide.fr> 
wrote:
> > Le 15/11/2014 18:26, Samuel Martin a écrit :
> >> On Sat, Nov 15, 2014 at 5:00 PM, Volker Krause <volker.krause@kdab.com> 
wrote:
> >>> This is rarely needed by packages, but convenient to have when it is.
> > 
> > There is only one package (openpowerlink) that set this variable in
> > buildroot and the expected value is "x86" or "x86_64".

My use-case is packaging GammaRay (https://github.com/KDAB/GammaRay), which 
relies on CMAKE_SYSTEM_PROCESSOR. Setting it via the cmake command line is of 
course possible, but that didn't look like the "clean" solution.

> Hmm... this is in the openpowerlink source?
> I think it'd better do (to be more robust):
> ---
> string(REGEX REPLACE "i*86" "x86" CMAKE_SYSTEM_PROCESSOR
> ${CMAKE_SYSTEM_PROCESSOR})
> ---
> But that's another story ;-)

Right, the usual value of CMAKE_SYSTEM_PROCESSOR for x86 32bit seems to be far 
from well defined. "i*86" is the most common one I've seen on Linux, so 
BR2_ARCH should be fine there in general.

> > Are you sure that the BR2_ARCH can be used by other packages that need
> > CMAKE_SYSTEM_PROCESSOR ?
> 
> According to CMake doc [1], CMAKE_SYSTEM_PROCESSOR is set to the
> output of the command "uname -p" (in fact it is the output of "uname
> -m").
> This is only true for native compilation.
> 
> In the case of cross-compilation, the CMake code does not set anything
> [2], it just expects the CMAKE_SYSTEM_* variables to be set in the
> toolchain file.

I'll submit an updated patch that adds qstrip, and that sets the correct arm 
variant as shown in the x265 patch that Bernd mentioned.

regards,
Volker
Romain Naour Nov. 22, 2014, 12:14 a.m. UTC | #6
Hi Samuel, Volker,

Le 15/11/2014 19:20, Samuel Martin a écrit :
> Romain, Volker,
> 
> On Sat, Nov 15, 2014 at 6:52 PM, Romain Naour <romain.naour@openwide.fr> wrote:
>> Hi Volker,
>>
>> Le 15/11/2014 18:26, Samuel Martin a écrit :
>>> Hi Volker,
>>>
>>> On Sat, Nov 15, 2014 at 5:00 PM, Volker Krause <volker.krause@kdab.com> wrote:
>>>> This is rarely needed by packages, but convenient to have when it is.
>>>>
>>
>> There is only one package (openpowerlink) that set this variable in buildroot
>> and the expected value is "x86" or "x86_64".
> 
> Hmm... this is in the openpowerlink source?
> I think it'd better do (to be more robust):
> ---
> string(REGEX REPLACE "i*86" "x86" CMAKE_SYSTEM_PROCESSOR
> ${CMAKE_SYSTEM_PROCESSOR})
> ---
> But that's another story ;-)

I used "if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")" instead, because the meaning of
* is not the same as in shell. I had "i6x86"...

I found "^i.86$" in cmake sources:
http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/FindJNI.cmake;h=3dcb0d0aaf019a69766b26db36ddbdab6aee3fa7;hb=HEAD#l46

I send a patch to fix that in openpowerlink sources:
http://patchwork.ozlabs.org/patch/413219/

Best regards,
Samuel Martin Nov. 22, 2014, 9:19 a.m. UTC | #7
On Sat, Nov 22, 2014 at 1:14 AM, Romain Naour <romain.naour@openwide.fr> wrote:
> Hi Samuel, Volker,
>
> Le 15/11/2014 19:20, Samuel Martin a écrit :
>> Romain, Volker,
>>
>> On Sat, Nov 15, 2014 at 6:52 PM, Romain Naour <romain.naour@openwide.fr> wrote:
>>> Hi Volker,
>>>
>>> Le 15/11/2014 18:26, Samuel Martin a écrit :
>>>> Hi Volker,
>>>>
>>>> On Sat, Nov 15, 2014 at 5:00 PM, Volker Krause <volker.krause@kdab.com> wrote:
>>>>> This is rarely needed by packages, but convenient to have when it is.
>>>>>
>>>
>>> There is only one package (openpowerlink) that set this variable in buildroot
>>> and the expected value is "x86" or "x86_64".
>>
>> Hmm... this is in the openpowerlink source?
>> I think it'd better do (to be more robust):
>> ---
>> string(REGEX REPLACE "i*86" "x86" CMAKE_SYSTEM_PROCESSOR
>> ${CMAKE_SYSTEM_PROCESSOR})
>> ---
>> But that's another story ;-)
>
> I used "if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")" instead, because the meaning of
> * is not the same as in shell. I had "i6x86"...

Good catch!

>
> I found "^i.86$" in cmake sources:
> http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/FindJNI.cmake;h=3dcb0d0aaf019a69766b26db36ddbdab6aee3fa7;hb=HEAD#l46
>
> I send a patch to fix that in openpowerlink sources:
> http://patchwork.ozlabs.org/patch/413219/
>
> Best regards,
> --
> Romain Naour
>
> OPEN WIDE Ingénierie - Paris
> 23/25, rue Daviel| 75013 PARIS
> http://ingenierie.openwide.fr
>
> Le blog des technologies libres et embarquées :
> http://www.linuxembedded.fr
diff mbox

Patch

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index c8735ef..57a6d29 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -193,5 +193,6 @@  $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
 		-e 's:@@TARGET_LDFLAGS@@:$(call qstrip,$(TARGET_LDFLAGS)):' \
 		-e 's:@@TARGET_CC_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CC_NOCCACHE))):' \
 		-e 's:@@TARGET_CXX_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CXX_NOCCACHE))):' \
+		-e 's:@@BR2_ARCH@@:$(BR2_ARCH):' \
 		$(TOPDIR)/support/misc/toolchainfile.cmake.in \
 		> $@
diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index 4ca3d35..86ef0b4 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -11,6 +11,7 @@ 
 string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST_DIR})
 
 set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR @@BR2_ARCH@@)
 
 set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS")
 set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS")