From 8ee65e2aac8728c6dcd4b3800e3736dc543bb172 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 13 Jun 2017 07:31:21 -0500 Subject: [PATCH] Separate out compile flags for C and check for Clang --- CMakeLists.txt | 56 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3d27b3db..b7cc1dde3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,59 +110,46 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) # GCC compiler options list(APPEND f90flags -cpp -std=f2008ts -fbacktrace -O2) - list(APPEND cflags -cpp -std=c99 -O2) if(debug) list(REMOVE_ITEM f90flags -O2) - list(REMOVE_ITEM cflags -O2) list(APPEND f90flags -g -Wall -pedantic -fbounds-check -ffpe-trap=invalid,overflow,underflow) - list(APPEND cflags -g -Wall -pedantic -fbounds-check) list(APPEND ldflags -g) endif() if(profile) list(APPEND f90flags -pg) - list(APPEND cflags -pg) list(APPEND ldflags -pg) endif() if(optimize) list(REMOVE_ITEM f90flags -O2) - list(REMOVE_ITEM cflags -O2) list(APPEND f90flags -O3) - list(APPEND cflags -O3) endif() if(openmp) list(APPEND f90flags -fopenmp) - list(APPEND cflags -fopenmp) list(APPEND ldflags -fopenmp) endif() if(coverage) list(APPEND f90flags -coverage) - list(APPEND cflags -coverage) list(APPEND ldflags -coverage) endif() elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) # Intel compiler options list(APPEND f90flags -fpp -std08 -assume byterecl -traceback) - list(APPEND cflags -std=c99) if(debug) list(APPEND f90flags -g -warn -ftrapuv -fp-stack-check "-check all" -fpe0 -O0) - list(APPEND cflags -g -w3 -ftrapuv -fp-stack-check -O0) list(APPEND ldflags -g) endif() if(profile) list(APPEND f90flags -pg) - list(APPEND cflags -pg) list(APPEND ldflags -pg) endif() if(optimize) list(APPEND f90flags -O3) - list(APPEND cflags -O3) endif() if(openmp) list(APPEND f90flags -qopenmp) - list(APPEND cflags -qopenmp) list(APPEND ldflags -qopenmp) endif() @@ -214,6 +201,49 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Cray) endif() +if(CMAKE_C_COMPILER_ID STREQUAL GNU) + # GCC compiler options + list(APPEND cflags -std=c99 -O2) + if(debug) + list(REMOVE_ITEM cflags -O2) + list(APPEND cflags -g -Wall -pedantic -fbounds-check) + endif() + if(profile) + list(APPEND cflags -pg) + endif() + if(optimize) + list(REMOVE_ITEM cflags -O2) + list(APPEND cflags -O3) + endif() + if(coverage) + list(APPEND cflags -coverage) + endif() + +elseif(CMAKE_C_COMPILER_ID STREQUAL Intel) + # Intel compiler options + list(APPEND cflags -std=c99) + if(debug) + list(APPEND cflags -g -w3 -ftrapuv -fp-stack-check -O0) + endif() + if(profile) + list(APPEND cflags -pg) + endif() + if(optimize) + list(APPEND cflags -O3) + endif() + +elseif(CMAKE_C_COMPILER_ID MATCHES Clang) + # Clang options + list(APPEND cflags -std=c99) + if(debug) + list(APPEND cflags -g -O0 -ftrapv) + endif() + if(optimize) + list(APPEND cflags -O3) + endif() + +endif() + # Show flags being used message(STATUS "Fortran flags: ${f90flags}") message(STATUS "C flags: ${cflags}")