Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/cmakedeps tool no build type #13267

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions conan/tools/cmake/cmakedeps/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,11 @@ def filename(self):

@property
def configuration(self):
if not self.require.build:
return self.cmakedeps.configuration \
if self.cmakedeps.configuration else None
else:
return self.conanfile.settings_build.get_safe("build_type")
return self.cmakedeps.configuration

@property
def arch(self):
if not self.require.build:
return self.cmakedeps.arch if self.cmakedeps.arch else None
else:
return self.conanfile.settings_build.get_safe("arch")
return self.cmakedeps.arch

@property
def config_suffix(self):
Expand Down
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
REVISIONS = "revisions" # Only when enabled in config, not by default look at server_launcher.py
OAUTH_TOKEN = "oauth_token"

__version__ = '2.0.0-dev'
__version__ = '2.0.1-dev'
memsharded marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def build(self):


def test_custom_configuration(client):
""" The configuration may differ from the build context and the host context"""
""" The configuration in the build context is still the same than the host context"""
conanfile = textwrap.dedent("""
from conan import ConanFile
from conan.tools.cmake import CMakeDeps
Expand All @@ -366,12 +366,12 @@ def generate(self):
client.run("install . -pr:h default -s:b build_type=RelWithDebInfo"
" -pr:b default -s:b arch=x86 --build missing")
curdir = client.current_folder
data_name_context_build = "liba_build-relwithdebinfo-x86-data.cmake"
data_name_context_build = f"liba_build-debug-{host_arch}-data.cmake"
data_name_context_host = f"liba-debug-{host_arch}-data.cmake"
assert os.path.exists(os.path.join(curdir, data_name_context_build))
assert os.path.exists(os.path.join(curdir, data_name_context_host))

assert "set(liba_build_INCLUDE_DIRS_RELWITHDEBINFO" in \
assert "set(liba_build_INCLUDE_DIRS_DEBUG" in \
open(os.path.join(curdir, data_name_context_build)).read()
assert "set(liba_INCLUDE_DIRS_DEBUG" in \
open(os.path.join(curdir, data_name_context_host)).read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,38 @@ def build(self):
# The debug binaries are missing, so adding --build=missing
c.run("create example -pr:b=default -pr:h=default -s:h build_type=Debug --build=missing "
"--build=example")

# listed as both requires and build_requires
c.assert_listed_require({"example/1.0": "Cache"})
c.assert_listed_require({"example/1.0": "Cache"}, build=True)


def test_using_package_module():
"""
This crashed, because the profile "build" didn't have "build_type"
https://github.com/conan-io/conan/issues/13209
"""
c = TestClient()
c.save({"conanfile.py": GenConanfile("tool", "0.1")})
c.run("create .")

consumer = textwrap.dedent("""
from conan import ConanFile
from conan.tools.cmake import CMakeDeps
class Pkg(ConanFile):
name = "pkg"
version = "0.1"
settings = "os", "compiler", "build_type", "arch"
tool_requires = "tool/0.1"

def generate(self):
deps = CMakeDeps(self)
deps.build_context_activated = ["tool"]
deps.build_context_build_modules = ["tool"]
deps.generate()
""")
c.save({"conanfile.py": consumer,
"profile_build": "[settings]\nos=Windows"}, clean_first=True)
c.run("create . -pr:b=profile_build")
# it doesn't crash anymore, it used to crash
assert "pkg/0.1: Created package" in c.out