From 09d700f4b635ac63108b7a08a22858c66ced3188 Mon Sep 17 00:00:00 2001 From: SSE4 Date: Fri, 12 Feb 2021 23:05:17 +0700 Subject: [PATCH] - check cmake Signed-off-by: SSE4 --- .../test/functional/subsystems_build_test.py | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/conans/test/functional/subsystems_build_test.py b/conans/test/functional/subsystems_build_test.py index 5110ccc0506..86fc0ad6b05 100644 --- a/conans/test/functional/subsystems_build_test.py +++ b/conans/test/functional/subsystems_build_test.py @@ -126,3 +126,86 @@ def test_cygwin(self): assert "__MINGW32__" not in client.out assert "__MINGW64__" not in client.out assert "__MSYS__" not in client.out + + +@pytest.mark.skipif(platform.system() != "Windows", reason="Tests Windows Subsystems") +class TestSubsystemsCMakeBuild: + cmakelists = textwrap.dedent(""" + cmake_minimum_required(VERSION 2.8) + project(app) + + add_executable(app main.cpp) + """) + + def _build(self, client, generator="Unix Makefiles"): + main_cpp = gen_function_cpp(name="main") + client.save({"CMakeLists.txt": self.cmakelists, + "main.cpp": main_cpp}) + + client.run_command("cmake -DCMAKE_SH=\"CMAKE_SH-NOTFOUND\" -G \"%s\" ." % generator) + client.run_command("cmake --build .") + client.run_command("app") + + @pytest.mark.tool_msys2 + def test_msys(self): + """ + native MSYS environment, binaries depend on MSYS runtime (msys-2.0.dll) + posix-compatible, intended to be run only in MSYS environment (not in pure Windows) + """ + client = TestClient() + # pacman -S gcc + self._build(client) + + check_exe_run(client.out, "main", "gcc", None, "Debug", "x86_64", None) + + assert "__MINGW32__" not in client.out + assert "__MINGW64__" not in client.out + assert "__MSYS__" in client.out + + @pytest.mark.tool_msys2 + @pytest.mark.tool_mingw64 + def test_mingw64(self): + """ + 64-bit GCC, binaries for generic Windows (no dependency on MSYS runtime) + """ + client = TestClient() + # pacman -S mingw-w64-x86_64-gcc + self._build(client, generator="MinGW Makefiles") + + check_exe_run(client.out, "main", "gcc", None, "Debug", "x86_64", None) + + assert "__MINGW64__" in client.out + assert "__CYGWIN__" not in client.out + assert "__MSYS__" not in client.out + + @pytest.mark.tool_msys2 + @pytest.mark.tool_mingw32 + def test_mingw32(self): + """ + 32-bit GCC, binaries for generic Windows (no dependency on MSYS runtime) + """ + client = TestClient() + # pacman -S mingw-w64-i686-gcc + self._build(client, generator="MinGW Makefiles") + + check_exe_run(client.out, "main", "gcc", None, "Debug", "x86", None) + + assert "__MINGW32__" in client.out + assert "__CYGWIN__" not in client.out + assert "__MSYS__" not in client.out + + @pytest.mark.tool_cygwin + def test_cygwin(self): + """ + Cygwin environment, binaries depend on Cygwin runtime (cygwin1.dll) + posix-compatible, intended to be run only in Cygwin environment (not in pure Windows) + """ + client = TestClient() + # install "gcc-c++" and "make" packages + self._build(client) + check_exe_run(client.out, "main", "gcc", None, "Debug", "x86_64", None) + + assert "__CYGWIN__" in client.out + assert "__MINGW32__" not in client.out + assert "__MINGW64__" not in client.out + assert "__MSYS__" not in client.out