Skip to content
Merged
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
40 changes: 31 additions & 9 deletions cmake/modules/FindELPA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
# Deprecated (TODO: Remove this part)
# ========================================================================

# Migrate caches created when FindPkgConfig used the public ELPA prefix.
if(DEFINED CACHE{ELPA_LIBRARIES})
get_property(_elpa_libraries_cache_type CACHE ELPA_LIBRARIES PROPERTY TYPE)
if(_elpa_libraries_cache_type STREQUAL "INTERNAL")
unset(ELPA_LIBRARIES CACHE)
unset(ELPA_INCLUDE_DIRS CACHE)
unset(ELPA_LINK_LIBRARIES CACHE)
endif()
endif()
unset(_elpa_libraries_cache_type)

# Compatible layer towards old manual routines
if(DEFINED ELPA_DIR)
message(WARNING "ELPA_DIR is deprecated and will be removed in the future release.")
Expand Down Expand Up @@ -47,20 +58,26 @@ endif()

# ========================================================================

# TODO: Make pkg-config discovery unconditional after removing the deprecated
# manual discovery path.
if(NOT ELPA_INCLUDE_DIRS)
find_package(PkgConfig)
if(NOT PKG_CONFIG_FOUND)
message(FATAL_ERROR "Pkg-config is needed to get all information about the ELPA library")
endif()
# Find preferred library corresponding with ABACUS configuration first
if(ENABLE_OPENMP)
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp elpa)
pkg_search_module(ELPA_PKG REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp elpa)
else()
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa)
pkg_search_module(ELPA_PKG REQUIRED IMPORTED_TARGET GLOBAL elpa)
endif()
if(${ELPA_VERSION} VERSION_LESS "2021.05.001")
if(ELPA_PKG_VERSION VERSION_LESS "2021.05.001")
message(FATAL_ERROR "ELPA version >= 2021.05.001 is required.")
endif()
set(ELPA_INCLUDE_DIRS ${ELPA_PKG_INCLUDE_DIRS})
set(ELPA_LINK_LIBRARIES ${ELPA_PKG_LINK_LIBRARIES})
set(ELPA_LIBRARIES ${ELPA_PKG_LIBRARIES})
set(ELPA_VERSION ${ELPA_PKG_VERSION})
endif()

# Handle the QUIET and REQUIRED arguments and
Expand All @@ -73,18 +90,23 @@ if(ELPA_FOUND)
list(GET ELPA_LINK_LIBRARIES 0 ELPA_LIBRARY)
set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIRS})
if(NOT TARGET ELPA::ELPA)
add_library(ELPA::ELPA UNKNOWN IMPORTED)
set_target_properties(ELPA::ELPA PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${ELPA_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ELPA_INCLUDE_DIR}")
# TODO: Remove the manual target fallback with the deprecated ELPA inputs.
if(TARGET PkgConfig::ELPA_PKG)
add_library(ELPA::ELPA ALIAS PkgConfig::ELPA_PKG)
else()
add_library(ELPA::ELPA UNKNOWN IMPORTED)
set_target_properties(ELPA::ELPA PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${ELPA_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ELPA_INCLUDE_DIR}")
endif()
endif()
endif()

set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ELPA_INCLUDE_DIR})

# Compability workaround for ELPA_DIR
# TODO: Remove this check
# TODO: Remove this check with the deprecated ELPA_DIR path.
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <elpa/elpa_version.h>
Expand Down
Loading