判断编译器类型
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
参考资料
原创文章,作者:6024010,如若转载,请注明出处:https://blog.ytso.com/245245.html