[CMake] Cross-compiling: Cmake compiler and ABI check don´t work

Schmid Alexander A.Schmid at de.ccv.eu
Fri Feb 18 01:49:44 EST 2011


Hi,

of course, I´d like to have you think further about it, so here you go...

This is the toolchain file I use. 
The specialty about is that I want to use the ARMCC as compiler and an SDK-provided linker tool for linking. 

# this one is important
SET( CMAKE_SYSTEM_NAME Generic )
# this one not so much
SET( CMAKE_SYSTEM_VERSION 1 )

# ---------------------------------------------------------------------------------
# setup local variables used
# ---------------------------------------------------------------------------------

SET( SDK1_ROOT "$ENV{PROJ_ROOT}\\tools\\Sdk1" )
message( STATUS "The SDK1 can be found at ${SDK1_ROOT}" )
SET( SDK1_INCLUDE "${SDK1_ROOT}/include" )
STRING( REPLACE "\\" "/" SDK1_INCLUDE ${SDK1_INCLUDE} )
SET( SDK1_LIB "${SDK1_ROOT}/lib" )
STRING( REPLACE "\\" "/" SDK1_LIB ${SDK1_LIB} )

SET( SDK2_ROOT "$ENV{PROJ_ROOT}\\tools\\Sdk2" )
message( STATUS "The SDK2 can be found at ${SDK2_ROOT}" )
SET( SDK2_INCLUDE "${SDK2_ROOT}/include" )
STRING( REPLACE "\\" "/" SDK2_INCLUDE ${SDK2_INCLUDE} )
SET( SDK2_LIB "${SDK2_ROOT}/lib" )
STRING( REPLACE "\\" "/" SDK2_LIB ${SDK2_LIB} )

SET( RVCT40_BIN "$ENV{RVCT40BIN}" )
message( STATUS "The ARM Tools can be found at ${RVCT40_BIN}" )


# ---------------------------------------------------------------------------------
# setup object file extensions - must be forced to .o for being able to work with compiler
# ---------------------------------------------------------------------------------
SET( CMAKE_C_OUTPUT_EXTENSION .o )
SET( CMAKE_CXX_OUTPUT_EXTENSION .o )
SET( CMAKE_EXECUTABLE_SUFFIX .out )

# search for programs in the build host directories
SET( CMAKE_FIND_ROOT_PATH $SDK1_ROOT )
SET( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
# for libraries and headers in the target directories
SET( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
SET( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )


# ---------------------------------------------------------------------------------
# setup compiler and linker flags
# ---------------------------------------------------------------------------------
SET( ARMCC_SPECIAL_FLAGS "-Ono_memcpy --library_interface=aeabi_clib --no_unaligned_access -Ono_tree_sequencing --thumb -c --cpu ARM1136J-S --bi -J\"${SDK1_INCLUDE}\" " )

# sets the --cpu ARM1136J-S switch on the ARMCC
SET( SDK1_LINKER_FLAGS "-p" ) 

IF( COMPILER_ADD_DEBUGGING_SYMBOLS )
    	SET( SDK1_LINKER_FLAGS "${SDK1_LINKER_FLAGS} -g -map" )
	SET( CC_FLAGS "${CC_FLAGS} -g" )
ELSE( COMPILER_ADD_DEBUGGING_SYMBOLS )
	SET( CC_FLAGS "${CC_FLAGS} -DNDEBUG" )
	SET( SDK1_LINKER_FLAGS "${SDK1_LINKER_FLAGS} -DNDEBUG")
ENDIF( COMPILER_ADD_DEBUGGING_SYMBOLS )

IF( COMPILER_OPTIMIZE_FOR_SIZE )
	SET ( CC_FLAGS "${CC_FLAGS} -Ospace" )
	SET ( SDK1_LINKER_FLAGS "${SDK1_LINKER_FLAGS} -armcc,-Ospace" )
ENDIF( COMPILER_OPTIMIZE_FOR_SIZE )

IF( COMPILER_OPTIMIZE_FOR_SPEED )
	SET ( CC_FLAGS "${CC_FLAGS} -O3,-Otime" )
	SET ( SDK1_LINKER_FLAGS "${SDK1_LINKER_FLAGS} -armcc,-O3,-Otime" )
ENDIF( COMPILER_OPTIMIZE_FOR_SPEED )




# ---------------------------------------------------------------------------------
# setup compilers and flags
# ---------------------------------------------------------------------------------
# Compiler must have forward slashes in its path
STRING( REPLACE "\\" "/" ARMCC_ROOT ${RVCT40_BIN} )
SET( CMAKE_C_COMPILER   "${ARMCC_ROOT}/armcc.exe" )
SET( CMAKE_CXX_COMPILER "${ARMCC_ROOT}/armcc.exe" )
# Linker must have escaped back slashes in its path
SET( SDK1_LINKER "${SDK1_ROOT}\\bin\\sdk1linker.exe" )

# specify the compile command
SET( CMAKE_C_FLAGS   "${CC_FLAGS} -DLOGSYS_FLAG -DLOGSYS_NEW_API_STYLE -I\"${SDK2_INCLUDE}\" " )
# The warning 830 is suppressed, because the arm compiler complains that there is no corresponding "delete" for the "new( size_t, void*)".
# This is true on one hand, but on the other the standard defines the API for new and delete just as it is implemented in the <new> header.
# See e.g. http://www.cplusplus.com/reference/std/new/operator%20new/ and http://www.cplusplus.com/reference/std/new/operator%20delete/
SET( CMAKE_CXX_FLAGS "${CC_FLAGS} -D__STDC_LIMIT_MACROS -DLOGSYS_FLAG -DLOGSYS_NEW_API_STYLE --diag_suppress=1300,830 --cpp --exceptions -I\"${SDK2_INCLUDE}\" " )

# This here is needed to manage to get the ARMCC and the SDK Linker (which wraps armcc) working for the CMAKe startup tests.
# The next two lines set the "low-level" compiler call to accept all those flags defined as CXX_INTERNAL_FLAGS. This means that
# each file will be compiled using these flags"

SET( CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> ${ARMCC_SPECIAL_FLAGS} <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
SET( CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> ${ARMCC_SPECIAL_FLAGS} <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")

# specify the linker and its options for creating static libraries:
SET( CMAKE_AR_FLAGS "${SDK1_LINKER_FLAGS} -o <TARGET> <OBJECTS>")
SET( CMAKE_CXX_CREATE_STATIC_LIBRARY "${SDK1_LINKER} ${CMAKE_AR_FLAGS}")
SET( CMAKE_C_CREATE_STATIC_LIBRARY "${SDK1_LINKER} ${CMAKE_AR_FLAGS}")

# specify the linker for linking applications
SET( SDK1_HDRTOOL_FLAGS "-hdrtool,-l,ceif.lib=N:/ceif.lib,-l,net.lib=N:/net.lib,-l,elog.lib=N:/elog.lib" )
SET( SDK1_LINKER_FLAGS_APP "${SDK1_LINKER_FLAGS} -armlink,-userlibpath=\"${SDK2_LIB}\",ceif.o,svc_net.o,elog.o -s 500000 -h 2000000 -o <TARGET>.out <OBJECTS> <LINK_LIBRARIES> " )
SET( CMAKE_C_LINK_EXECUTABLE   "${SDK1_LINKER} ${SDK1_LINKER_FLAGS_APP} ${SDK1_HDRTOOL_FLAGS}" )
SET( CMAKE_CXX_LINK_EXECUTABLE "${SDK1_LINKER} ${SDK1_LINKER_FLAGS_APP} ${SDK1_HDRTOOL_FLAGS}" )

Beste Grüße / Best regards
 
Alexander Schmid
Software Development 
------------------------------------------------------------------------
CCV Deutschland GmbH        Fon:     +49 (8752) 864 0
Gewerbering 1                       Fax:     +49 (8752) 864 100
84072 Au i.d. Hallertau           www.ccv-deutschland.de
                                            www.ccv.eu
A.Schmid at de.ccv.eu			

HRB 177321 - Registergericht München                                                                                          
Geschäftsführung:                                                                             
Reinhard Blum (Vorsitzender)                                                                                
Günther Froschermeier                                                                             
                                             
-----Ursprüngliche Nachricht-----
Von: Alexander Neundorf [mailto:a.neundorf-work at gmx.net] 
Gesendet: Donnerstag, 17. Februar 2011 18:05
An: Schmid Alexander
Cc: cmake at cmake.org
Betreff: Re: AW: [CMake] Cross-compiling: Cmake compiler and ABI check don´t work

On Thursday 17 February 2011, Schmid Alexander wrote:
> Hi,
>
> is it possible that the ABI check won´t work anyway for cross-compiling
> scenarios?

It should.

> Anyway, I don´t think that the toolchain file is messed up, because the
> first part of CMake´s detection flow uses the settings I specified there.
> But the second part doesn´t.....


I won't think further about it without seeing the file. If there are secrets 
in it, please replace them with "SecretStuff" or something.

Alex


More information about the CMake mailing list