forked from BhallaLab/moose-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckCXXCompiler.cmake
56 lines (49 loc) · 1.91 KB
/
CheckCXXCompiler.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
# Compiler check.
# Must support c++14
# If python2 is supported then we can not use c++17.
if(COMPILER_IS_TESTED)
return()
endif()
########################### COMPILER MACROS #####################################
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11 )
CHECK_CXX_COMPILER_FLAG("-Wno-strict-aliasing" COMPILER_WARNS_STRICT_ALIASING )
# Turn warning to error: Not all of the options may be supported on all
# versions of compilers. be careful here.
add_definitions(-Wall
#-Wno-return-type-c-linkage
-Wno-unused-variable
-Wno-unused-function
#-Wno-unused-private-field
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1")
message(FATAL_ERROR "Insufficient gcc version. Minimum requried 5.1")
endif()
add_definitions( -Wno-unused-local-typedefs )
add_definitions( -fmax-errors=5 )
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_definitions( -Wno-unused-local-typedef )
endif()
add_definitions(-fPIC)
if(COMPILER_WARNS_STRICT_ALIASING)
add_definitions( -Wno-strict-aliasing )
endif(COMPILER_WARNS_STRICT_ALIASING)
# Disable some harmless warnings.
CHECK_CXX_COMPILER_FLAG( "-Wno-unused-but-set-variable"
COMPILER_SUPPORT_UNUSED_BUT_SET_VARIABLE_NO_WARN
)
if(COMPILER_SUPPORT_UNUSED_BUT_SET_VARIABLE_NO_WARN)
add_definitions( "-Wno-unused-but-set-variable" )
endif(COMPILER_SUPPORT_UNUSED_BUT_SET_VARIABLE_NO_WARN)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(APPLE)
add_definitions( -mllvm -inline-threshold=1000 )
endif(APPLE)
else(COMPILER_SUPPORTS_CXX11)
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} is too old. \n"
"Please use a compiler which has full c++11 support."
)
endif(COMPILER_SUPPORTS_CXX11)
set(COMPILER_IS_TESTED ON)