[CMake] How to determine a ABI version of the arm-linux-gcc?

Yegor Yefremov yegor_sub1 at visionsystems.de
Thu Jan 28 08:31:03 EST 2010


>>>> O.K. Here are some lines of my CMakeLists.txt:
>>>>
>>>> set (CMAKE_C_COMPILER arm-linux-gcc)
>>>> set (CMAKE_STRIP arm-linux-strip)
> 
> Oh, if you do that in CMakeLists.txt this is quite late. You should use a 
> toolchain file as described in the wiki.

I'll try it later.
 
>>>> message (STATUS "ABI ${CMAKE_C_COMPILER_ABI}")
>>>>
>>>> After running cmake I see only ABI as output and CMakeCache.txt doesn't
>>>> contain CMAKE_C_COMPILER_ABI variable at all.
>>> It's in CMakeFiles/CMake*Compiler.cmake.  It works only after the
>>> language is enabled by the project() or enable_language() command.
>>> The compiler must be set before one of these commands runs.
>> O.K. after I defined project language and placed set (CMAKE_C_COMPILER
>> arm-linux-gcc) before project(foo C) I could get the proper compiler ABI.
>> Looking forward for this feature to be included.
> 
> Please test the new attached patch again and let me know if there are issues.

Index: CMakeCompilerABI.h
===================================================================
--- cmake-2.8.0.orig/Modules/CMakeCompilerABI.h	23 Jan 2008 22:53:18 -0000	1.3
+++ cmake-2.8.0/Modules/CMakeCompilerABI.h	25 Jan 2010 17:02:37 -0000
@@ -17,6 +17,24 @@ const char info_sizeof_dptr[] =  {
 # define ABI_ID "ELF N32"
 #elif defined(__sgi) && defined(_ABI64)
 # define ABI_ID "ELF 64"
+/* check for gcc for ARM, may support ARM EABI */
+#elif defined(__GNU__) && defined(__ELF__) && defined(__ARM_EABI__)
+# define ABI_ID "ELF ARMEABI"

are these two statements not doubled?

+#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEL__)
+# define ABI_ID "ELF ARM"
+#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEL__)
+# define ABI_ID "ELF ARM"


+/* Check for the IAR compilers, they also generate ELF files. 
+ * When called with --aeabi, they are EABI compatible, but I think we cannot
+ * test for this here. */
+#elif defined(__ICCARM__)
+# define ABI_ID "ELF ARM"
+/* The IAR AVR linker supports many output formats, also ELF, but I think we 
+ * cannot test for this here. */ 
+#elif defined(__ICCAVR__)
+# define ABI_ID "IAR AVR"
+#elif defined(__ICCAVR32__)
+# define ABI_ID "IAR AVR32"
 #elif defined(__ELF__)
 # define ABI_ID "ELF"
 #endif

Unfortunately this patch is not working for me. But if I exclude defined(__GNU__) then it is the same as previous patch and the proper ABI will be detected, otherwise I get "ELF" as ABI.

Yegor


More information about the CMake mailing list