上回的CMakeLists.txt里面有一句,if (WIN32)......endif(WIN32);
根据资料,这是判断操作系统是否是Windows;
下面单独看一下;
一个CMakeLists.txt文件如下;
if(WIN32)
# 如果是 Windows
message("当前操作系统为 Windows")
elseif(UNIX AND NOT APPLE)
# 如果是 Linux
message("当前操作系统为 Linux")
else()
message(FATAL_ERROR "不支持的操作系统类型")
endif()
然后运行看一下,如下图;
它有一些输出;
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Proj