Skip to content

Commit

Permalink
extend NMakeToolchain test
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm committed Dec 6, 2022
1 parent 336a8a2 commit b8af0a4
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions conans/test/functional/toolchains/test_nmake_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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("""
Expand All @@ -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
Expand Down

0 comments on commit b8af0a4

Please sign in to comment.