@@ -214,30 +214,35 @@ if(GCC_INSTALL_PREFIX AND NOT USE_DEPRECATED_GCC_INSTALL_PREFIX)
214214 "See https://github.com/llvm/llvm-project/pull/77537 for detail." )
215215endif ()
216216
217- if (APPLE )
217+ cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS SDK." OFF "APPLE" OFF )
218+
219+ if (CLANG_USE_XCSELECT)
220+ if (DEFAULT_SYSROOT)
221+ message (FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with CLANG_USE_XCSELECT." )
222+ endif ()
223+
218224 check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H)
219- if (CLANG_HAVE_XCSELECT_H)
220- include (CheckSymbolExists)
221- list (APPEND CMAKE_REQUIRED_LIBRARIES xcselect)
222- check_symbol_exists(xcselect_host_sdk_path xcselect.h CLANG_HAVE_XCSELECT_HOST_SDK_PATH)
223- list (REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect)
225+ if (NOT CLANG_HAVE_XCSELECT_H)
226+ message (FATAL_ERROR "CLANG_USE_XCSELECT is enabled but xcselect.h was not found." )
224227 endif ()
225- endif ()
226228
227- cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS SDK." OFF
228- "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF )
229+ include (CheckSymbolExists)
230+ list (APPEND CMAKE_REQUIRED_LIBRARIES xcselect)
231+ check_symbol_exists(xcselect_host_sdk_path xcselect.h CLANG_HAVE_XCSELECT_HOST_SDK_PATH)
232+ list (REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect)
229233
230- if (DEFAULT_SYSROOT AND CLANG_USE_XCSELECT)
231- message (FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with CLANG_USE_XCSELECT." )
232- endif ()
234+ if (NOT CLANG_HAVE_XCSELECT_HOST_SDK_PATH)
235+ message (FATAL_ERROR "CLANG_USE_XCSELECT is enabled but either libxcselect is not available "
236+ "or it is missing xcselect_host_sdk_path." )
237+ endif ()
233238
234- if (CLANG_USE_XCSELECT)
235239 set (XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED)
236240 set (CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING
237241 "Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES} " )
238242 set_property (CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS ${XCSELECT_VALID_POLICIES} )
239243 string (TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} CLANG_XCSELECT_HOST_SDK_POLICY)
240244 list (JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX)
245+
241246 if (NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES "^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX} )$" )
242247 if (NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES)
243248 message (FATAL_ERROR
0 commit comments