-
Notifications
You must be signed in to change notification settings - Fork 2
/
detect_compiler.cmake
31 lines (29 loc) · 1.05 KB
/
detect_compiler.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function(check_compiling_with_clang result_var)
if(NOT DEFINED ${result_var})
string(TOLOWER "${CMAKE_C_COMPILER_ID}" LOWER_CASE_C_COMPILER_ID)
string(TOLOWER "${CMAKE_CXX_COMPILER_ID}" LOWER_CASE_CXX_COMPILER_ID)
if(LOWER_CASE_C_COMPILER_ID MATCHES "clang" AND LOWER_CASE_CXX_COMPILER_ID MATCHES "clang")
set(${result_var} true PARENT_SCOPE)
else()
set(${result_var} false PARENT_SCOPE)
endif()
endif()
endfunction(check_compiling_with_clang)
function(check_compiling_with_gcc result_var)
if(NOT DEFINED ${result_var})
if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(${result_var} true PARENT_SCOPE)
else()
set(${result_var} false PARENT_SCOPE)
endif()
endif()
endfunction(check_compiling_with_gcc)
function(check_compiling_with_msvc result_var)
if(NOT DEFINED ${result_var})
if(CMAKE_C_COMPILER_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(${result_var} true PARENT_SCOPE)
else()
set(${result_var} false PARENT_SCOPE)
endif()
endif()
endfunction(check_compiling_with_msvc)