Skip to content

Commit

Permalink
[cmake] fix issues when cp2k is build with spack
Browse files Browse the repository at this point in the history
Co-authored-by: Rocco Meli <r.meli@bluemail.ch>
  • Loading branch information
mtaillefumier and RMeli committed Oct 19, 2023
1 parent f45a645 commit 25e21fa
Show file tree
Hide file tree
Showing 39 changed files with 504 additions and 551 deletions.
74 changes: 14 additions & 60 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ project(

set(cp2k_APIVERSION ${cp2k_VERSION_MAJOR}.${cp2k_VERSION_MINOR})

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")

if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()

# set language and standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 11)

find_package(PkgConfig)

Expand Down Expand Up @@ -110,7 +113,6 @@ option(CP2K_USE_SPLA
option(CP2K_USE_METIS "enable metis library support" OFF)
option(CP2K_USE_LIBXSMM "Use libxsmm for small gemms (supports x86 platforms)"
OFF)
option(CP2K_BUILD_DBCSR "Duild dbcsr at the same time than cp2k." OFF)
option(BUILD_SHARED_LIBS "Build cp2k shared library" ON)

cmake_dependent_option(CP2K_ENABLE_ELPA_OPENMP_SUPPORT
Expand All @@ -119,23 +121,8 @@ cmake_dependent_option(CP2K_ENABLE_FFTW3_OPENMP_SUPPORT
"Enable FFTW openmp support" ON "CP2K_USE_FFTW3" OFF)
cmake_dependent_option(CP2K_ENABLE_FFTW3_THREADS_SUPPORT
"Enable FFTW THREADS support" OFF "CP2K_USE_FFTW3" OFF)
cmake_dependent_option(CP2K_ENABLE_F08_MPI "Enable MPI Fortran 2008 interface"
OFF "CP2K_USE_MPI" OFF)

cmake_dependent_option(
DBCSR_USE_ACCEL
"Enable dbcsr gpu support. It will be turned on only if cp2k gpu support is on"
ON
"CP2K_BUILD_DBCSR"
OFF)
cmake_dependent_option(DBCSR_USE_OPENMP "Enable dbcsr openmp support" OFF
"CP2K_BUILD_DBCSR" OFF)
cmake_dependent_option(
DBCSR_USE_G2G
"Enable dbcsr gpu-gpu communication support. It will be turned on only if cp2k gpu support is on"
ON
"CP2K_BUILD_DBCSR"
OFF)
cmake_dependent_option(CP2K_USE_MPI_F08 "Enable MPI Fortran 2008 interface" OFF
"CP2K_USE_MPI" OFF)

cmake_dependent_option(
CP2K_USE_CUSOLVER_MP
Expand Down Expand Up @@ -561,44 +548,7 @@ endif()
# PACKAGE DISCOVERY (compiler configuration can impact package discovery)
find_package(OpenMP REQUIRED COMPONENTS Fortran C CXX)

# CP2K options are prefixed with CP2K_ (namespacing) while dbcsr does not.
if(NOT CP2K_BUILD_DBCSR)
find_package(DBCSR 2.4 REQUIRED)
else()
# replace this with the block command when we update to cmake 3.25

set(USE_ACCEL "")
set(BLAS_LIBRARIES "")
set(LAPACK_LIBRARIES "")
set(USE_MPI ${CP2K_USE_MPI})
set(WITH_EXAMPLES OFF)
set(BUILD_TESTING OFF)
set(WITH_C_API OFF)
set(USE_SMM "")
set(USE_OPENMP ON)
check_git_submodule(dbcsr "${CMAKE_SOURCE_DIR}/exts/dbcsr")
if(DBCSR_USE_ACCEL AND CP2K_USE_ACCEL MATCHES "CUDA|HIP")
if(CP2K_USE_ACCEL MATCHES "CUDA")
set(USE_ACCEL "cuda")
endif()
if(CP2K_USE_ACCEL MATCHES "HIP")
set(USE_ACCEL "hip")
endif()
set(WITH_GPU "${CP2K_WITH_GPU}")
set(ACC_ARCH_NUMBER "${CP2K_GPU_ARCH_NUMBER_${CP2K_WITH_GPU}}")
endif()
set(BLAS_LIBRARIES "${CP2K_BLAS_LINK_LIBRARIES}")
set(LAPACK_LIBRARIES "${CP2K_LAPACK_LINK_LIBRARIES}")
set(USE_MPI ${CP2K_USE_MPI})
set(WITH_C_API OFF)
if(CP2K_USE_LIBXSMM)
set(USE_SMM "libxsmm")
endif()
set(WITH_G2G ${DBCSR_WITH_G2G})
if(DBCSR_USE_OPENMP)
set(USE_OPENMP ON)
endif()
endif()
find_package(DBCSR 2.6 REQUIRED)

# ==================================
if(CP2K_USE_ELPA)
Expand Down Expand Up @@ -693,7 +643,7 @@ if(CP2K_USE_SUPERLU)
find_package(SuperLU REQUIRED)
endif()

if(CP2K_USE_PARMETIS)
if(CP2K_USE_METIS)
find_package(Metis)
endif()

Expand Down Expand Up @@ -755,7 +705,7 @@ add_subdirectory(src)
include(GNUInstallDirs)

get_target_property(CP2K_LIBS cp2k_link_libs INTERFACE_LINK_LIBRARIES)
configure_file(cmake/cp2k.pc.in cp2k.pc @ONLY)
configure_file(cmake/libcp2k.pc.in libcp2k.pc @ONLY)

message(
""
Expand Down Expand Up @@ -998,12 +948,16 @@ write_basic_package_version_file(

configure_file("${PROJECT_SOURCE_DIR}/cmake/cp2kConfig.cmake.in"
"${PROJECT_BINARY_DIR}/cp2kConfig.cmake" @ONLY)

install(FILES "${PROJECT_BINARY_DIR}/cp2kConfig.cmake"
"${PROJECT_BINARY_DIR}/cp2kConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cp2k")

install(FILES "${PROJECT_BINARY_DIR}/libcp2k.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

install(
DIRECTORY "${PROJECT_SOURCE_DIR}/cmake"
DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/modules"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cp2k"
FILES_MATCHING
PATTERN "*.cmake")
209 changes: 94 additions & 115 deletions cmake/CompilerConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,127 +5,106 @@
#! SPDX-License-Identifier: GPL-2.0-or-later !
#!-------------------------------------------------------------------------------------------------!

if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
set(CMAKE_Fortran_FLAGS
"${CMAKE_Fortran_FLAGS} -mtune=native -ffree-line-length-512 -ffree-form -std=f2008 -fimplicit-none -Werror=aliasing -Werror=ampersand -Werror=c-binding-type -Werror=intrinsic-shadow -Werror=intrinsics-std -Werror=tabs -Werror=target-lifetime -Werror=underflow -Werror=unused-but-set-variable -Werror=unused-variable -Werror=conversion -Werror=zerotrip -Wuninitialized -Wno-maybe-uninitialized -Wunused-parameter"
)

if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch"
)# gcc 10+ has this automatically
endif()
set(CP2K_C_COMPILER_LIST "GNU;Intel;NAG;Cray;PGI;Clang;AppleClang")
set(CP2K_Fortran_COMPILER_LIST "GNU;Intel;NAG;Cray;PGI")

set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -g -funroll-loops")
set(CMAKE_Fortran_FLAGS_COVERAGE
"-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"
)
set(CMAKE_Fortran_FLAGS_DEBUG
"-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"
)
if((NOT (USE_MPI)) OR (NOT ("${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES
"Open MPI")))
set(CMAKE_Fortran_FLAGS_COVERAGE
"${CMAKE_Fortran_FLAGS_COVERAGE} -fsanitize=leak")
set(CMAKE_Fortran_FLAGS_DEBUG
"${CMAKE_Fortran_FLAGS_DEBUG} -fsanitize=leak")
endif()
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
set(CMAKE_Fortran_FLAGS
"${CMAKE_Fortran_FLAGS} -free -stand=f18 -fpp -heap-arrays")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -g")
set(CMAKE_Fortran_FLAGS_DEBUG "-O2 -debug")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
set(CMAKE_Fortran_FLAGS
"${CMAKE_Fortran_FLAGS} -Mfreeform -Mextend -Mallocatable=03"
)# -Mallocatable=03: enable F2003+ assignment semantics
set(CMAKE_Fortran_FLAGS_RELEASE "-fast")
set(CMAKE_Fortran_FLAGS_DEBUG "-g")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "NAG")
set(CMAKE_Fortran_FLAGS
"${CMAKE_Fortran_FLAGS} -f2008 -free -Warn=reallocation -Warn=subnormal")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-g -C")
if(NOT OpenMP_FOUND)
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -gline"
)# -gline is only supported without OpenMP
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -C=all"
)# some checks are not available with OpenMP
endif()
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -f free -M3105 -ME7212"
)# -M3105: hide a
# false-positive warning about modified loop variables due to loop fusing,
# promote warning 7212 to an error
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -G2")
set(CMAKE_Fortran_FLAGS_DEBUG "-G2")
set(CMAKE_Fortran_MODOUT_FLAG "-ef") # override to get lower-case module file
# names
else()
if(NOT CMAKE_C_COMPILER_ID IN_LIST CP2K_C_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 for your compiler!\n\
Please open an issue at https://github.com/cp2k/dbcsr/issues with the reported compiler name and the required flags."
)
message("-- CMAKE_Fortran_COMPILER_ID: " ${CMAKE_Fortran_COMPILER_ID})
message("-- CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
"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(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS_RELEASE "-O3 -g -funroll-loops -Wall")
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g --coverage -Wall")
set(CMAKE_C_FLAGS_DEBUG
"-O2 -ggdb -Wall -fsanitize=undefined -fsanitize=address -fsanitize-recover=all -Wall -Wextra -Werror -Wno-vla-parameter -Wno-deprecated-declarations"
)
if((NOT (USE_MPI)) OR (NOT ("${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES
"Open MPI")))
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -fsanitize=leak")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=leak")
endif()
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS_RELEASE "-O3 -funroll-loops")
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g --coverage")
set(CMAKE_C_FLAGS_DEBUG "-O1 -g -fno-omit-frame-pointer")
elseif(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_C_FLAGS_RELEASE "-O3 -funroll-loops")
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g --coverage")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "-lgcov") # Apple's Clang needs an extra
elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
set(CMAKE_C_FLAGS_RELEASE "-O3 -g")
set(CMAKE_C_FLAGS_DEBUG "-O0 -debug")
elseif(CMAKE_C_COMPILER_ID STREQUAL "PGI")
set(CMAKE_C_FLAGS_RELEASE "-fast")
set(CMAKE_C_FLAGS_DEBUG "-g")
elseif(CMAKE_C_COMPILER_ID STREQUAL "Cray")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_C_FLAGS_DEBUG "-G2")
if(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
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -h system_alloc")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -h system_alloc")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -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()
# OpenACC support with CCE is EOL: causes
# https://github.com/cp2k/dbcsr/issues/261 eventually check compiler version
# (similar to -h system_alloc)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -hnoacc -h nomessage=1234")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -hnoacc -h nomessage=1234")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -hnoacc -M1234")
else()
if(NOT CMAKE_Fortran_COMPILER_ID IN_LIST CP2K_Fortran_COMPILER_LIST)
message(
WARNING
"\
Unknown C++ compiler, trying without any additional (optimization) flags.\n\
You may have to specify flags for C++11/14 support manually.\n\
Please open an issue at https://github.com/cp2k/dbcsr/issues with the reported compiler name and the required flags."
"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(
"$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-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>"
"$<$<AND:$<COMPILE_LANG_AND_ID:Fortran,GNU>,$<VERSION_GREATER_EQUAL:${CMAKE_Fortran_COMPILER_VERSION},11>>:-fallow-argument-mismatch>"
"$<$<COMPILE_LANG_AND_ID:Fortran,Intel>:-free -stand=f18 -fpp -heap-arrays>"
"$<$<COMPILE_LANG_AND_ID:Fortran,PGI>:-Mfreeform -Mextend -Mallocatable=03>"
"$<$<COMPILE_LANG_AND_ID:Fortran,NAG>:-f2008 -free -Warn=reallocation -Warn=subnormal>"
"$<$<COMPILE_LANG_AND_ID:C,Cray>:-hnoacc -h nomessage=1234>"
"$<$<COMPILE_LANG_AND_ID:Fortran,Cray>:-f free -M3105 -ME7212 -hnoacc -M1234>"
)

add_compile_options(
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:Fortran,GNU>>:-O3;-g;-funroll-loops>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:Fortran,PGI>>:-fast>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:Fortran,Intel>>:-O3;-g>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:Fortran,Cray>>:-O2;-G2>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:Fortran,NAG>>:-gline>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:C,GNU>>:-O3;-g;-funroll-loops;-Wall>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:C,PGI>>:-fast>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:C,Intel>>:-O3;-g>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:C,Cray>>:-O3>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:C,NAG>>:-gline>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:C,Clang>>:-O3;-funroll-loops>"
"$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:C,AppleClang>>:-O3;-funroll-loops>"
"$<$<NOT:$<BOOL:OpenMP_FOUND>>:$<$<AND:$<CONFIG:RELEASE>,$<COMPILE_LANG_AND_ID:Fortran,NAG>>:-gline>>"
)

add_compile_options(
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:Fortran,GNU>>:-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>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:Fortran,PGI>>:-g>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:Fortran,Intel>>:-O2;-debug>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:Fortran,Cray>>:-G2>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:C,GNU>>:-O2;-ggdb;-Wall;-fsanitize=undefined;-fsanitize=address;-fsanitize-recover=all;-Wall;-Wextra;-Werror;-Wno-vla-parameter;-Wno-deprecated-declarations>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:C,PGI>>:-fast>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:C,Intel>>:-O3;-g>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:C,Cray>>:-G2>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:C,NAG>>:-g;-C>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:C,Clang>>:-O1;-g;-fno-omit-frame-pointer>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:C,AppleClang>>:-O0;-g>"
"$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANG_AND_ID:Fortran,NAG>>:-C=all>")

add_compile_options(
"$<$<AND:$<CONFIG:COVERAGE>,$<COMPILE_LANG_AND_ID:Fortran,GNU>>:-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>"
"$<$<AND:$<CONFIG:COVERAGE>,$<COMPILE_LANG_AND_ID:C,GNU>>:-O0;-g;--coverage;-Wall>"
)

if(NOT CP2K_USE_MPI OR NOT "${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES "Open
MPI")
add_compile_options(
"$<$<AND:$<CONFIG:COVERAGE>,$<COMPILE_LANG_AND_ID:Fortran,GNU>>:-fsanitize=leak>"
"$<$<AND:$<CONFIG:COVERAGE>,$<COMPILE_LANG_AND_ID:C,GNU>>:-O0;-g;--coverage;-Wall>"
)
message("-- CMAKE_C_COMPILER_ID: " ${CMAKE_C_COMPILER_ID})
message("-- CMAKE_C_COMPILER full path: " ${CMAKE_C_COMPILER})
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("$<$<LANGUAGE:C>:-h;system_alloc>"
"$<$<LANGUAGE:Fortran>:-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()

0 comments on commit 25e21fa

Please sign in to comment.