-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_compiler.cmake
71 lines (50 loc) · 1.73 KB
/
config_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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# determine the compiler
# for cross compilation, the target platform is required to be known
#
# the values here can be initialized using a toolchain file
set( MOTOR_COMPILER_CONFIGURED FALSE )
# just set the cxx version to 11 for now
# it need to be used in the target property CXX_STANDARD
set( MOTOR_CXX_STANDARD 17 )
# Microsoft compiler
set( MOTOR_COMPILER_MSC OFF )
set( MOTOR_COMPILER_MSC_14 OFF ) # vs 2015
set( MOTOR_COMPILER_MSC_15 OFF ) # vs 2017
set( MOTOR_COMPILER_MSC_16 OFF ) # vs 2019
set( MOTOR_COMPILER_MSC_17 OFF ) # vs 2022
# Gnu compiler (GCC, GCC-C++)
set( MOTOR_COMPILER_GNU OFF )
set( MOTOR_COMPILER_CLANG OFF )
if( MSVC_IDE OR MSVC )
set( MOTOR_COMPILER_MSC ON )
if( MSVC_VERSION EQUAL 1900 )
set( MOTOR_COMPILER_MSC_14 on )
set( MOTOR_CXX_STANDARD 11 )
elseif( MSVC_VERSION GREATER 1909 AND MSVC_VERSION LESS 1920 )
set( MOTOR_COMPILER_MSC_15 on )
set( MOTOR_CXX_STANDARD 14 )
elseif( MSVC_VERSION GREATER 1919 AND MSVC_VERSION LESS 1930 )
set( MOTOR_COMPILER_MSC_16 on )
set( MOTOR_CXX_STANDARD 17 )
elseif( MSVC_VERSION GREATER 1929 AND MSVC_VERSION LESS 1938 )
set( MOTOR_COMPILER_MSC_17 on )
set( MOTOR_CXX_STANDARD 17 )
else()
message( FATAL "MSVC Compiler not yet supported" )
endif()
elseif( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
set( MOTOR_COMPILER_GNU ON )
else()
message( FATAL_ERROR "Unsupported compiler")
endif()
#
# Print Info
#
if( MOTOR_COMPILER_MSC )
message( STATUS "[compiler] : Microsoft Compiler Suite" )
elseif( MOTOR_COMPILER_GNU )
message( STATUS "[compiler] : GNU Compiler Suite" )
endif()
set( CMAKE_CXX_STANDARD ${MOTOR_CXX_STANDARD} )
set( MOTOR_COMPILER_CONFIGURED TRUE )