Skip to content

Commit 24c1517

Browse files
committed
Move abacus_rename_option before cmake_dependent_option
1 parent 5959d29 commit 24c1517

1 file changed

Lines changed: 25 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ option(ENABLE_GOOGLEBENCH "Enable GOOGLE-benchmark usage" OFF)
6565
option(ENABLE_RAPIDJSON "Enable rapid-json usage" OFF)
6666
option(ENABLE_CNPY "Enable cnpy usage" OFF)
6767

68+
# ==============================================================================
69+
# Rename deprecated options (TODO: Remove this section in the future release)
70+
# This must appear before cmake_dependent_options so their cached value is
71+
# preserved even when the dependencies are unavailable
72+
# ==============================================================================
73+
function(abacus_rename_option old_name new_name)
74+
get_property(_old_defined CACHE "${old_name}" PROPERTY TYPE SET)
75+
if(NOT _old_defined)
76+
return()
77+
endif()
78+
message(DEPRECATION "${old_name} has been renamed to ${new_name}.")
79+
get_property(_type CACHE "${new_name}" PROPERTY TYPE)
80+
get_property(_help CACHE "${new_name}" PROPERTY HELPSTRING)
81+
set("${new_name}" "${${old_name}}" CACHE "${_type}" "${_help}" FORCE)
82+
unset("${old_name}" CACHE)
83+
endfunction()
84+
abacus_rename_option(USE_OPENMP ENABLE_OPENMP)
85+
abacus_rename_option(USE_ABACUS_LIBM ENABLE_ABACUS_LIBM)
86+
abacus_rename_option(USE_ELPA ENABLE_ELPA)
87+
abacus_rename_option(INFO MATH_INFO)
88+
abacus_rename_option(EXX_DEV ENABLE_EXX_DEV)
89+
# ==============================================================================
90+
6891
# Options requiring MPI and LCAO
6992
cmake_dependent_option(ENABLE_ELPA "Enable ELPA for LCAO" ON "ENABLE_LCAO;ENABLE_MPI" OFF)
7093
cmake_dependent_option(ENABLE_LIBRI "Enable LibRI for hybrid functional"
@@ -90,26 +113,8 @@ cmake_dependent_option(ENABLE_NCCL_PARALLEL_DEVICE
90113
"Enable NCCL-backed collectives in parallel_device; requires MPI"
91114
OFF "USE_CUDA;ENABLE_MPI" OFF)
92115

93-
# ==============================================================================
94-
# Deprecated options (TODO: Remove this section in the future release)
95-
# ==============================================================================
96-
function(abacus_rename_option old_name new_name)
97-
get_property(_old_defined CACHE "${old_name}" PROPERTY TYPE SET)
98-
if(NOT _old_defined)
99-
return()
100-
endif()
101-
message(DEPRECATION "${old_name} has been renamed to ${new_name}.")
102-
get_property(_type CACHE "${new_name}" PROPERTY TYPE)
103-
get_property(_help CACHE "${new_name}" PROPERTY HELPSTRING)
104-
set("${new_name}" "${${old_name}}" CACHE "${_type}" "${_help}" FORCE)
105-
unset("${old_name}" CACHE)
106-
endfunction()
107-
abacus_rename_option(USE_OPENMP ENABLE_OPENMP)
108-
abacus_rename_option(USE_ABACUS_LIBM ENABLE_ABACUS_LIBM)
109-
abacus_rename_option(USE_ELPA ENABLE_ELPA)
110-
abacus_rename_option(INFO MATH_INFO)
111-
abacus_rename_option(EXX_DEV ENABLE_EXX_DEV)
112-
116+
# Deprecated ENABLE_LIBCOMM
117+
# TODO: Remove this section in the future release
113118
if(DEFINED CACHE{ENABLE_LIBCOMM})
114119
message(
115120
DEPRECATION
@@ -126,7 +131,6 @@ if(DEFINED CACHE{ENABLE_LIBCOMM})
126131
endif()
127132
unset(ENABLE_LIBCOMM CACHE)
128133
endif()
129-
# ==============================================================================
130134

131135
# CTest defines BUILD_TESTING when it is first included. Include it only after
132136
# ABACUS has declared its OFF-by-default option above.

0 commit comments

Comments
 (0)