output PACKAGE_NOT_FOUND_MESSAGE as warning when CMake package is not found

pull/14216/head
na-trium-144 1 month ago
parent b825faebaf
commit 74204667f5
  1. 11
      mesonbuild/dependencies/cmake.py
  2. 6
      mesonbuild/dependencies/data/CMakeLists.txt

@ -414,7 +414,16 @@ class CMakeDependency(ExternalDependency):
# Whether the package is found or not is always stored in PACKAGE_FOUND
self.is_found = self.traceparser.var_to_bool('PACKAGE_FOUND')
if not self.is_found:
return
not_found_message = self.traceparser.get_cmake_var('PACKAGE_NOT_FOUND_MESSAGE')
if len(not_found_message) > 0:
mlog.warning(
'CMake reported that the package {} was not found with the following reason:\n'
'{}'.format(name, not_found_message[0]))
else:
mlog.warning(
'CMake reported that the package {} was not found, '
'even though Meson\'s preliminary check succeeded.'.format(name))
raise self._gen_exception('PACKAGE_FOUND is false')
# Try to detect the version
vers_raw = self.traceparser.get_cmake_var('PACKAGE_VERSION')

@ -100,3 +100,9 @@ if(${_packageName}_FOUND OR ${PACKAGE_NAME}_FOUND)
set(PACKAGE_DEFINITIONS "${${definitions}}")
set(PACKAGE_LIBRARIES "${${libs}}")
endif()
if(${_packageName}_NOT_FOUND_MESSAGE)
set(PACKAGE_NOT_FOUND_MESSAGE "${${_packageName}_NOT_FOUND_MESSAGE}")
elseif(${PACKAGE_NAME}_NOT_FOUND_MESSAGE)
set(PACKAGE_NOT_FOUND_MESSAGE "${${PACKAGE_NAME}_NOT_FOUND_MESSAGE}")
endif()

Loading…
Cancel
Save