/
cmake_ios_cross_build_test.py
73 lines (65 loc) · 2.17 KB
/
cmake_ios_cross_build_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import platform
import textwrap
import pytest
from conans.test.utils.tools import TestClient
@pytest.mark.skipif(platform.system() != "Darwin", reason="Only for Apple")
@pytest.mark.tool_cmake
def test_cross_build_test_package():
# https://github.com/conan-io/conan/issues/9202
profile_build = textwrap.dedent("""
[settings]
os=Macos
arch=x86_64
compiler=apple-clang
compiler.version=12.0
compiler.libcxx=libc++
build_type=Release
[options]
[build_requires]
[env]
""")
profile_host = textwrap.dedent("""
[settings]
os=iOS
os.version=12.0
arch=x86_64
compiler=apple-clang
compiler.version=12.0
compiler.libcxx=libc++
build_type=Release
[options]
[build_requires]
[env]
""")
test_cmakelist = textwrap.dedent("""
cmake_minimum_required(VERSION 3.1)
project(PackageTest CXX)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
find_package(hello REQUIRED CONFIG)
add_executable(example example.cpp)
target_link_libraries(example hello::hello)
set_property(TARGET example PROPERTY CXX_STANDARD 11)
""")
test_conanfile = textwrap.dedent("""
import os
from conans import ConanFile, CMake, tools
class HelloTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not tools.cross_building(self):
os.chdir("bin")
self.run(".%sexample" % os.sep)
""")
client = TestClient()
client.run("new hello/0.1 -t")
client.save({"profile_build": profile_build,
"profile_host": profile_host,
"./test_package/conanfile.py": test_conanfile,
"./test_package/CMakeLists.txt": test_cmakelist})
client.run("create . -pr:b profile_build -pr:h profile_host")