33# Find the native ELPA headers and libraries through pkg-config.
44#
55
6- # ========================================================================
7- # Deprecated (TODO: Remove this part)
8- # ========================================================================
6+ find_package (PkgConfig REQUIRED )
97
10- # Migrate caches created when FindPkgConfig used the public ELPA prefix.
11- if (DEFINED CACHE{ELPA_LIBRARIES})
12- get_property (_elpa_libraries_cache_type CACHE ELPA_LIBRARIES PROPERTY TYPE)
13- if (_elpa_libraries_cache_type STREQUAL "INTERNAL" )
14- unset (ELPA_LIBRARIES CACHE )
15- unset (ELPA_INCLUDE_DIRS CACHE )
16- unset (ELPA_LINK_LIBRARIES CACHE )
17- endif ()
18- endif ()
19- unset (_elpa_libraries_cache_type)
20-
21- # Compatible layer towards old manual routines
22- if (DEFINED ELPA_DIR)
23- message (WARNING "ELPA_DIR is deprecated and will be removed in the future release." )
24- endif ()
25- if (DEFINED ELPA_INCLUDE_DIR)
26- set (ELPA_INCLUDE_DIRS ${ELPA_INCLUDE_DIR} )
27- endif ()
28- if (DEFINED ELPA_LIBRARIES)
29- set (ELPA_LINK_LIBRARIES ${ELPA_LIBRARIES} )
30- endif ()
31-
32- find_path (ELPA_INCLUDE_DIRS
33- elpa/elpa.h
34- HINTS ${ELPA_DIR}
35- PATH_SUFFIXES "include" "include/elpa"
36- )
37- # Fix #3589
38- # First if judges if ELPA dir specified
39- if (ELPA_INCLUDE_DIRS MATCHES "^/usr/include/elpa/.*" )
40- # Second if judges if global visible ELPA header found
41- if (DEFINED ELPA_DIR OR CMAKE_PREFIX_PATH MATCHES ".*elpa.*" )
42- unset (ELPA_INCLUDE_DIRS)
43- endif ()
44- endif ()
8+ # Find preferred library corresponding with ABACUS configuration first
459if (ENABLE_OPENMP)
46- find_library (ELPA_LINK_LIBRARIES
47- NAMES elpa_openmp elpa
48- HINTS ${ELPA_DIR}
49- PATH_SUFFIXES "lib"
50- )
10+ pkg_search_module (ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp elpa )
5111else ()
52- find_library (ELPA_LINK_LIBRARIES
53- NAMES elpa
54- HINTS ${ELPA_DIR}
55- PATH_SUFFIXES "lib"
56- )
57- endif ()
58-
59- # ========================================================================
60-
61- # TODO: Make pkg-config discovery unconditional after removing the deprecated
62- # manual discovery path.
63- if (NOT ELPA_INCLUDE_DIRS)
64- find_package (PkgConfig )
65- if (NOT PKG_CONFIG_FOUND)
66- message (FATAL_ERROR "Pkg-config is needed to get all information about the ELPA library" )
67- endif ()
68- # Find preferred library corresponding with ABACUS configuration first
69- if (ENABLE_OPENMP)
70- pkg_search_module (ELPA_PKG REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp elpa )
71- else ()
72- pkg_search_module (ELPA_PKG REQUIRED IMPORTED_TARGET GLOBAL elpa )
73- endif ()
74- if (ELPA_PKG_VERSION VERSION_LESS "2021.05.001" )
75- message (FATAL_ERROR "ELPA version >= 2021.05.001 is required." )
76- endif ()
77- set (ELPA_INCLUDE_DIRS ${ELPA_PKG_INCLUDE_DIRS} )
78- set (ELPA_LINK_LIBRARIES ${ELPA_PKG_LINK_LIBRARIES} )
79- set (ELPA_LIBRARIES ${ELPA_PKG_LIBRARIES} )
80- set (ELPA_VERSION ${ELPA_PKG_VERSION} )
12+ pkg_search_module (ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa )
8113endif ()
8214
8315# Handle the QUIET and REQUIRED arguments and
@@ -90,35 +22,14 @@ if(ELPA_FOUND)
9022 list (GET ELPA_LINK_LIBRARIES 0 ELPA_LIBRARY)
9123 set (ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIRS} )
9224 if (NOT TARGET ELPA::ELPA)
93- # TODO: Remove the manual target fallback with the deprecated ELPA inputs.
94- if (TARGET PkgConfig::ELPA_PKG)
95- add_library (ELPA::ELPA ALIAS PkgConfig::ELPA_PKG )
96- else ()
97- add_library (ELPA::ELPA UNKNOWN IMPORTED )
98- set_target_properties (ELPA::ELPA PROPERTIES
99- IMPORTED_LINK_INTERFACE_LANGUAGES "C"
100- IMPORTED_LOCATION "${ELPA_LIBRARY} "
101- INTERFACE_INCLUDE_DIRECTORIES "${ELPA_INCLUDE_DIR} " )
102- endif ()
25+ add_library (ELPA::ELPA UNKNOWN IMPORTED )
26+ set_target_properties (ELPA::ELPA PROPERTIES
27+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
28+ IMPORTED_LOCATION "${ELPA_LIBRARY} "
29+ INTERFACE_INCLUDE_DIRECTORIES "${ELPA_INCLUDE_DIR} " )
10330 endif ()
10431endif ()
10532
10633set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ELPA_INCLUDE_DIR} )
10734
108- # Compability workaround for ELPA_DIR
109- # TODO: Remove this check with the deprecated ELPA_DIR path.
110- include (CheckCXXSourceCompiles )
111- check_cxx_source_compiles ("
112- #include <elpa/elpa_version.h>
113- #if ELPA_API_VERSION < 20210430
114- #error ELPA version is too old.
115- #endif
116- int main(){}
117- "
118- ELPA_VERSION_SATISFIES
119- )
120- if (NOT ELPA_VERSION_SATISFIES)
121- message (FATAL_ERROR "ELPA version is too old. We support version 2021 or higher." )
122- endif ()
123-
12435mark_as_advanced (ELPA_INCLUDE_DIR ELPA_LIBRARY )
0 commit comments