patch the source code to the ScaFaCoS lib with a proper fix instead of working around it with compiler flags

This commit is contained in:
Axel Kohlmeyer
2020-06-17 13:01:29 -04:00
parent 27f1ce71fd
commit 2d52a09d08

View File

@ -14,45 +14,23 @@ endif()
option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT})
if(DOWNLOAD_SCAFACOS)
message(STATUS "ScaFaCoS download requested - we will build our own")
# create variables to pass our compiler flags along to the subsystem compile
# need to apply -fallow-argument-mismatch, if the fortran compiler supports it
include(CheckFortranCompilerFlag)
check_fortran_compiler_flag("-fallow-argument-mismatch" GNUFortran_ARGUMENT_MISMATCH_FLAG)
if(GNUFortran_ARGUMENT_MISMATCH_FLAG)
set(APPEND_Fortran_FLAGS "-fallow-argument-mismatch")
endif()
include(CheckCCompilerFlag)
check_c_compiler_flag("-fcommon" GNUC_NO_EXTERN_MISSING_FLAG)
if(GNUC_NO_EXTERN_MISSING_FLAG)
set(APPEND_C_FLAGS "-fcommon")
endif()
if(CMAKE_Fortran_FLAGS)
set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${APPEND_Fortran_FLAGS}")
else()
set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_${CMAKE_BUILD_TYPE}_FLAGS} ${APPEND_Fortran_FLAGS}")
endif()
if(CMAKE_CXX_FLAGS)
set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS}")
endif()
if(CMAKE_C_FLAGS)
set(SCAFACOS_C_FLAGS "${CMAKE_C_FLAGS} ${APPEND_C_FLAGS}")
else()
set(SCAFACOS_C_FLAGS "${CMAKE_C_${CMAKE_BUILD_TYPE}_FLAGS} ${APPEND_C_FLAGS}")
endif()
# version 1.0.1 needs a patch to compile and linke cleanly with GCC 10 and later.
file(DOWNLOAD https://download.lammps.org/thirdparty/scafacos-1.0.1-fix.diff ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff
EXPECTED_HASH MD5=4baa1333bb28fcce102d505e1992d032)
include(ExternalProject)
ExternalProject_Add(scafacos_build
URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz
URL_MD5 bd46d74e3296bd8a444d731bb10c1738
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --disable-doc
--enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m
--with-internal-fftw --with-internal-pfft
--with-internal-pnfft ${CONFIGURE_REQUEST_PIC}
FC=${CMAKE_MPI_Fortran_COMPILER} FCFLAGS=${SCAFACOS_Fortran_FLAGS}
CXX=${CMAKE_MPI_CXX_COMPILER} CXXFLAGS=${SCAFACOS_CXX_FLAGS}
CC=${CMAKE_MPI_C_COMPILER} CFLAGS=${SCAFACOS_C_FLAGS}
FC=${CMAKE_MPI_Fortran_COMPILER}
CXX=${CMAKE_MPI_CXX_COMPILER}
CC=${CMAKE_MPI_C_COMPILER}
F77=
BUILD_BYPRODUCTS
<INSTALL_DIR>/lib/libfcs.a