-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Describe the bug
When trying the new workspace feature I was comparing how well this would fit to streamline our current workflow.
The majority of our package's conanfiles is using custom generate()
methods assigning cache variables based on the selected options, for example:
def generate(self):
...
tc = CMakeToolchain(self)
tc.cache_variables["BUILD_CLIENT_TOOLS"] = self.options.build_client_tools
tc.cache_variables["BUILD_DOCS"] = self.options.get_safe('build_docs', False)
For daily development we maintain a collection of profiles defining toolchains and options for the packages as required for the respective platforms.
[settings]
os=Linux
arch=x86_64
build_type=Release
[options]
pkg_a/*:build_client_tools=True
..
I tried to create a monolithic build style workspace using several of our packages and a conanws.py
as suggested in the docs:
from conan import Workspace
from conan import ConanFile
from conan.tools.cmake import CMakeDeps, CMakeToolchain, cmake_layout
import os
class MyWs(ConanFile):
""" This is a special conanfile, used only for workspace definition of layout
and generators. It shouldn't have requirements, tool_requirements. It shouldn't have
build() or package() methods
"""
settings = "os", "compiler", "build_type", "arch"
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.generate()
def layout(self):
cmake_layout(self)
class Ws(Workspace):
def root_conanfile(self):
return MyWs # Note this is the class name
def packages(self):
result = []
for f in ['pkg_a', 'pkg_b']:
conanfile = self.load_conanfile(os.path.join(self.folder, f))
result.append({"path": f, "ref": f"{conanfile.name}/{conanfile.version}"})
self.output.info(f"Workspace packages: {result}")
return result
Supplying one of our profiles while invoking conan workspace super-install ..
configures the projects but upon inspecting the generated presets file I found the cache variable definitions from packages be missing in the workspace' CMake presets.
Is that a defect indeed or just me holding it wrong?
Thanks.