macro(set_compiler_flags) get_filename_component(COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME_WE) if(COMPILER_NAME STREQUAL ifort) if(WIN32) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-debug:full /check /traceback /nologo") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "/O2 /nologo /Qvec-report0") endif() elseif(APPLE) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-g -warn") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "-O -warn -vec-report0") endif() else() if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-g -warn") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "-O -warn -vec-report0") endif() endif() elseif(COMPILER_NAME STREQUAL g95) if(WIN32) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ftrace=full") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-loops -msse2") endif() elseif(APPLE) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-g -Wall") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "-O") endif() else() if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-g -Wall") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "-O") endif() endif() elseif(COMPILER_NAME STREQUAL gfortran) if(WIN32) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ftrace=full") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-loops -msse2") endif() elseif(APPLE) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-g -Wall -m32") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "-O -m32") endif() else() if(CMAKE_BUILD_TYPE STREQUAL Debug) set(CMAKE_Fortran_FLAGS_DEBUG "-g -Wall") elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_Fortran_FLAGS_RELEASE "-O") endif() endif() endif() endmacro()