forked from lijiext/lammps
make formatting of if statements and string comparisons consistent
This commit is contained in:
parent
bec53a1cbf
commit
bc063f2e88
|
@ -9,7 +9,7 @@ if(POLICY CMP0074)
|
|||
endif()
|
||||
# set policy to silence warnings about missing executable permissions in
|
||||
# pythonx.y-config when cross-compiling. review occasionally if it may be set to NEW
|
||||
if (POLICY CMP0109)
|
||||
if(POLICY CMP0109)
|
||||
cmake_policy(SET CMP0109 OLD)
|
||||
endif()
|
||||
########################################
|
||||
|
@ -77,7 +77,7 @@ check_for_autogen_files(${LAMMPS_SOURCE_DIR})
|
|||
include(CheckIncludeFileCXX)
|
||||
|
||||
# set required compiler flags and compiler/CPU arch specific optimizations
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4)
|
||||
set(CMAKE_TUNE_DEFAULT "-xCOMMON-AVX512")
|
||||
|
@ -179,7 +179,7 @@ endif()
|
|||
|
||||
if(BUILD_MPI)
|
||||
# We use a non-standard procedure to cross-compile with MPI on Windows
|
||||
if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)
|
||||
if((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING)
|
||||
include(MPI4WIN)
|
||||
target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
|
||||
else()
|
||||
|
@ -213,7 +213,7 @@ string(TOUPPER ${LAMMPS_SIZES} LAMMPS_SIZES)
|
|||
target_compile_definitions(lammps PUBLIC -DLAMMPS_${LAMMPS_SIZES})
|
||||
|
||||
# posix_memalign is not available on Windows
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(LAMMPS_MEMALIGN "0" CACHE STRING "posix_memalign() is not available on Windows" FORCE)
|
||||
else()
|
||||
set(LAMMPS_MEMALIGN "64" CACHE STRING "enables the use of the posix_memalign() call instead of malloc() when large chunks or memory are allocated by LAMMPS. Set to 0 to disable")
|
||||
|
@ -255,7 +255,7 @@ if(BUILD_OMP)
|
|||
message(FATAL_ERROR "Cannot find the 'omp.h' header file required for full OpenMP support")
|
||||
endif()
|
||||
|
||||
if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)) OR
|
||||
if(((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0)))
|
||||
|
@ -319,7 +319,7 @@ find_program(GZIP_EXECUTABLE gzip)
|
|||
find_package_handle_standard_args(GZIP REQUIRED_VARS GZIP_EXECUTABLE)
|
||||
option(WITH_GZIP "Enable GZIP support" ${GZIP_FOUND})
|
||||
if(WITH_GZIP)
|
||||
if(GZIP_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING))
|
||||
if(GZIP_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING))
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_GZIP)
|
||||
else()
|
||||
message(FATAL_ERROR "gzip executable not found")
|
||||
|
@ -330,7 +330,7 @@ find_program(FFMPEG_EXECUTABLE ffmpeg)
|
|||
find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_EXECUTABLE)
|
||||
option(WITH_FFMPEG "Enable FFMPEG support" ${FFMPEG_FOUND})
|
||||
if(WITH_FFMPEG)
|
||||
if(FFMPEG_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING))
|
||||
if(FFMPEG_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING))
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_FFMPEG)
|
||||
else()
|
||||
message(FATAL_ERROR "ffmpeg executable not found")
|
||||
|
@ -445,7 +445,7 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-MESONT)
|
|||
if(PKG_${SIMPLE_LIB})
|
||||
string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}")
|
||||
string(TOLOWER "${PKG_LIB}" PKG_LIB)
|
||||
if(PKG_LIB STREQUAL mesont)
|
||||
if(PKG_LIB STREQUAL "mesont")
|
||||
enable_language(Fortran)
|
||||
file(GLOB_RECURSE ${PKG_LIB}_SOURCES
|
||||
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.f90)
|
||||
|
@ -457,9 +457,9 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-MESONT)
|
|||
add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES})
|
||||
set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_MACHINE})
|
||||
target_link_libraries(lammps PRIVATE ${PKG_LIB})
|
||||
if(PKG_LIB STREQUAL awpmd)
|
||||
if(PKG_LIB STREQUAL "awpmd")
|
||||
target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include)
|
||||
elseif(PKG_LIB STREQUAL h5md)
|
||||
elseif(PKG_LIB STREQUAL "h5md")
|
||||
target_include_directories(h5md PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/h5md/include ${HDF5_INCLUDE_DIRS})
|
||||
else()
|
||||
target_include_directories(${PKG_LIB} PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB})
|
||||
|
@ -472,7 +472,7 @@ if(PKG_USER-AWPMD)
|
|||
endif()
|
||||
|
||||
if(PKG_USER-ATC)
|
||||
if(LAMMPS_SIZES STREQUAL BIGBIG)
|
||||
if(LAMMPS_SIZES STREQUAL "BIGBIG")
|
||||
message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG")
|
||||
endif()
|
||||
target_link_libraries(atc PRIVATE ${LAPACK_LIBRARIES})
|
||||
|
@ -516,7 +516,7 @@ endif()
|
|||
# and the MPI library - if use - has to be linked right before those
|
||||
# and after everything else that is compiled locally
|
||||
######################################################################
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_link_libraries(lammps PRIVATE -lwsock32 -lpsapi)
|
||||
endif()
|
||||
|
||||
|
@ -565,8 +565,8 @@ add_dependencies(lammps gitversion)
|
|||
# Actually add executable and lib to build
|
||||
############################################
|
||||
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
list (FIND LANGUAGES "Fortran" _index)
|
||||
if(${_index} GREATER -1)
|
||||
list(FIND LANGUAGES "Fortran" _index)
|
||||
if(_index GREATER -1)
|
||||
target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
|
||||
endif()
|
||||
set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h compute.h dihedral.h domain.h error.h fix.h force.h group.h improper.h
|
||||
|
@ -644,7 +644,7 @@ if(BUILD_SHARED_LIBS)
|
|||
else()
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
endif()
|
||||
if (Python_EXECUTABLE)
|
||||
if(Python_EXECUTABLE)
|
||||
add_custom_target(
|
||||
install-python ${CMAKE_COMMAND} -E remove_directory build
|
||||
COMMAND ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h
|
||||
|
@ -677,7 +677,7 @@ if(BUILD_SHARED_LIBS OR PKG_PYTHON)
|
|||
else()
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
endif()
|
||||
if (Python_EXECUTABLE)
|
||||
if(Python_EXECUTABLE)
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python)
|
||||
install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py build -b ${CMAKE_BINARY_DIR}/python install --prefix=${CMAKE_INSTALL_PREFIX} --root=\$ENV{DESTDIR}/ WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR})")
|
||||
endif()
|
||||
|
@ -722,15 +722,15 @@ if(OPTIONS)
|
|||
message(" Options: ${OPTIONS}")
|
||||
endif()
|
||||
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
list (FIND LANGUAGES "Fortran" _index)
|
||||
if(${_index} GREATER -1)
|
||||
list(FIND LANGUAGES "Fortran" _index)
|
||||
if(_index GREATER -1)
|
||||
message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER}
|
||||
Type: ${CMAKE_Fortran_COMPILER_ID}
|
||||
Version: ${CMAKE_Fortran_COMPILER_VERSION}
|
||||
Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}")
|
||||
endif()
|
||||
list (FIND LANGUAGES "C" _index)
|
||||
if(${_index} GREATER -1)
|
||||
list(FIND LANGUAGES "C" _index)
|
||||
if(_index GREATER -1)
|
||||
message(STATUS "C compiler: ${CMAKE_C_COMPILER}
|
||||
Type: ${CMAKE_C_COMPILER_ID}
|
||||
Version: ${CMAKE_C_COMPILER_VERSION}
|
||||
|
@ -795,7 +795,7 @@ if(PKG_KSPACE)
|
|||
endif()
|
||||
if(PKG_KOKKOS)
|
||||
if(Kokkos_ENABLE_CUDA)
|
||||
if (${FFT} STREQUAL "KISS")
|
||||
if(FFT STREQUAL "KISS")
|
||||
message(STATUS "Kokkos FFT: KISS")
|
||||
else()
|
||||
message(STATUS "Kokkos FFT: cuFFT")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
message(STATUS "Downloading and building Google Test library")
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(GTEST_LIB_POSTFIX d)
|
||||
else()
|
||||
set(GTEST_LIB_POSTFIX)
|
||||
|
|
|
@ -106,7 +106,7 @@ function(FetchPotentials pkgfolder potfolder)
|
|||
endfunction(FetchPotentials)
|
||||
|
||||
# set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux
|
||||
if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (EXISTS /etc/os-release))
|
||||
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (EXISTS /etc/os-release))
|
||||
file(STRINGS /etc/os-release distro REGEX "^NAME=")
|
||||
string(REGEX REPLACE "NAME=\"?([^\"]*)\"?" "\\1" distro "${distro}")
|
||||
file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=")
|
||||
|
|
|
@ -48,7 +48,7 @@ if(GPU_API STREQUAL "CUDA")
|
|||
|
||||
# ensure that no *cubin.h files exist from a compile in the lib/gpu folder
|
||||
file(GLOB GPU_LIB_OLD_CUBIN_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/*_cubin.h)
|
||||
if (GPU_LIB_OLD_CUBIN_HEADERS)
|
||||
if(GPU_LIB_OLD_CUBIN_HEADERS)
|
||||
message(FATAL_ERROR "########################################################################\n"
|
||||
"Found file(s) generated by the make-based build system in lib/gpu\n"
|
||||
"Please run\n"
|
||||
|
@ -154,7 +154,7 @@ elseif(GPU_API STREQUAL "OPENCL")
|
|||
endif()
|
||||
option(USE_STATIC_OPENCL_LOADER "Download and include a static OpenCL ICD loader" ${_opencl_static_default})
|
||||
mark_as_advanced(USE_STATIC_OPENCL_LOADER)
|
||||
if (USE_STATIC_OPENCL_LOADER)
|
||||
if(USE_STATIC_OPENCL_LOADER)
|
||||
include(OpenCLLoader)
|
||||
else()
|
||||
find_package(OpenCL REQUIRED)
|
||||
|
|
|
@ -99,7 +99,7 @@ if(PKG_KSPACE)
|
|||
${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/remap_kokkos.cpp)
|
||||
if(Kokkos_ENABLE_CUDA)
|
||||
if(NOT ${FFT} STREQUAL "KISS")
|
||||
if(NOT (FFT STREQUAL "KISS"))
|
||||
target_compile_definitions(lammps PRIVATE -DFFT_CUFFT)
|
||||
target_link_libraries(lammps PRIVATE cufft)
|
||||
endif()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if(LAMMPS_SIZES STREQUAL BIGBIG)
|
||||
if(LAMMPS_SIZES STREQUAL "BIGBIG")
|
||||
message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG")
|
||||
endif()
|
||||
option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
|
||||
|
|
|
@ -17,7 +17,7 @@ if(DOWNLOAD_MDI)
|
|||
# only ON/OFF are allowed for "mpi" flag when building MDI library
|
||||
# so translate boolean value of BUILD_MPI
|
||||
# always disable MPI when cross-compiling to Windows.
|
||||
if((BUILD_MPI) AND NOT((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING))
|
||||
if((BUILD_MPI) AND NOT((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING))
|
||||
set(MDI_USE_MPI ON)
|
||||
else()
|
||||
set(MDI_USE_MPI OFF)
|
||||
|
@ -27,12 +27,12 @@ if(DOWNLOAD_MDI)
|
|||
set(MDI_USE_PYTHON_PLUGINS OFF)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.12)
|
||||
find_package(PythonLibs QUIET) # Deprecated since version 3.12
|
||||
if (PYTHONLIBS_FOUND)
|
||||
if(PYTHONLIBS_FOUND)
|
||||
set(MDI_USE_PYTHON_PLUGINS ON)
|
||||
endif()
|
||||
else()
|
||||
find_package(Python QUIET COMPONENTS Development)
|
||||
if (Python_Development_FOUND)
|
||||
if(Python_Development_FOUND)
|
||||
set(MDI_USE_PYTHON_PLUGINS ON)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -85,7 +85,7 @@ if(DOWNLOAD_MDI)
|
|||
|
||||
endif()
|
||||
# need to add support for dlopen/dlsym, except when compiling for Windows.
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows"))
|
||||
list(APPEND MDI_DEP_LIBS "${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
if(MDI_DEP_LIBS)
|
||||
|
|
|
@ -9,7 +9,7 @@ function(prevent_in_source_builds)
|
|||
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
|
||||
|
||||
# disallow in-source builds
|
||||
if("${srcdir}" STREQUAL "${bindir}" OR "${srcdir2}" STREQUAL "${bindir}" OR "${srcdir3}" STREQUAL "${bindir}")
|
||||
if(("${srcdir}" STREQUAL "${bindir}") OR ("${srcdir2}" STREQUAL "${bindir}") OR ("${srcdir3}" STREQUAL "${bindir}"))
|
||||
message(FATAL_ERROR "\
|
||||
|
||||
CMake must not to be run in the source directory. \
|
||||
|
|
|
@ -19,11 +19,11 @@ if(ENABLE_TESTING)
|
|||
# we need to build and link a LOT of tester executables, so it is worth checking if
|
||||
# a faster linker is available. requires GNU or Clang compiler, newer CMake.
|
||||
# also only verified with Fedora Linux > 30 and Ubuntu <= 18.04 (Ubuntu 20.04 fails)
|
||||
if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
|
||||
AND ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||
OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")))
|
||||
if (((CMAKE_LINUX_DISTRO STREQUAL Ubuntu) AND (CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04))
|
||||
OR ((CMAKE_LINUX_DISTRO STREQUAL Fedora) AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30)))
|
||||
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
|
||||
AND ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")))
|
||||
if(((CMAKE_LINUX_DISTRO STREQUAL "Ubuntu") AND (CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04))
|
||||
OR ((CMAKE_LINUX_DISTRO STREQUAL "Fedora") AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30)))
|
||||
include(CheckCXXCompilerFlag)
|
||||
set(CMAKE_CUSTOM_LINKER_DEFAULT default)
|
||||
check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG)
|
||||
|
@ -58,7 +58,7 @@ if(ENABLE_TESTING)
|
|||
endif()
|
||||
|
||||
# Compiler specific features for testing
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF)
|
||||
mark_as_advanced(ENABLE_COVERAGE)
|
||||
if(ENABLE_COVERAGE)
|
||||
|
@ -83,7 +83,7 @@ mark_as_advanced(ENABLE_IWYU)
|
|||
if(ENABLE_IWYU)
|
||||
# enforce these settings
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable reporting compilation commands to compile_commands.json" FORCE)
|
||||
if (NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")))
|
||||
if(NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")))
|
||||
message(FATAL_ERROR "IWYU is only supported with Clang or GNU compilers")
|
||||
endif()
|
||||
# detect the "native" header folder so we can include them first
|
||||
|
@ -91,7 +91,7 @@ if(ENABLE_IWYU)
|
|||
string(REGEX REPLACE ".*libraries: *=([^:]+):.*" "\\1/include" IWYU_EXTRA_INCLUDE_DIR ${IWYU_SEARCH_PATHS})
|
||||
find_program(IWYU_EXE NAMES include-what-you-use iwyu)
|
||||
find_program(IWYU_TOOL NAMES iwyu_tool iwyu-tool iwyu_tool.py)
|
||||
if (IWYU_EXE AND IWYU_TOOL)
|
||||
if(IWYU_EXE AND IWYU_TOOL)
|
||||
add_custom_target(
|
||||
iwyu
|
||||
${IWYU_TOOL} -o clang -p ${CMAKE_CURRENT_BINARY_DIR} -- -I${IWYU_EXTRA_INCLUDE_DIR} -Xiwyu --mapping_file=${CMAKE_CURRENT_SOURCE_DIR}/iwyu/iwyu-extra-map.imp
|
||||
|
|
|
@ -45,7 +45,7 @@ if(BUILD_LAMMPS_SHELL)
|
|||
target_include_directories(lammps-shell PRIVATE ${LAMMPS_TOOLS_DIR}/lammps-shell)
|
||||
|
||||
# workaround for broken readline pkg-config file on FreeBSD
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
target_include_directories(lammps-shell PRIVATE /usr/local/include)
|
||||
endif()
|
||||
target_link_libraries(lammps-shell PRIVATE lammps PkgConfig::READLINE)
|
||||
|
|
Loading…
Reference in New Issue