How to determine host operating system when cross compiling with CMake?

I am developing for an embedded system using a custom toolchain file. CMAKE_SYSTEM_NAME is set to "Generic", so the variables are WIN32, UNIX, etc. Cannot be used to check the operating system on which the project is configured. But I need to configure the project differently on different OSs.

How to determine the operating system on which cmake is running?

+6
source share
1 answer

Check the variables that describe the system .

Of particular interest is the variable CMAKE_HOST_SYSTEM and its relatives. Unfortunately, their exact behavior largely depends on the platform and toolchain used. If you don’t get reasonable values ​​for your environment, consider writing a CMake mailing list to request the best support for your platform.

+3
source

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


All Articles