Cross compilation - getting the target CPU and version

I cross compile for VxWorks using cmake. When I start cmake, for the first time I have to provide information about the compiler, the target OS, etc.

In the cross-compilation dialog box, three target system settings are set:

  • operating system
  • Version
  • CPU

(followed by a compiler, etc.)

While I can get the first, using CMAKE_SYSTEM_NAME , I can not get the version and processor. Both return an empty string.

Here is an example:

 MESSAGE("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") MESSAGE("CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}") 

Output:

 CMAKE_SYSTEM_PROCESSOR: CMAKE_SYSTEM_VERSION: 

My Cmake Version 2.8.10.2, and the target OS is VxWorks (if it matters, the compiler is WindRiver GNU).

How can I get the version and processor that I installed at the beginning? Or is this not possible if I cross-compile an OS that is unknown to cmake?

(Btw. Compilation is working fine)

+4
source share
1 answer

It seems so far this is not possible. I get blank lines all the time.

However, there is a working solution, and I assume this is the best way:

Before:

I specified the cross-compilation options (compiler and target system, see the question), then it starts certain parts of VxWorks in the CMake list (marked with if( VxWorks ) to ensure that it will not run when using other systems).

Now (solution):

I wrote toolchain files for both the platform for VxWorks and the required processors.

Minuses:

  • I need to write additional files:
    • Tool file
    • Platform File for VxWorks
    • Other platform files for each Processor (and processor type, Gnu, and Diab)

Pros:

  • CMake list is now much cleaner
  • Separate project settings and goals
  • Separate system and processor settings - it is easy to add new processors very clearly, but save system settings
  • I write some settings in the toolchain file and system / processor settings related to CMake boot.
  • ...
0
source

Source: https://habr.com/ru/post/1480782/


All Articles