C++学习(四零九)CMAKE_SYSTEM_NAME确定操作系统类型_hankern的专栏-CSDN博客The name of the operating system for which CMake is to build. See the CMAKE_SYSTEM_VERSION variable for the OS version.Note that CMAKE_SYSTEM_NAME is not set to anything by default when running in script mode, since it's not building anything.System ..https://blog.csdn.net/hankern/article/details/121173971
# -----------------------------------------------------------------------------
# O/S Detection
# these are defined in common.h too
SET(LINUX False)
SET(FREEBSD False)
SET(MACOS False)
# Detect the operating system
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(TARGET_OS_NAME "macos")
SET(TARGET_OS 3)
SET(MACOS True)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
SET(TARGET_OS_NAME "freebsd")
SET(TARGET_OS 2)
SET(FREEBSD True)
ELSE()
SET(TARGET_OS_NAME "linux")
SET(TARGET_OS 1)
SET(LINUX True)
ENDIF()
# show the operating system on the console
message(STATUS "operating system: ${TARGET_OS_NAME} (TARGET_OS=${TARGET_OS})")



