Skip to content
Snippets Groups Projects
Commit e6225406 authored by Tomáš Pecka's avatar Tomáš Pecka Committed by Jan Trávníček
Browse files

CMake: Configure SystemDeps also inside local project.conf

parent ff9fce63
No related branches found
No related tags found
No related merge requests found
Pipeline #23366 passed
......@@ -199,8 +199,8 @@ class Generator:
 
@classmethod
def generate_library(cls, project, dry_run):
sys_includes, sys_libs, finds = cls._handle_system_deps(project.system_deps)
test_sys_includes, test_sys_libs, test_finds = cls._handle_system_deps(project.system_deps_test)
sys_includes, sys_libs, finds = cls._handle_system_deps(project, project.system_deps)
test_sys_includes, test_sys_libs, test_finds = cls._handle_system_deps(project, project.system_deps_test)
 
with SmartOpen("CMakeLists.txt", 'w', directory=project.path, dry_run=dry_run) as f:
f.write(CATEGORIES[project.category].format(
......@@ -219,7 +219,7 @@ class Generator:
 
@classmethod
def generate_executable(cls, project, dry_run):
sys_includes, sys_libs, finds = cls._handle_system_deps(project.system_deps)
sys_includes, sys_libs, finds = cls._handle_system_deps(project, project.system_deps)
 
with SmartOpen("CMakeLists.txt", 'w', directory=project.path, dry_run=dry_run) as f:
f.write(CATEGORIES[project.category].format(
......@@ -232,15 +232,30 @@ class Generator:
))
 
@staticmethod
def _handle_system_deps(system_deps):
def _handle_system_deps(project, system_deps):
libs, incl, find = [], [], []
def update(cfg, dep, incl, libs, find):
# try access the section, raises ConfigException if not present
Config.get_section(cfg, 'CMake:Deps:{}'.format(dep))
incl += Config.get_array(cfg, 'CMake:Deps:{}'.format(dep), 'include', fallback=[])
libs += Config.get_array(cfg, 'CMake:Deps:{}'.format(dep), 'link', fallback=[])
f = Config.get(CONFIG, 'CMake:Deps:{}'.format(dep), 'find', fallback="")
if f is not "":
find.append(f)
for dep in system_deps:
incl = incl + Config.get_array(CONFIG, 'CMake:Deps:{}'.format(dep), 'include', fallback=[])
libs = libs + Config.get_array(CONFIG, 'CMake:Deps:{}'.format(dep), 'link', fallback=[])
try:
find.append(Config.get(CONFIG, 'CMake:Deps:{}'.format(dep), 'find'))
# first, try to find CMake:Deps:{} section in projects's conf
update(project._config, dep, incl, libs, find)
except ConfigException:
pass
try:
# then in main conf
update(CONFIG, dep, incl, libs, find)
except ConfigException:
# warning!
print("Warning: System dependency '{}' is not configured".format(dep), file=sys.stderr)
 
return incl, libs, find
 
......
......@@ -4,3 +4,6 @@ category: library
[Dependencies]
project: alib2xml alib2common alib2abstraction alib2measure alib2std
system: xml2 stdc++fs
[CMake:Deps:stdc++fs]
link: stdc++fs
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment