Skip to content

Commit

Permalink
Add MSBuildToolchain.properties (#12147)
Browse files Browse the repository at this point in the history
* Add MSBuildToolchain.properties

* Update conan/tools/microsoft/toolchain.py

Co-authored-by: Jelle Spijker <[email protected]>

Co-authored-by: Jelle Spijker <[email protected]>
  • Loading branch information
memsharded and jellespijker authored Sep 20, 2022
1 parent 6ea750d commit 8aeea22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion conan/tools/microsoft/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class MSBuildToolchain(object):
</ItemDefinitionGroup>
<PropertyGroup Label="Configuration">
<PlatformToolset>{{ toolset }}</PlatformToolset>
{% for k, v in properties.items() %}
<{{k}}>{{ v }}</{{k}}>
{% endfor %}
</PropertyGroup>
</Project>
""")
Expand All @@ -51,6 +54,7 @@ def __init__(self, conanfile):
self.runtime_library = self._runtime_library(conanfile.settings)
self.cppstd = conanfile.settings.get_safe("compiler.cppstd")
self.toolset = self._msvs_toolset(conanfile)
self.properties = {}
check_using_build_profile(self._conanfile)

def _name_condition(self, settings):
Expand Down Expand Up @@ -163,7 +167,8 @@ def format_macro(key, value):
"runtime_library": runtime_library,
"toolset": toolset,
"compile_options": compile_options,
"parallel": parallel
"parallel": parallel,
"properties": self.properties,
}

def _write_config_toolchain(self, config_filename):
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/toolchains/test_msbuild_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ class Pkg(ConanFile):
settings = "os", "compiler", "build_type", "arch"
def generate(self):
msbuild = MSBuildToolchain(self)
msbuild.properties["IncludeExternals"] = "true"
msbuild.generate()
""")
client.save({"conanfile.py": conanfile})
client.run("install . {}".format(settings))
props = client.load("conantoolchain_release_x64.props")
assert "<IncludeExternals>true</IncludeExternals>" in props
assert "<LanguageStandard>stdcpp17</LanguageStandard>" in props
if version == "190":
assert "<PlatformToolset>v140</PlatformToolset>" in props
Expand Down

0 comments on commit 8aeea22

Please sign in to comment.