-
Notifications
You must be signed in to change notification settings - Fork 23
/
CMakeCompilers.txt
39 lines (35 loc) · 1.3 KB
/
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
29
30
31
32
33
34
35
36
37
38
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()
# Use openmp
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_EXE_LINKER_FLAGS "-fopenmp")
# optimization flags support
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DCHECK_STRICTMOD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
message(STATUS "Building DEBUG version")
else()
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3")
message(STATUS "Building RELEASE version")
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()
# For OSX use clang
if(APPLE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpmath=sse -Wa,-q")
endif()
endif()