From d05711feb0cee0af17264542fdc3f3b083c83090 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 15 Aug 2020 12:06:06 +0300 Subject: [PATCH] fix detection of target name from cmake config file all supported targets are now detected correctly --- build.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 6e97e19e..f930209f 100755 --- a/build.py +++ b/build.py @@ -423,6 +423,22 @@ class Builder(object): if self.target.post_build: self.target.post_build(self) + @staticmethod + def extract_project_name(line: str): + project_name = None + + # Try to get project name without whitespaces in it + match = re.search(r'project\s*\(\s*(\w[\w-]+)', line, re.IGNORECASE) + + if not match: + # Try to get project name that contains whitespaces + match = re.search(r'project\s*\(\s*"?(\w[\s\w-]+)"?', line, re.IGNORECASE) + + if match: + project_name = match.group(1) + + return project_name + def _detect_target(self): cmakelists_path = None @@ -438,9 +454,9 @@ class Builder(object): project_name = None for line in open(cmakelists_path).readlines(): - match = re.search(r'project\s*\(\s*"?(\w[\s\w-]+)"?', line, re.IGNORECASE) - if match: - project_name = match.group(1).lower() + project_name = Builder.extract_project_name(line) + if project_name: + project_name = project_name.lower() break assert project_name