Skip to content

Commit 1dd484d

Browse files
authored
Fix: Restore incremental builds with pkg-config ELPA (#7662)
* Fix: Restore incremental builds with pkg-config ELPA * Change ${ELPA_PKG_VERSION} to ELPA_PKG_VERSION
1 parent bf54db6 commit 1dd484d

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

cmake/modules/FindELPA.cmake

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
# Deprecated (TODO: Remove this part)
88
# ========================================================================
99

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+
1021
# Compatible layer towards old manual routines
1122
if(DEFINED ELPA_DIR)
1223
message(WARNING "ELPA_DIR is deprecated and will be removed in the future release.")
@@ -47,20 +58,26 @@ endif()
4758

4859
# ========================================================================
4960

61+
# TODO: Make pkg-config discovery unconditional after removing the deprecated
62+
# manual discovery path.
5063
if(NOT ELPA_INCLUDE_DIRS)
5164
find_package(PkgConfig)
5265
if(NOT PKG_CONFIG_FOUND)
5366
message(FATAL_ERROR "Pkg-config is needed to get all information about the ELPA library")
5467
endif()
5568
# Find preferred library corresponding with ABACUS configuration first
5669
if(ENABLE_OPENMP)
57-
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp elpa)
70+
pkg_search_module(ELPA_PKG REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp elpa)
5871
else()
59-
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa)
72+
pkg_search_module(ELPA_PKG REQUIRED IMPORTED_TARGET GLOBAL elpa)
6073
endif()
61-
if(${ELPA_VERSION} VERSION_LESS "2021.05.001")
74+
if(ELPA_PKG_VERSION VERSION_LESS "2021.05.001")
6275
message(FATAL_ERROR "ELPA version >= 2021.05.001 is required.")
6376
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})
6481
endif()
6582

6683
# Handle the QUIET and REQUIRED arguments and
@@ -73,18 +90,23 @@ if(ELPA_FOUND)
7390
list(GET ELPA_LINK_LIBRARIES 0 ELPA_LIBRARY)
7491
set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIRS})
7592
if(NOT TARGET ELPA::ELPA)
76-
add_library(ELPA::ELPA UNKNOWN IMPORTED)
77-
set_target_properties(ELPA::ELPA PROPERTIES
78-
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
79-
IMPORTED_LOCATION "${ELPA_LIBRARY}"
80-
INTERFACE_INCLUDE_DIRECTORIES "${ELPA_INCLUDE_DIR}")
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()
81103
endif()
82104
endif()
83105

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

86108
# Compability workaround for ELPA_DIR
87-
# TODO: Remove this check
109+
# TODO: Remove this check with the deprecated ELPA_DIR path.
88110
include(CheckCXXSourceCompiles)
89111
check_cxx_source_compiles("
90112
#include <elpa/elpa_version.h>

0 commit comments

Comments
 (0)