-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
conans/test/integration/toolchains/microsoft/test_nmakedeps.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import platform | ||
import re | ||
import textwrap | ||
|
||
import pytest | ||
|
||
from conans.test.utils.tools import TestClient | ||
|
||
|
||
@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows") | ||
def test_nmakedeps(): | ||
client = TestClient() | ||
conanfile = textwrap.dedent(""" | ||
from conan import ConanFile | ||
class Pkg(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
name = "test-nmakedeps" | ||
version = "1.0" | ||
def package_info(self): | ||
self.cpp_info.components["pkg-1"].libs = ["pkg-1"] | ||
self.cpp_info.components["pkg-1"].defines = ["TEST_DEFINITION1"] | ||
self.cpp_info.components["pkg-1"].system_libs = ["ws2_32"] | ||
self.cpp_info.components["pkg-2"].libs = ["pkg-2"] | ||
self.cpp_info.components["pkg-2"].defines = ["TEST_DEFINITION2=0"] | ||
self.cpp_info.components["pkg-2"].requires = ["pkg-1"] | ||
self.cpp_info.components["pkg-3"].libs = ["pkg-3"] | ||
self.cpp_info.components["pkg-3"].defines = ["TEST_DEFINITION3="] | ||
self.cpp_info.components["pkg-3"].requires = ["pkg-1", "pkg-2"] | ||
self.cpp_info.components["pkg-4"].libs = ["pkg-4"] | ||
self.cpp_info.components["pkg-4"].defines = ["TEST_DEFINITION4=test-cmakedeps"] | ||
""") | ||
client.save({"conanfile.py": conanfile}) | ||
client.run("create . -s arch=x86_64") | ||
# Issue: https://github.com/conan-io/conan/issues/11822 | ||
client.run("install test-nmakedeps/1.0@ -g NMakeDeps -s build_type=Release -s arch=x86_64") | ||
# Checking that NMakeDeps builds correctly .bat file | ||
bat_file = client.load("conannmakedeps.bat") | ||
# Checking that defines are added to CL | ||
for flag in ( | ||
r"/DTEST_DEFINITION1", r"/DTEST_DEFINITION2#0", | ||
r"/DTEST_DEFINITION3#", r'/DTEST_DEFINITION4#\\"test-cmakedeps\\"', | ||
): | ||
assert re.search(fr'set "CL=%CL%.*\s{flag}[\s|"]', bat_file) | ||
# Checking that libs and system libs are added to _LINK_ | ||
for flag in (r"pkg-1\.lib", r"pkg-2\.lib", r"pkg-3\.lib", r"pkg-4\.lib", r"ws2_32\.lib"): | ||
assert re.search(fr'set "_LINK_=%_LINK_%.*\s{flag}(?:\s|"$)', bat_file) |