def autotools_fpic_test(self): runner = None settings = MockSettings({"os": "Linux"}) options = MockOptions({"fPIC": True, "shared": False}) conanfile = MockConanfile(settings, options, runner) ab = AutoToolsBuildEnvironment(conanfile) self.assertTrue(ab.fpic) options = MockOptions({"fPIC": True, "shared": True}) conanfile = MockConanfile(settings, options, runner) ab = AutoToolsBuildEnvironment(conanfile) self.assertTrue(ab.fpic) options = MockOptions({"fPIC": False, "shared": True}) conanfile = MockConanfile(settings, options, runner) ab = AutoToolsBuildEnvironment(conanfile) self.assertTrue(ab.fpic) options = MockOptions({"fPIC": False, "shared": False}) conanfile = MockConanfile(settings, options, runner) ab = AutoToolsBuildEnvironment(conanfile) self.assertFalse(ab.fpic) settings = MockSettings({"os": "Windows"}) options = MockOptions({"fPIC": True, "shared": True}) conanfile = MockConanfile(settings, options, runner) ab = AutoToolsBuildEnvironment(conanfile) self.assertFalse(ab.fpic) settings = MockSettings({"os": "Macos", "compiler": "clang"}) options = MockOptions({"fPIC": False, "shared": False}) conanfile = MockConanfile(settings, options, runner) ab = AutoToolsBuildEnvironment(conanfile) self.assertFalse(ab.fpic) ab.fpic = True self.assertIn("-fPIC", ab.vars["CXXFLAGS"])
def test_cppstd(self): options = MockOptions({}) # Valid one for GCC settings = MockSettings({ "build_type": "Release", "arch": "x86", "compiler": "gcc", "compiler.libcxx": "libstdc++11", "compiler.version": "7.1", "cppstd": "17" }) conanfile = MockConanfile(settings, options) be = AutoToolsBuildEnvironment(conanfile) expected = be.vars["CXXFLAGS"] self.assertIn("-std=c++17", expected) # Invalid one for GCC settings = MockSettings({ "build_type": "Release", "arch": "x86", "compiler": "gcc", "compiler.libcxx": "libstdc++11", "compiler.version": "4.9", "cppstd": "17" }) conanfile = MockConanfile(settings, options) be = AutoToolsBuildEnvironment(conanfile) expected = be.vars["CXXFLAGS"] self.assertNotIn("-std", expected) # Valid one for Clang settings = MockSettings({ "build_type": "Release", "arch": "x86", "compiler": "clang", "compiler.libcxx": "libstdc++11", "compiler.version": "4.0", "cppstd": "17" }) conanfile = MockConanfile(settings, options) be = AutoToolsBuildEnvironment(conanfile) expected = be.vars["CXXFLAGS"] self.assertIn("-std=c++1z", expected) # Invalid one for Clang settings = MockSettings({ "build_type": "Release", "arch": "x86", "compiler": "clang", "compiler.libcxx": "libstdc++11", "compiler.version": "3.3", "cppstd": "17" }) conanfile = MockConanfile(settings, options) be = AutoToolsBuildEnvironment(conanfile) expected = be.vars["CXXFLAGS"] self.assertNotIn("-std=", expected) # Visual Activate 11 is useless settings = MockSettings({ "build_type": "Release", "arch": "x86", "compiler": "Visual Studio", "compiler.version": "15", "cppstd": "11" }) conanfile = MockConanfile(settings, options) be = AutoToolsBuildEnvironment(conanfile) expected = be.vars["CXXFLAGS"] self.assertNotIn("-std=c++", expected) # Visual Activate 17 in VS 2017 settings = MockSettings({ "build_type": "Release", "arch": "x86", "compiler": "Visual Studio", "compiler.version": "15", "cppstd": "17" }) conanfile = MockConanfile(settings, options) be = AutoToolsBuildEnvironment(conanfile) expected = be.vars["CXXFLAGS"] self.assertIn("/std:c++17", expected) # Visual Activate 17 in VS 2015 settings = MockSettings({ "build_type": "Release", "arch": "x86", "compiler": "Visual Studio", "compiler.version": "14", "cppstd": "17" }) conanfile = MockConanfile(settings, options) be = AutoToolsBuildEnvironment(conanfile) expected = be.vars["CXXFLAGS"] self.assertIn("/std:c++latest", expected)