[CMake] Problem using CMake for cross compiling for linux

Magnus Therning magnus at therning.org
Thu Nov 28 17:04:48 EST 2013


On Thu, Nov 28, 2013 at 04:05:18PM +0100, Thomas Baag wrote:
> Hi folks,
> 
> i'm trying to cross compile a simple hello world on Scientific Linux 6.4 
> (amd64) using cmake version 2.8.4 and arm-none-eabi-gcc 4.8.1. I've 
> encountered the well known "-rdynamic" problem[1], but couldn't manage to 
> apply a nice workaround.
> 
> I DONT want to disable simple compiler checks. The problem seems to be in the 
> "__linux_compiler_gnu" macro in "Modules/Platform/Linux-GNU.cmake".
> 
> Until now i tried 
> SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
> SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
> before and after "PROJECT(...)", but it didn't work.
> After that, I added this on top of my CMakeList.txt:
> SET(__LINUX_COMPILER_GNU 1)
> MACRO(__linux_compiler_gnu lang)
>  SET(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "")
> ENDMACRO()
> But it also didnt work.
> 
> Now i'm somehow out of ideas. Could anyone pls help?
> 
> 
> Greetings
> Thomas
> 
> [1] http://www.cmake.org/Bug/view.php?id=9985
> 
> 
> ================
> # Minimal CMakeList.txt:
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
> 
> SET(__LINUX_COMPILER_GNU 1)
> MACRO(__linux_compiler_gnu lang)
>  SET(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "")
> ENDMACRO()
> 
> PROJECT(Build-Example)
> 
> ================
> # Minimal toolchain file:
> SET(CMAKE_SYSTEM_NAME Linux)
> SET(CMAKE_SYSTEM_PROCESSOR "armv7")
> SET(CMAKE_C_COMPILER arm-none-eabi-gcc)

The only way I found around this was

    set(CMAKE_SYSTEM_NAME Generic )

but I think that is exactly what you want to avoid given your comment
about "I DONT want to disable simple compiler checks."

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4 
email: magnus at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus

Unix is the answer, but only if you phrase the question very
carefully.
     -- Unknown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20131128/41a28e62/attachment.pgp>


More information about the CMake mailing list