判断编译器类型
1. cmake命令是不区分大小写的,但是变量区分。
2. 判断编译类型:
CMakeLists.txt 文件内容如下:
cmake_minimum_required (VERSION 3.12.2)
project (list_cmd_test)
message("${CMAKE_CXX_COMPILER_ID}")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
message("Clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("GNU")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message("Intel")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message("MSVC")
endif()
GNU
GNU
输出:
GNU
GNU
GNU GNU