forked from quarkslab/NFLlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeCompilers.txt
29 lines (26 loc) · 1011 Bytes
/
CMakeCompilers.txt
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
include(CheckCXXCompilerFlag)
# C++11 support
CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
endif()
# optimization flags support
if(CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3")
foreach(FLAG -march=native -mtune=native -funroll-loops)
string(REGEX REPLACE -= _ FLAG_ID ${FLAG})
string(TOUPPER ${FLAG_ID} FLAG_ID)
CHECK_CXX_COMPILER_FLAG(${FLAG} COMPILER_SUPPORTS${FLAG_ID})
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${FLAG}")
endforeach()
else()
add_definitions(-DCHECK_STRICTMOD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()