From b8af0a41adfc779664aa211a667a00beb632773e Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Tue, 6 Dec 2022 15:29:32 +0100 Subject: [PATCH] extend NMakeToolchain test --- .../toolchains/test_nmake_toolchain.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/conans/test/functional/toolchains/test_nmake_toolchain.py b/conans/test/functional/toolchains/test_nmake_toolchain.py index e1a2409bf5c..509a532fb8b 100644 --- a/conans/test/functional/toolchains/test_nmake_toolchain.py +++ b/conans/test/functional/toolchains/test_nmake_toolchain.py @@ -8,11 +8,13 @@ from conans.test.utils.tools import TestClient -@pytest.mark.parametrize("compiler, version, runtime, cppstd, build_type", - [("msvc", "190", "dynamic", "14", "Release"), - ("msvc", "191", "static", "17", "Debug")]) +@pytest.mark.parametrize("compiler, version, runtime, cppstd, build_type, cflags, cxxflags, sharedlinkflags, exelinkflags", + [("msvc", "190", "dynamic", "14", "Release", [], [], [], []), + ("msvc", "190", "dynamic", "14", "Release", ["/GL"], ["/GL"], ["/LTCG"], ["/LTCG"]), + ("msvc", "191", "static", "17", "Debug", [], [], [], [])]) @pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows") -def test_toolchain_nmake(compiler, version, runtime, cppstd, build_type): +def test_toolchain_nmake(compiler, version, runtime, cppstd, build_type, + cflags, cxxflags, sharedlinkflags, exelinkflags): client = TestClient(path_with_spaces=False) settings = {"compiler": compiler, "compiler.version": version, @@ -21,10 +23,18 @@ def test_toolchain_nmake(compiler, version, runtime, cppstd, build_type): "build_type": build_type, "arch": "x86_64"} + conf = { + "tools.build:cflags": "[{}]".format(",".join([f"\"{flag}\"" for flag in cflags])) if cflags else "", + "tools.build:cxxflags": "[{}]".format(",".join([f"\"{flag}\"" for flag in cxxflags])) if cxxflags else "", + "tools.build:sharedlinkflags": "[{}]".format(",".join([f"\"{flag}\"" for flag in sharedlinkflags])) if sharedlinkflags else "", + "tools.build:exelinkflags": "[{}]".format(",".join([f"\"{flag}\"" for flag in exelinkflags])) if exelinkflags else "", + } + # Build the profile according to the settings provided settings = " ".join('-s %s="%s"' % (k, v) for k, v in settings.items() if v) + conf = " ".join(f"-c {k}={v}" for k, v in conf.items() if v) client.run("new dep/1.0 -m=cmake_lib") - client.run(f'create . -tf=None {settings} ' + client.run(f'create . -tf=None {settings} {conf} ' f'-c tools.cmake.cmaketoolchain:generator="Visual Studio 15"') conanfile = textwrap.dedent(""" @@ -50,7 +60,7 @@ def build(self): "makefile": makefile, "simple.cpp": gen_function_cpp(name="main", includes=["dep"], calls=["dep"])}, clean_first=True) - client.run("install . {}".format(settings)) + client.run(f"install . {settings} {conf}") client.run("build .") client.run_command("simple.exe") assert "dep/1.0" in client.out