0

I have an environment script of yocto toolchain which sets all the environmental variables like CC CXX PATH etc.

Basically it has the following lines:

export CC="arm-oe-linux-gnueabi-gcc  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=$SDKTARGETSYSROOT"
export CXX="arm-oe-linux-gnueabi-g++  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=$SDKTARGETSYSROOT"

I sourced this file in my current shell and ran cmake command. Then I get the following error in CMakeError.log

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /home/ramana/9150/toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/ramana/9150/toolchain/sysroots/cortexa8hf-vfp-neon-oe-linux-gnueabi 
Build flags: 
Id flags: 

The output was:
No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /home/ramana/9150/toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/ramana/9150/toolchain/sysroots/cortexa8hf-vfp-neon-oe-linux-gnueabi 
Build flags: 
Id flags: -c

The output was:
No such file or directory

and so on.

If I do ls on that file:

ramana@ramana-VirtualBox:~/9150$ ls -l /home/ramana/9150/toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc
-rwxr-xr-x 1 ramana ramana 862352 Jan 23 17:38 /home/ramana/9150/toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc

so file exists in that path.

Next I tried setting CMAKE_C_COMPILER and CMAKE_CXX_COMPILER in CMakeLists.txt as:

set (CMAKE_C_COMPILER $ENV{CC})
set (CMAKE_CXX_COMPILER $ENV{CXX})

Now I get the same error in CMakeError.log:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: arm-oe-linux-gnueabi-gcc  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/ramana/9150/toolchain/sysroots/cortexa8hf-vfp-neon-oe-linux-gnueabi 
Build flags: 
Id flags: 

The output was:
No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: arm-oe-linux-gnueabi-gcc  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/ramana/9150/toolchain/sysroots/cortexa8hf-vfp-neon-oe-linux-gnueabi 
Build flags: 
Id flags: -c

The output was:
No such file or directory

Then I tried the command line option using

cmake -DCMAKE_C_COMPILER=$CC

Then I get the same error with compiler options missing. So I added double quotes to $CC above. Then I get the same error as in previous two scenarios.

These are recommended options available, but I failed to use these. What am I missing here? Please help. Thanks in advance

Ramana Reddy
  • 369
  • 1
  • 8
  • 28
  • 2
    Have you tried splitting out your compiler and the flags? As in set `CC` etc, but only as the executable and then set the flags as `COMPILE_FLAGS`, an [example](https://stackoverflow.com/questions/11783932/how-do-i-add-a-linker-or-compile-flag-in-a-cmake-file#11797272) – Timothy Brown Jan 24 '19 at 14:54
  • @TimothyBrown well I will try that out. But this makes the CMakeFile dependent on `toolchain` right? I mean, if there is a different `toolchain` I have to change all these in the `CMakeLists.txt` – Ramana Reddy Jan 25 '19 at 04:53
  • Yes. However you can write one or more macros that set those flags based on the toolchain, for example `if(CMAKE__COMPILER_ID MATCHES "GNU") ...`. Known compilers [are](https://cmake.org/cmake/help/v3.0/variable/CMAKE_LANG_COMPILER_ID.html). – Timothy Brown Jan 25 '19 at 16:23

0 Answers0