Skip to content

Commit

Permalink
aedi: support explicit module paths to keep cmake targets
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Jul 20, 2023
1 parent 2d47d70 commit 703b33e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions aedi/target/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def configure(self, state: BuildState):
def post_build(self, state: BuildState):
self.install(state)

def keep_module_target(self, state: BuildState, target: str):
def keep_module_target(self, state: BuildState, target: str, module_paths: typing.Sequence[Path] = ()):
import_patterns = (
r'list\s*\(APPEND\s+_cmake_import_check_targets\s+(?P<target>[\w:-]+)[\s)]',
r'list\s*\(APPEND\s+_cmake_import_check_files_for_(?P<target>[\w:-]+)\s',
Expand All @@ -476,12 +476,19 @@ def _keep_target(line: str):

return line

module = 'targets-release.cmake'
probe_modules = False

for probe_module in (module, self.name + module):
module_path = state.install_path / 'lib' / 'cmake' / self.name / probe_module
if not module_paths:
default_modules_path = state.install_path / 'lib' / 'cmake' / self.name
default_module_name = 'targets-release.cmake'
module_paths = (
default_modules_path / default_module_name,
default_modules_path / (self.name + default_module_name)
)
probe_modules = True

if module_path.exists():
for module_path in module_paths:
if not probe_modules or module_path.exists():
self.update_text_file(module_path, _keep_target)


Expand Down

0 comments on commit 703b33e

Please sign in to comment.