#!-------------------------------------------------------------------------------------------------! #! CP2K: A general program to perform molecular dynamics simulations ! #! Copyright 2000-2024 CP2K developers group ! #! ! #! SPDX-License-Identifier: GPL-2.0-or-later ! #!-------------------------------------------------------------------------------------------------! set(CP2K_C_COMPILER_LIST "GNU;Intel;NAG;Cray;PGI;Clang;AppleClang") set(CP2K_Fortran_COMPILER_LIST "GNU;Intel;NAG;Cray;PGI") if(NOT CMAKE_C_COMPILER_ID IN_LIST CP2K_C_COMPILER_LIST) message( WARNING "Unknown C compiler, trying without any additional (optimization) flags.\n" "You may have to specify flags for C11 support manually.\n Please open an\n" "issue at https://github.com/cp2k/cp2k/issues with the reported compiler \n" "name and the required flags.") message("-- CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}\n" "-- CMAKE_C_COMPILER full path: ${CMAKE_C_COMPILER}\n") endif() if(NOT CMAKE_Fortran_COMPILER_ID IN_LIST CP2K_Fortran_COMPILER_LIST) message( WARNING "Unknown Fortran compiler, trying without any additional (optimization) flags.\n" "You will most likely have to specify extra options for free-form Fortran 2008\n" "for your compiler! Please open an issue at https://github.com/cp2k/cp2k/issues\n" "with the reported compiler name and the required flags.") message("-- CMAKE_Fortran_COMPILER_ID: ${CMAKE_Fortran_COMPILER_ID}\n" "-- CMAKE_Fortran_COMPILER full path: ${CMAKE_Fortran_COMPILER}\n") endif() # OpenACC support with CCE is EOL: causes # https://github.com/cp2k/dbcsr/issues/261 eventually check compiler version # (similar to -h system_alloc) add_compile_options( "$<$:-mtune=native;-ffree-line-length-512;-ffree-form;-std=f2008;-fimplicit-none;-Werror=aliasing;-Werror=ampersand;-Werror=c-binding-type;-Werror=conversion;-Werror=intrinsic-shadow;-Werror=intrinsics-std;-Werror=line-truncation;-Werror=tabs;-Werror=target-lifetime;-Werror=underflow;-Werror=unused-but-set-variable;-Werror=unused-variable>" "$<$,$>:-fallow-argument-mismatch>" "$<$:-free -stand=f18 -fpp -heap-arrays>" "$<$:-Mfreeform -Mextend -Mallocatable=03>" "$<$:-f2008 -free -Warn=reallocation -Warn=subnormal>" "$<$:-hnoacc -h nomessage=1234>" "$<$:-f free -M3105 -ME7212 -hnoacc -M1234>" ) add_compile_options( "$<$,$>:-O3;-g;-funroll-loops>" "$<$,$>:-fast>" "$<$,$>:-O3;-g>" "$<$,$>:-O2;-G2>" "$<$,$>:-gline>" "$<$,$>:-O3;-g;-funroll-loops;-Wall>" "$<$,$>:-fast>" "$<$,$>:-O3;-g>" "$<$,$>:-O3>" "$<$,$>:-gline>" "$<$,$>:-O3;-funroll-loops>" "$<$,$>:-O3;-funroll-loops>" "$<$>:$<$,$>:-gline>>" ) add_compile_options( "$<$,$>:-fbacktrace;-ffree-form;-fimplicit-none;-std=f2008;-fsanitize=leak;-fcheck=all,no-array-temps;-ffpe-trap=invalid,zero,overflow;-finit-derived;-finit-real=snan;-finit-integer=-42;-Werror=realloc-lhs;-finline-matmul-limit=0>" "$<$,$>:-g>" "$<$,$>:-O2;-debug>" "$<$,$>:-G2>" "$<$,$>:-O2;-ggdb;-Wall;-fsanitize=undefined;-fsanitize=address;-fsanitize-recover=all;-Wall;-Wextra;-Werror;-Wno-vla-parameter;-Wno-deprecated-declarations>" "$<$,$>:-fast>" "$<$,$>:-O3;-g>" "$<$,$>:-G2>" "$<$,$>:-g;-C>" "$<$,$>:-O1;-g;-fno-omit-frame-pointer>" "$<$,$>:-O0;-g>" "$<$,$>:-C=all>") add_compile_options( "$<$,$>:-O0;-g;--coverage;-fno-omit-frame-pointer;-fcheck=all;-ffpe-trap=invalid,zero,overflow;-fbacktrace;-finit-real=snan;-finit-integer=-42;-finit-derived;-Werror=realloc-lhs;-finline-matmul-limit=0>" "$<$,$>:-O0;-g;--coverage;-Wall>" ) if(NOT CP2K_USE_MPI OR NOT "${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES "Open MPI") add_compile_options( "$<$,$>:-fsanitize=leak>" "$<$,$>:-O0;-g;--coverage;-Wall>" ) endif() if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang") set(CMAKE_Fortran_MODOUT_FLAG "-ef") # override to get lower-case module file # names set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "-lgcov") # Apple's Clang needs an extra endif() if(CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") set(CMAKE_Fortran_MODOUT_FLAG "-ef") # override to get lower-case module file # names endif() if(CMAKE_C_COMPILER_ID STREQUAL "Cray" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9) # prevent deallocation failures due to tcmalloc's free with glibc's # aligned_alloc, see https://bugzilla.redhat.com/show_bug.cgi?id=1569391 add_compile_options("$<$:-h;system_alloc>" "$<$:-h;system_alloc>") # since the detection of the implicitly linked libraries occurs before we can # intervene, filter them out again list(FILTER CMAKE_C_IMPLICIT_LINK_LIBRARIES EXCLUDE REGEX "tcmalloc") list(FILTER CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES EXCLUDE REGEX "tcmalloc") endif()