-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathfetch_mrcpp.cmake
63 lines (56 loc) · 2.1 KB
/
fetch_mrcpp.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
find_package(MRCPP CONFIG QUIET
NO_CMAKE_PATH
NO_CMAKE_PACKAGE_REGISTRY
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
)
if(TARGET MRCPP::mrcpp)
get_property(_loc TARGET MRCPP::mrcpp PROPERTY LOCATION)
message(STATUS "Found MRCPP: ${_loc} (found version ${MRCPP_VERSION})")
# check that the parallel configurations of MRChem and MRCPP are compatible
# these checks are only needed when picking up an installed library:
# if we build it ourselves, then the parallel configuration for MRCPP will follow that of MRChem
#
# 1. OMP MRChem + non-OMP MRCPP is not a great idea, but it's not problematic.
# We just emit a warning.
get_target_property(MRCPP_HAS_OMP MRCPP::mrcpp MRCPP_HAS_OMP)
if(ENABLE_OPENMP AND NOT MRCPP_HAS_OMP)
message(WARNING
"You are building MRChem with OpenMP, while using a non-OpenMP version of MRCPP!\
We recommend rebuilding MRCPP with OpenMP support."
)
endif()
# 1. MPI MRChem + non-MPI MRCPP will lead to runtime failures.
# Fail configuration with a fatal error.
get_target_property(MRCPP_HAS_MPI MRCPP::mrcpp MRCPP_HAS_MPI)
if(ENABLE_MPI AND NOT MRCPP_HAS_MPI)
message(FATAL_ERROR
"You cannot build MRChem with MPI and link against a non-MPI version of MRCPP!\
Rebuild MRCPP with MPI support or disable it for MRChem."
)
endif()
else()
message(STATUS "Suitable MRCPP could not be located. Fetching and building!")
include(FetchContent)
FetchContent_Declare(mrcpp_sources
QUIET
GIT_REPOSITORY
https://github.com/MRChemSoft/mrcpp.git
GIT_TAG
2f05eee26561313509b1e452e58efa2eadc18dca
)
FetchContent_GetProperties(mrcpp_sources)
set(CMAKE_BUILD_TYPE Release)
set(ENABLE_OPENMP ${ENABLE_OPENMP})
set(ENABLE_MPI ${ENABLE_MPI})
set(Eigen3_DIR ${eigen3_sources_BINARY_DIR})
set(PYTHON_INTERPRETER ${Python_EXECUTABLE})
set(ENABLE_TESTS ON CACHE BOOL "" FORCE)
set(ENABLE_EXAMPLES OFF CACHE BOOL "" FORCE)
if(NOT mrcpp_sources_POPULATED)
FetchContent_Populate(mrcpp_sources)
add_subdirectory(
${mrcpp_sources_SOURCE_DIR}
${mrcpp_sources_BINARY_DIR}
)
endif()
endif()