I am trying to compile for Linux (with Generator Eclipse CDT4 - Ninja) but when I am checking for ${CMAKE_SYSTEM_NAME} in CMakeLists.txt, all I get is blank.
In which scenarios is using this variable valid?
Using cmake 3.02 from Debian Testing.
02 Answers
You need to place CMAKE_SYSTEM_NAME after project command:
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
project(Foo)
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")Result:
CMAKE_SYSTEM_NAME:
-- The C compiler identification is GNU 4.9.1
...
-- Detecting CXX compiler ABI info - done
CMAKE_SYSTEM_NAME: Linux I have the same issue, and work it out.
All i want to do is cross compile on Linux server with aarch64-himix100-linux, and compile with the default toolchain on Darwin system.
I use CMAKE_HOST_SYSTEM_NAME instead of CMAKE_SYSTEM_NAME.
The value of CMAKE_HOST_SYSTEM_NAME is equal to the output of uname -s.
For example,
cmake_minimum_required(VERSION 3.8)
if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/Toolchain-aarch64-himix100-linux.cmake")
endif ()
project(phoenix) 1