mirror of https://github.com/lammps/lammps.git
add CMake check that will refuse compilation of unit tests or skip tests
This is mainly because the default compilers on RHEL/CentOS 7.x are not sufficient to compile googletest. Also some Fortran module test requires a working F90 module and others are more recent Fortran compiler.
This commit is contained in:
parent
3a8abecd68
commit
d8ab00ea78
|
@ -147,6 +147,16 @@ compile and will download and compile a specific recent version of the
|
|||
`Googletest <https://github.com/google/googletest/>`_ C++ test framework
|
||||
for implementing the tests.
|
||||
|
||||
.. admonition:: Software version requirements for testing
|
||||
:class: note
|
||||
|
||||
The compiler and library version requirements for the testing
|
||||
framework are more strict than for the main part of LAMMPS. For
|
||||
example the default GNU C++ and Fortran compilers of RHEL/CentOS 7.x
|
||||
(version 4.8.x) are not sufficient. The CMake configuration will try
|
||||
to detect compatible versions and either skip incompatible tests or
|
||||
stop with an error.
|
||||
|
||||
After compilation is complete, the unit testing is started in the build
|
||||
folder using the ``ctest`` command, which is part of the CMake software.
|
||||
The output of this command will be looking something like this::
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
# Created by Axel Kohlmeyer and Richard Berger
|
||||
########################################
|
||||
# download and build googletest framework
|
||||
|
||||
# cannot compile googletest anymore with the default GCC on RHEL 7.x
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0))
|
||||
message(FATAL_ERROR "Need GNU C++ compiler version 6.x or later for unit testing")
|
||||
endif()
|
||||
|
||||
message(STATUS "Downloading and building googletest framework")
|
||||
set(GTEST_URL "https://github.com/google/googletest/archive/release-1.12.1.tar.gz" CACHE STRING "URL of googletest source")
|
||||
set(GTEST_MD5 "e82199374acdfda3f425331028eb4e2a" CACHE STRING "MD5 sum for googletest source")
|
||||
|
|
|
@ -14,6 +14,11 @@ if(CMAKE_Fortran_COMPILER)
|
|||
message(STATUS "Skipping Tests for the LAMMPS Fortran Module: cannot identify Fortran compiler")
|
||||
return()
|
||||
endif()
|
||||
# GNU Fortran 4.8.x on RHEL/CentOS 7.x is not sufficient to compile the Fortran module
|
||||
if((CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") AND (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0))
|
||||
message(FATAL_ERROR "Need GNU Fortran compiler version 6.x or later for unit testing")
|
||||
endif()
|
||||
|
||||
get_filename_component(LAMMPS_FORTRAN_MODULE ${LAMMPS_SOURCE_DIR}/../fortran/lammps.f90 ABSOLUTE)
|
||||
if(BUILD_MPI)
|
||||
find_package(MPI REQUIRED)
|
||||
|
@ -32,10 +37,14 @@ if(CMAKE_Fortran_COMPILER)
|
|||
|
||||
add_library(flammps STATIC ${LAMMPS_FORTRAN_MODULE} keepstuff.f90)
|
||||
|
||||
add_executable(test_fortran_create wrap_create.cpp test_fortran_create.f90)
|
||||
target_link_libraries(test_fortran_create PRIVATE flammps lammps MPI::MPI_Fortran GTest::GTestMain)
|
||||
target_include_directories(test_fortran_create PRIVATE "${LAMMPS_SOURCE_DIR}/../fortran")
|
||||
add_test(NAME FortranOpen COMMAND test_fortran_create)
|
||||
if(MPI_Fortran_HAVE_F90_MODULE)
|
||||
add_executable(test_fortran_create wrap_create.cpp test_fortran_create.f90)
|
||||
target_link_libraries(test_fortran_create PRIVATE flammps lammps MPI::MPI_Fortran GTest::GTestMain)
|
||||
target_include_directories(test_fortran_create PRIVATE "${LAMMPS_SOURCE_DIR}/../fortran")
|
||||
add_test(NAME FortranOpen COMMAND test_fortran_create)
|
||||
else()
|
||||
message(STATUS "Skipping FortranOpen test since no working F90 MPI module was found")
|
||||
endif()
|
||||
|
||||
add_executable(test_fortran_commands wrap_commands.cpp test_fortran_commands.f90)
|
||||
target_link_libraries(test_fortran_commands PRIVATE flammps lammps MPI::MPI_Fortran GTest::GTestMain)
|
||||
|
|
Loading…
Reference in New Issue