How do I determine the host operating system when using CMAKE?

I am using a custom toolchain file to develop an embedded system. CMAKE_SYSTEM_NAME is set to “Generic”, so variables such as WIN32, UNIX cannot be used to check the operating system of the configuration item. But I need Configure the project in different ways on different OS.

How to determine the operating system for cmake?

check variables that describe the system.

Special interest The ones are the CMAKE_HOST_SYSTEM variable and its relatives. Unfortunately, the exact behavior of these largely depends on the platform and toolchain used. If you are not getting a reasonable value for your environment, please consider writing to the CMake mailing list for Please provide better support for your platform.

I am using a custom toolchain file to develop an embedded system. CMAKE_SYSTEM_NAME is set to “Generic”, so WIN32, UNIX Such variables cannot be used to check the operating system of the configuration project. But I need to configure the project in different ways on different OS.

How to determine the operating system of cmake?

Check the variables that describe the system.

Of particular interest is the CMAKE_HOST_SYSTEM variable and its relatives. Unfortunately, The exact behavior of these largely depends on the platform and toolchain used. If you are not getting a reasonable value for your environment, please consider writing to the CMake mailing list to request better support for your platform. /p>

Leave a Comment

Your email address will not be published.