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

Sketchy missing header check #16518

Draft
wants to merge 1 commit into
base: develop2
Choose a base branch
from
Draft
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
25 changes: 24 additions & 1 deletion conan/tools/cmake/cmake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys

from conan.tools.build import build_jobs, cmd_args_to_string
from conan.tools.cmake.presets import load_cmake_presets
Expand Down Expand Up @@ -31,7 +32,7 @@ def _cmake_cmd_line_args(conanfile, generator):
return args


class CMake(object):
class CMake:
""" CMake helper to use together with the CMakeToolchain feature """

def __init__(self, conanfile):
Expand Down Expand Up @@ -182,6 +183,28 @@ def build(self, build_type=None, target=None, cli_args=None, build_tool_args=Non
"""
self._conanfile.output.info("Running CMake.build()")
self._build(build_type, target, cli_args, build_tool_args, stdout=stdout, stderr=stderr)
stderr = (stderr or sys.stderr)
stdout = (stdout or sys.stdout)

def _get_output(stream):
pos = stream.tell()
stream.seek(0)
output = stream.read()
stream.seek(pos)
return output

def _parse_missing_headers(output):
if "C1083" in output:
return True
if "file not found" in output:
return True
if "No such file or directory" in output:
return True

if _parse_missing_headers(_get_output(stderr)) or _parse_missing_headers(_get_output(stdout)):
self._conanfile.output.error("CMake: Missing headers, check your include directories")
self._conanfile.output.warn("CMake: This can be caused by missing dependencies")
self._conanfile.output.warn("CMake: Check the output above for more information")

def install(self, build_type=None, component=None, cli_args=None, stdout=None, stderr=None):
"""
Expand Down