123456789101112131415161718192021222324252627282930313233343536373839 |
- 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()
|