Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output PACKAGE_NOT_FOUND_MESSAGE as warning when CMake package is not found #14216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion mesonbuild/dependencies/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,16 @@ def _detect_dep(self, name: str, package_version: str, modules: T.List[T.Tuple[s
# 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')
Expand Down
6 changes: 6 additions & 0 deletions mesonbuild/dependencies/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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