Skip to content

Fix compilation of CMake projects

Use builddir when building CMake recipes

CMake 3.10.2 has some weird behavior that we can extrapolate to some other old versions:

  • Old CMake versions don't work with whitespace after -H or -B

Allow building CMake recipes using system libraries

Because both configure methods from CMake class and base class MakefilesBase are decorated with @async_modify_environment, the following error appears when trying to build a CMake project recipe with use_system_libs equals True:

Traceback (most recent call last):
  File "./cerbero/cerbero/build/oven.py", line 202, in _cook_recipe
    loop.run_until_complete(stepfunc(recipe))
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "./cerbero/cerbero/build/recipe.py", line 54, in wrapped
    await ret
  File "./cerbero/cerbero/build/build.py", line 170, in call
    res = await func(*args)
  File "./cerbero/cerbero/build/build.py", line 595, in configure
    await MakefilesBase.configure(self)
  File "./cerbero/cerbero/build/build.py", line 168, in call
    self._add_system_libs()
  File "./cerbero/cerbero/build/build.py", line 327, in _add_system_libs
    self.set_env(var, val)
  File "./cerbero/cerbero/build/build.py", line 260, in set_env
    self.check_reentrancy()
  File "./cerbero/cerbero/build/build.py", line 247, in check_reentrancy
    raise RuntimeError('Do not modify the env inside @modify_environment, it will have no effect')
RuntimeError: Do not modify the env inside @modify_environment, it will have no effect

Commit 2af16912 added changes preventing modifying environment twice and raising an exception when someone tries to do that.

The CMake.configure() method requires to be called afeter modifying environment because it uses environment variables to set the cmake command options.

There are several ways to fix this, but I think it's the simplest one. Remove @async_modify_environment from MakefilesBase.configure and require derived classes to add it. Other option would be not to raise an exception when trying to modify environment afetr calling the decorator but it might lead to less secure code and unexpected environmet changes during the build when not controlled properly.

Edited by Nirbheek Chauhan

Merge request reports

Loading