2013-07-17 19:24:07 +02:00
# Copyright Olivier Parcollet 2012
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
#
# Compilers are sorted by group of interoperability
# group 1 : fully compliant C++11 compiler
# gcc 4.8.1 and higher, clang >= 3.3
# group 1 : older gcc, ok with workaround
# group 2 : Intel 14.0 : almost C++11, but with Intel workaround
# group 3 : Intel 13.0 : messy compiler...
# group 0 : other
if ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" )
EXECUTE_PROCESS ( COMMAND ${ CMAKE_CXX_COMPILER } --version
O U T P U T _ V A R I A B L E _ c o m p i l e r _ o u t p u t R E S U L T _ V A R I A B L E r e t u r n c o d e O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
2013-10-01 22:56:11 +02:00
set ( compiler_version_min "4.8.1" )
2013-07-17 19:24:07 +02:00
set ( compiler_name "gcc" )
string ( REGEX REPLACE ".*([2-5]\\.[0-9]\\.[0-9]).*" "\\1" compiler_version ${ _compiler_output } )
2014-07-02 21:44:51 +02:00
#if(NOT compiler_version VERSION_LESS "4.9.0")
# set (compiler_is_c14 ON)
#endif()
2013-07-19 13:25:31 +02:00
2013-07-17 19:24:07 +02:00
elseif ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
EXECUTE_PROCESS ( COMMAND ${ CMAKE_CXX_COMPILER } --version
O U T P U T _ V A R I A B L E _ c o m p i l e r _ o u t p u t R E S U L T _ V A R I A B L E r e t u r n c o d e O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
set ( CMAKE_COMPILER_IS_CLANG TRUE )
set ( compiler_name "clang" )
IF ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
# Apple which does not has the official clang version number ...
string ( REGEX REPLACE ".*LLVM ([2-5]\\.[0-9]).*" "\\1" compiler_version ${ _compiler_output } )
2014-01-09 19:42:01 +01:00
# but this does not work if clang is not from Apple (compiled manually on the mac)
if ( NOT ${ compiler_version } )
string ( REGEX REPLACE ".* version ([2-5]\\.[0-9]).*" "\\1" compiler_version ${ _compiler_output } )
endif ( )
2013-07-17 19:24:07 +02:00
else ( )
2014-01-09 19:42:01 +01:00
string ( REGEX REPLACE ".* version ([2-5]\\.[0-9]).*" "\\1" compiler_version ${ _compiler_output } )
2013-07-17 19:24:07 +02:00
endif ( )
2013-12-10 11:53:58 +01:00
#message(STATUS "Compiler --version output = ${_compiler_output}")
message ( STATUS "Compiler version = ${compiler_version}" )
2013-07-17 19:24:07 +02:00
set ( compiler_version_min "3.2" )
2013-12-10 11:53:58 +01:00
# does not always work ... To be fixed when clang 3.4 officially released and on OS X.
2014-07-02 21:44:51 +02:00
#if(NOT compiler_version VERSION_LESS "3.4")
# set (compiler_is_c14 ON)
#endif()
2013-12-10 11:53:58 +01:00
2013-07-17 19:24:07 +02:00
elseif ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" )
EXECUTE_PROCESS ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpversion
O U T P U T _ V A R I A B L E c o m p i l e r _ v e r s i o n R E S U L T _ V A R I A B L E r e t u r n c o d e O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
set ( CMAKE_COMPILER_IS_ICC TRUE )
2013-10-01 22:56:11 +02:00
set ( compiler_version_min "14.0.0" )
2013-07-17 19:24:07 +02:00
set ( compiler_name "Intel icc" )
#string(REGEX REPLACE "[^0-9]*([0-9]+\\.[0-9]\\.[0-9]).*" "\\1" compiler_version ${_compiler_output})
else ( )
set ( compiler_version_min "0.0" )
set ( compiler_group 0 )
set ( line_of_star "\n************************** WARNING ************************************\n" )
MESSAGE ( WARNING "${line_of_star} Compiler not recognized by TRIQS : TRIQS may compile .. or not ${line_of_star}" )
#message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ( )
MESSAGE ( STATUS "Compiler is ${compiler_name} with version ${compiler_version}" )
# Check version
if ( compiler_version VERSION_LESS ${ compiler_version_min } )
set ( line_of_star "\n************************** FATAL ERROR ************************************\n" )
2014-01-09 19:27:55 +01:00
MESSAGE ( FATAL_ERROR "${line_of_star}You are using the ${compiler_name} compiler but your compiler is too old :\n TRIQS requires version >= ${compiler_version_min} while you have ${compiler_version}\n ${line_of_star}" )
2013-07-17 19:24:07 +02:00
endif ( compiler_version VERSION_LESS ${ compiler_version_min } )
# Now add some definitions ...
# on OS X : for clang, add the infamous -stdlib=libc++
IF ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
if ( CMAKE_COMPILER_IS_CLANG )
2014-10-18 11:36:26 +02:00
#set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ ")
set ( TRIQS_CXX_DEFINITIONS ${ TRIQS_CXX_DEFINITIONS } " -stdlib=libc++ -Wno-deprecated-writable-strings " )
2013-07-17 19:24:07 +02:00
MESSAGE ( STATUS "Adding compilation flags -stdlib=libc++ " )
2014-10-18 11:36:26 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ " )
2013-07-17 19:24:07 +02:00
else ( CMAKE_COMPILER_IS_CLANG )
MESSAGE ( WARNING "${line_of_star}You are on Os X but your are not using clang. This is NOT recommended...${line_of_star}" )
endif ( CMAKE_COMPILER_IS_CLANG )
ENDIF ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
# for icc, add the very infamous flags or calculation of boost::math bessel function are wrong !!
# tested on boost 1.53
IF ( CMAKE_COMPILER_IS_ICC )
2013-10-02 21:25:32 +02:00
set ( TRIQS_WORKAROUND_INTEL_COMPILER_14_BUGS 1 )
2013-07-25 23:08:44 +02:00
set ( BOOST_MATH_DISABLE_STD_FPCLASSIFY 1 )
#set(TRIQS_CXX_DEFINITIONS ${TRIQS_CXX_DEFINITIONS} -DTRIQS_WORKAROUND_INTEL_COMPILER_BUGS -DBOOST_MATH_DISABLE_STD_FPCLASSIFY)
2013-07-17 19:24:07 +02:00
#add_definitions( -DTRIQS_WORKAROUND_INTEL_COMPILER_BUGS -DBOOST_MATH_DISABLE_STD_FPCLASSIFY)
MESSAGE ( STATUS " Adding compilation flags -DTRIQS_WORKAROUND_INTEL_COMPILER_BUGS -DBOOST_MATH_DISABLE_STD_FPCLASSIFY" )
ENDIF ( CMAKE_COMPILER_IS_ICC )