Commit b974f818044a3211bf9623c3dd60f88482786164

Authored by geir-t
Committed by GitHub
1 parent 80d8e942

conan: Do not run tests when cross compiling (#430)

* conan: Do not run tests when cross compiling

Running conan create with a profile made for cross compiling would fail since the tests is not compiled for build OS

* Using suggestion from Conan docs

* conan: also add cross_building check in build step

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
conanfile.py
1 1 from conans import ConanFile, CMake
2   -from conans.tools import load
  2 +from conans.tools import load, cross_building
3 3 import re
4 4  
5 5  
... ... @@ -40,7 +40,8 @@ class CLI11Conan(ConanFile):
40 40 cmake.definitions["CLI11_SINGLE_FILE"] = "OFF"
41 41 cmake.configure()
42 42 cmake.build()
43   - cmake.test()
  43 + if not cross_building(self.settings):
  44 + cmake.test()
44 45 cmake.install()
45 46  
46 47 def package_id(self):
... ...
test_package/conanfile.py
1   -from conans import ConanFile, CMake
  1 +from conans import ConanFile, CMake, tools
2 2 import os
3 3  
4 4  
... ... @@ -16,5 +16,6 @@ class HelloTestConan(ConanFile):
16 16 self.copy("*.dylib*", dst="bin", src="lib")
17 17  
18 18 def test(self):
19   - os.chdir("bin")
20   - self.run(".%sexample" % os.sep)
  19 + if not tools.cross_building(self.settings):
  20 + os.chdir("bin")
  21 + self.run(".%sexample" % os.sep)
... ...