Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 4 additions & 97 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ option(ENABLE_CNPY "Enable cnpy usage" OFF)
cmake_dependent_option(ENABLE_ELPA "Enable ELPA for LCAO" ON "ENABLE_LCAO;ENABLE_MPI" OFF)
cmake_dependent_option(ENABLE_LIBRI "Enable LibRI for hybrid functional"
OFF "ENABLE_LCAO;ENABLE_MPI" OFF)
cmake_dependent_option(ENABLE_EXX_DEV "Enable LibRI developing features" OFF "ENABLE_LIBRI" OFF)
cmake_dependent_option(ENABLE_PEXSI "Enable PEXSI for LCAO" OFF "ENABLE_LCAO;ENABLE_MPI" OFF)
cmake_dependent_option(ENABLE_MLALGO "Enable the machine learning algorithms"
OFF "ENABLE_LCAO;ENABLE_MPI" OFF)

# EXX_DEV works with libRI PR#10 which is not merged into main branch; disabling it
# cmake_dependent_option(ENABLE_EXX_DEV "Enable LibRI developing features" OFF "ENABLE_LIBRI" OFF)

# Two-center FFT is only used in LCAO
cmake_dependent_option(ENABLE_FFT_TWO_CENTER "Enable FFT-based two-center integral method"
ON "ENABLE_LCAO" OFF)
Expand Down Expand Up @@ -136,27 +138,6 @@ if(NOT DEFINED NVHPC_ROOT_DIR AND DEFINED ENV{NVHPC_ROOT})
CACHE PATH "Path to NVIDIA HPC SDK root directory.")
endif()

# Feature definitions are collected while options and dependencies are resolved
# below. They are applied to targets in source/CMakeLists.txt.
set_property(GLOBAL PROPERTY ABACUS_FEATURE_DEFINITIONS "")

function(abacus_normalize_definitions out_var)
set(_defs)
foreach(_def IN LISTS ARGN)
if(_def MATCHES "^-D(.+)")
list(APPEND _defs "${CMAKE_MATCH_1}")
else()
list(APPEND _defs "${_def}")
endif()
endforeach()
set(${out_var} ${_defs} PARENT_SCOPE)
endfunction()

function(abacus_add_feature_definitions)
abacus_normalize_definitions(_defs ${ARGN})
set_property(GLOBAL APPEND PROPERTY ABACUS_FEATURE_DEFINITIONS ${_defs})
endfunction()

# enable json support
if(ENABLE_RAPIDJSON)
find_package(RapidJSON CONFIG REQUIRED)
Expand All @@ -167,7 +148,6 @@ if(ENABLE_RAPIDJSON)
"Check if your RapidJSON installation provides a complete exported CMake configuration."
)
endif()
abacus_add_feature_definitions(__RAPIDJSON)
endif()

# get commit info
Expand All @@ -193,7 +173,6 @@ if(COMMIT_INFO)
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_COMMIT_DATE_RESULT)
if(GIT_COMMIT_HASH_RESULT EQUAL 0 AND GIT_COMMIT_DATE_RESULT EQUAL 0)
abacus_add_feature_definitions(COMMIT_INFO)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/commit.h"
"#define COMMIT \"${GIT_COMMIT_HASH} (${GIT_COMMIT_DATE})\"\n")
set(ABACUS_COMMIT_INFO_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
Expand Down Expand Up @@ -272,14 +251,6 @@ if (USE_DSP)
set(ABACUS_BIN_NAME abacus_dsp)
endif()

if (USE_CUDA_ON_DCU)
abacus_add_feature_definitions(__CUDA_ON_DCU)
endif()

if (USE_CUDA_MPI)
abacus_add_feature_definitions(__CUDA_MPI)
endif()

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${PROJECT_SOURCE_DIR}/cmake/modules")
Expand Down Expand Up @@ -359,45 +330,23 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
)
endif()

if(ENABLE_ABACUS_LIBM)
abacus_add_feature_definitions(__ABACUS_LIBM)
endif()

if(ENABLE_NATIVE_OPTIMIZATION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native")
endif()

# Windows (native build, e.g. MinGW-w64 or MSVC) portability defines:
# _USE_MATH_DEFINES - expose M_PI and friends from <cmath>
# NOMINMAX - stop <windows.h> defining min()/max() macros
# _CRT_SECURE_NO_WARNINGS - silence CRT "use _s function" deprecations
if(WIN32)
abacus_add_feature_definitions(_USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS)
endif()

if(ENABLE_LCAO)
abacus_add_feature_definitions(__LCAO)
if(ENABLE_ELPA)
find_package(ELPA REQUIRED)
abacus_add_feature_definitions(__ELPA)
endif()
if(ENABLE_FFT_TWO_CENTER)
abacus_add_feature_definitions(USE_NEW_TWO_CENTER)
endif()
if(ENABLE_PEXSI)
find_package(PEXSI REQUIRED CONFIG)
if(PEXSI_VERSION VERSION_LESS "2.0.0")
message(FATAL_ERROR "PEXSI >= 2.0.0 is required")
endif()
abacus_add_feature_definitions(__PEXSI)
set(CMAKE_CXX_STANDARD 14)
endif()
endif()

if(DEBUG_INFO)
abacus_add_feature_definitions(__DEBUG)
endif()

if(ENABLE_MPI)
if(NOT CMAKE_CROSSCOMPILING)
# FindMPI runs a probe executable to determine the MPI library version,
Expand All @@ -406,18 +355,9 @@ if(ENABLE_MPI)
set(MPI_DETERMINE_LIBRARY_VERSION TRUE)
endif()
find_package(MPI COMPONENTS CXX REQUIRED)
abacus_add_feature_definitions(__MPI)
endif()


if (USE_DSP)
abacus_add_feature_definitions(__DSP)
endif()



if (USE_SW)
abacus_add_feature_definitions(__SW)
if(USE_SW)
set(SW ON)
endif()

Expand All @@ -440,10 +380,8 @@ if(USE_KML)
endif()

find_package(KML REQUIRED COMPONENTS ${_kml_components})
abacus_add_feature_definitions(__KML)
elseif(MKLROOT OR MKL_ROOT)
find_package(MKL REQUIRED)
abacus_add_feature_definitions(__MKL)
elseif(NOT USE_SW)
find_package(Lapack REQUIRED)
# ScaLAPACK is a distributed-memory library and is only needed for the
Expand Down Expand Up @@ -538,16 +476,13 @@ if(USE_CUDA)
endif()
enable_language(CUDA)
if(USE_CUDA)
abacus_add_feature_definitions(__CUDA)
abacus_add_feature_definitions(__UT_USE_CUDA)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -g -G" CACHE STRING "CUDA flags for debug build" FORCE)
endif()
if (ENABLE_OPENMP AND OpenMP_CXX_FOUND)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS}" CACHE STRING "CUDA flags" FORCE)
endif()
if (ENABLE_NCCL_PARALLEL_DEVICE)
abacus_add_feature_definitions(__NCCL_PARALLEL_DEVICE)
include(cmake/modules/SetupNccl.cmake)
abacus_setup_nccl()
endif()
Expand Down Expand Up @@ -616,9 +551,6 @@ if(USE_ROCM)
)
endif()

abacus_add_feature_definitions(__ROCM)
abacus_add_feature_definitions(__UT_USE_ROCM)
abacus_add_feature_definitions(__HIP_PLATFORM_HCC__)
endif()

if(ENABLE_ASAN)
Expand All @@ -632,10 +564,6 @@ if(ENABLE_ASAN)
add_link_options(-fsanitize=address)
endif()

if(ENABLE_FLOAT_FFTW)
abacus_add_feature_definitions(__ENABLE_FLOAT_FFTW)
endif()

if(ENABLE_MLALGO)
find_path(libnpy_SOURCE_DIR npy.hpp HINTS ${libnpy_INCLUDE_DIR})
if(NOT libnpy_SOURCE_DIR)
Expand All @@ -648,8 +576,6 @@ if(ENABLE_MLALGO)
FetchContent_MakeAvailable(libnpy)
else()
endif()

abacus_add_feature_definitions(__MLALGO)
endif()

# Torch uses outdated components to detect CUDA arch, causing failure on
Expand Down Expand Up @@ -683,7 +609,6 @@ if (ENABLE_CNPY)

# find ZLIB and link
find_package(ZLIB REQUIRED)
abacus_add_feature_definitions(__USECNPY)
endif()

function(git_submodule_update)
Expand Down Expand Up @@ -714,47 +639,29 @@ if(ENABLE_LIBRI)
find_package(LibRI REQUIRED)
find_package(LibComm REQUIRED)
find_package(cereal REQUIRED CONFIG)
abacus_add_feature_definitions(__EXX EXX_DM=3 EXX_H_COMM=2 TEST_EXX_LCAO=0
TEST_EXX_RADIAL=1)
if(ENABLE_EXX_DEV)
abacus_add_feature_definitions(__EXX_DEV)
endif()
endif()

if(ENABLE_LIBXC)
find_package(Libxc CONFIG REQUIRED)
if(Libxc_VERSION VERSION_LESS "5.1.7")
message(FATAL_ERROR "Libxc >= 5.1.7 is required")
endif()
abacus_add_feature_definitions(USE_LIBXC)
endif()

if(DEFINED DeePMD_DIR)
abacus_add_feature_definitions(__DPMD HIGH_PREC)
add_compile_options(-Wl,--no-as-needed)
find_package(DeePMD REQUIRED)
if(DeePMDC_FOUND)
abacus_add_feature_definitions(__DPMDC)
endif()
endif()

if(DEFINED NEP_DIR)
find_package(NEP REQUIRED)

if(NEP_FOUND)
abacus_add_feature_definitions(__NEP)
endif()
endif()

if(DEFINED TensorFlow_DIR)
find_package(TensorFlow REQUIRED)
endif()

abacus_add_feature_definitions(__FFTW3 __SELINV METIS)

if(MATH_INFO)
message(STATUS "Will gather math lib info.")
abacus_add_feature_definitions(GATHER_INFO)
# modifications on blas_connector and lapack_connector
endif()

Expand Down
Loading
Loading