Skip to content

Commit 92c517e

Browse files
na-trium-144jpakkane
authored andcommitted
output PACKAGE_NOT_FOUND_MESSAGE as warning when CMake package is not found
1 parent b7b45bb commit 92c517e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

mesonbuild/dependencies/cmake.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,16 @@ def _detect_dep(self, name: str, package_version: str, modules: T.List[T.Tuple[s
414414
# Whether the package is found or not is always stored in PACKAGE_FOUND
415415
self.is_found = self.traceparser.var_to_bool('PACKAGE_FOUND')
416416
if not self.is_found:
417-
return
417+
not_found_message = self.traceparser.get_cmake_var('PACKAGE_NOT_FOUND_MESSAGE')
418+
if len(not_found_message) > 0:
419+
mlog.warning(
420+
'CMake reported that the package {} was not found with the following reason:\n'
421+
'{}'.format(name, not_found_message[0]))
422+
else:
423+
mlog.warning(
424+
'CMake reported that the package {} was not found, '
425+
'even though Meson\'s preliminary check succeeded.'.format(name))
426+
raise self._gen_exception('PACKAGE_FOUND is false')
418427

419428
# Try to detect the version
420429
vers_raw = self.traceparser.get_cmake_var('PACKAGE_VERSION')

mesonbuild/dependencies/data/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,9 @@ if(${_packageName}_FOUND OR ${PACKAGE_NAME}_FOUND)
100100
set(PACKAGE_DEFINITIONS "${${definitions}}")
101101
set(PACKAGE_LIBRARIES "${${libs}}")
102102
endif()
103+
104+
if(${_packageName}_NOT_FOUND_MESSAGE)
105+
set(PACKAGE_NOT_FOUND_MESSAGE "${${_packageName}_NOT_FOUND_MESSAGE}")
106+
elseif(${PACKAGE_NAME}_NOT_FOUND_MESSAGE)
107+
set(PACKAGE_NOT_FOUND_MESSAGE "${${PACKAGE_NAME}_NOT_FOUND_MESSAGE}")
108+
endif()

0 commit comments

Comments
 (0)