def wrapper(self, *args, **kwargs): try: # Set custom headers of mac_digest and username self.set_custom_headers(self.user) ret = func(self, *args, **kwargs) return ret except ForbiddenException: raise ForbiddenException("Permission denied for user: '******'" % self.user) except AuthenticationException: # User valid but not enough permissions if self.user is None or self._rest_client.token is None: # token is None when you change user with user command # Anonymous is not enough, ask for a user remote = self.remote self._user_io.out.info( 'Please log in to "%s" to perform this action. ' 'Execute "conan user" command.' % remote.name) if "bintray" in remote.url: self._user_io.out.info( 'If you don\'t have an account sign up here: ' 'https://bintray.com/signup/oss') return retry_with_new_token(self, *args, **kwargs) else: # Token expired or not valid, so clean the token and repeat the call # (will be anonymous call but exporting who is calling) logger.info( "Token expired or not valid, cleaning the saved token and retrying" ) self._store_login((self.user, None)) self._rest_client.token = None # Set custom headers of mac_digest and username self.set_custom_headers(self.user) return wrapper(self, *args, **kwargs)
def wrapper(self, *args, **kwargs): try: # Set custom headers of mac_digest and username self.set_custom_headers(self.user) ret = func(self, *args, **kwargs) return ret except ForbiddenException: raise ForbiddenException("Permission denied for user: '******'" % self.user) except AuthenticationException: # User valid but not enough permissions if self.user is None or self._rest_client.token is None: # token is None when you change user with user command # Anonymous is not enough, ask for a user remote = self.remote self._user_io.out.info('Please log in to "%s" to perform this action. ' 'Execute "conan user" command.' % remote.name) if "bintray" in remote.url: self._user_io.out.info('If you don\'t have an account sign up here: ' 'https://bintray.com/signup/oss') return retry_with_new_token(self, *args, **kwargs) else: # Token expired or not valid, so clean the token and repeat the call # (will be anonymous call but exporting who is calling) logger.info("Token expired or not valid, cleaning the saved token and retrying") self._store_login((self.user, None)) self._rest_client.token = None # Set custom headers of mac_digest and username self.set_custom_headers(self.user) return wrapper(self, *args, **kwargs)
def _build(self, conanfile, pref, build_folder): # Read generators from conanfile and generate the needed files logger.info("GENERATORS: Writing generators") write_generators(conanfile, build_folder, self._output) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files copied_files = run_imports(conanfile, build_folder) try: self._hook_manager.execute("pre_build", conanfile=conanfile, reference=pref.ref, package_id=pref.id) logger.debug("Call conanfile.build() with files in build folder: %s", os.listdir(build_folder)) self._output.highlight("Calling build()") with conanfile_exception_formatter(str(conanfile), "build"): conanfile.build() self._output.success("Package '%s' built" % pref.id) self._output.info("Build folder %s" % build_folder) self._hook_manager.execute("post_build", conanfile=conanfile, reference=pref.ref, package_id=pref.id) except Exception as exc: self._output.writeln("") self._output.error("Package '%s' build failed" % pref.id) self._output.warn("Build folder %s" % build_folder) if isinstance(exc, ConanExceptionInUserConanfileMethod): raise exc raise ConanException(exc) finally: # Now remove all files that were imported with imports() remove_imports(conanfile, copied_files, self._output)
def _cmake_cross_build_defines(self, the_os, os_ver): ret = OrderedDict() os_ver = get_env("CONAN_CMAKE_SYSTEM_VERSION", os_ver) if self._cmake_system_name is False: return ret if self._cmake_system_name is not True: # String not empty ret["CMAKE_SYSTEM_NAME"] = self._cmake_system_name ret["CMAKE_SYSTEM_VERSION"] = os_ver else: # self._cmake_system_name is True, so detect if we are cross building and the system name and version platform_os = { "Darwin": "Macos" }.get(platform.system(), platform.system()) if (platform_os != the_os) or os_ver: # We are cross building if the_os: ret["CMAKE_SYSTEM_NAME"] = the_os if os_ver: ret["CMAKE_SYSTEM_VERSION"] = os_ver else: ret["CMAKE_SYSTEM_NAME"] = "Generic" if ret: # If enabled cross compile for env_var in [ "CONAN_CMAKE_SYSTEM_PROCESSOR", "CONAN_CMAKE_FIND_ROOT_PATH", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE" ]: value = os.getenv(env_var, None) if value: ret[env_var] = value if self._conanfile and self._conanfile.deps_cpp_info.sysroot: sysroot_path = self._conanfile.deps_cpp_info.sysroot else: sysroot_path = os.getenv("CONAN_CMAKE_FIND_ROOT_PATH", None) if sysroot_path: # Needs to be set here, can't be managed in the cmake generator, CMake needs to know about # the sysroot before any other thing ret["CMAKE_SYSROOT"] = sysroot_path.replace("\\", "/") # Adjust Android stuff if self._os == "Android": arch_abi_settings = { "armv8": "arm64-v8a", "armv7": "armeabi-v7a", "armv7hf": "armeabi-v7a", "armv6": "armeabi-v6", "armv5": "armeabi" }.get(self._arch, self._arch) if arch_abi_settings: ret["CMAKE_ANDROID_ARCH_ABI"] = arch_abi_settings logger.info("Setting Cross build flags: %s" % ", ".join(["%s=%s" % (k, v) for k, v in ret.items()])) return ret
def _build(self, conanfile, pref): # Read generators from conanfile and generate the needed files logger.info("GENERATORS: Writing generators") self._generator_manager.write_generators(conanfile, conanfile.build_folder, conanfile.generators_folder, self._output) logger.info("TOOLCHAIN: Writing toolchain") write_toolchain(conanfile, conanfile.generators_folder, self._output) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files copied_files = run_imports(conanfile) try: mkdir(conanfile.build_folder) with tools.chdir(conanfile.build_folder): run_build_method(conanfile, self._hook_manager, reference=pref.ref, package_id=pref.id) self._output.success("Package '%s' built" % pref.id) self._output.info("Build folder %s" % conanfile.build_folder) except Exception as exc: self._output.writeln("") self._output.error("Package '%s' build failed" % pref.id) self._output.warn("Build folder %s" % conanfile.build_folder) if isinstance(exc, ConanExceptionInUserConanfileMethod): raise exc raise ConanException(exc) finally: # Now remove all files that were imported with imports() remove_imports(conanfile, copied_files, self._output)
def _fill_runtime(settings): try: if settings.compiler == "Visual Studio": if settings.get_safe("compiler.runtime") is None: runtime = "MDd" if settings.get_safe( "build_type") == "Debug" else "MD" settings.compiler.runtime = runtime msg = "Setting 'compiler.runtime' not declared, automatically adjusted to '%s'" logger.info(msg % runtime) elif settings.compiler == "intel" and settings.get_safe( "compiler.base") == "Visual Studio": if settings.get_safe("compiler.base.runtime") is None: runtime = "MDd" if settings.get_safe( "build_type") == "Debug" else "MD" settings.compiler.base.runtime = runtime msg = "Setting 'compiler.base.runtime' not declared, automatically adjusted to '%s'" logger.info(msg % runtime) elif settings.compiler == "msvc": if settings.get_safe("compiler.runtime_type") is None: runtime = "Debug" if settings.get_safe( "build_type") == "Debug" else "Release" settings.compiler.runtime_type = runtime except Exception: # If the settings structure doesn't match these general # asumptions, like unexistant runtime pass
def call_rest_api_method(self, remote, method_name, *args, **kwargs): """Handles AuthenticationException and request user to input a user and a password""" user, token, refresh_token = self._localdb.get_login(remote.url) rest_client = self._get_rest_client(remote) if method_name == "authenticate": return self._authenticate(remote, *args, **kwargs) try: ret = getattr(rest_client, method_name)(*args, **kwargs) return ret except ForbiddenException: raise ForbiddenException("Permission denied for user: '******'" % user) except AuthenticationException: # User valid but not enough permissions if user is None or token is None: # token is None when you change user with user command # Anonymous is not enough, ask for a user self._user_io.out.info('Please log in to "%s" to perform this action. ' 'Execute "conan user" command.' % remote.name) return self._retry_with_new_token(user, remote, method_name, *args, **kwargs) elif token and refresh_token: # If we have a refresh token try to refresh the access token try: self._authenticate(remote, user, None) except AuthenticationException as exc: logger.info("Cannot refresh the token, cleaning and retrying: {}".format(exc)) self._clear_user_tokens_in_db(user, remote) return self.call_rest_api_method(remote, method_name, *args, **kwargs) else: # Token expired or not valid, so clean the token and repeat the call # (will be anonymous call but exporting who is calling) logger.info("Token expired or not valid, cleaning the saved token and retrying") self._clear_user_tokens_in_db(user, remote) return self._retry_with_new_token(user, remote, method_name, *args, **kwargs)
def fill_runtime(settings): try: if settings.compiler == "Visual Studio": if settings.get_safe("compiler.runtime") is None: settings.compiler.runtime = "MDd" if settings.get_safe("build_type") == "Debug" \ else "MD" logger.info("Setting 'compiler.runtime' not declared, automatically " "adjusted to '%s'" % settings.compiler.runtime) except Exception: # If the settings structure doesn't match these general # asumptions, like unexistant runtime pass
def get_file_path(self, filepath, token): try: encoded_path, _, user = self.updown_auth_manager.get_resource_info(token) if not self._valid_path(filepath, encoded_path): logger.info("Invalid path file!! %s: %s" % (user, filepath)) raise NotFoundException("File not found") logger.debug("Get file: user=%s path=%s" % (user, filepath)) file_path = os.path.normpath(os.path.join(self.base_store_folder, encoded_path)) return file_path except (jwt.ExpiredSignature, jwt.DecodeError, AttributeError): raise NotFoundException("File not found")
def _fill_runtime(settings): try: if settings.compiler == "Visual Studio": if settings.get_safe("compiler.runtime") is None: settings.compiler.runtime = "MDd" if settings.get_safe("build_type") == "Debug" \ else "MD" logger.info( "Setting 'compiler.runtime' not declared, automatically " "adjusted to '%s'" % settings.compiler.runtime) except Exception: # If the settings structure doesn't match these general # asumptions, like unexistant runtime pass
def _build_package(self): """ calls the imports + conanfile.build() method """ os.chdir(self.build_folder) self._conan_file.build_folder = self.build_folder self._conan_file.package_folder = self.package_folder # In local cache, install folder always is build_folder self._conan_file.install_folder = self.build_folder # Read generators from conanfile and generate the needed files logger.info("GENERATORS: Writing generators") write_generators(self._conan_file, self.build_folder, self._out) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files from conans.client.importer import run_imports copied_files = run_imports(self._conan_file, self.build_folder, self._out) try: # This is necessary because it is different for user projects # than for packages self._hook_manager.execute( "pre_build", conanfile=self._conan_file, reference=self._conan_ref, package_id=self._package_reference.package_id) logger.debug( "Call conanfile.build() with files in build folder: %s", os.listdir(self.build_folder)) self._out.highlight("Calling build()") with conanfile_exception_formatter(str(self._conan_file), "build"): self._conan_file.build() self._out.success("Package '%s' built" % self._conan_file.info.package_id()) self._out.info("Build folder %s" % self.build_folder) self._hook_manager.execute( "post_build", conanfile=self._conan_file, reference=self._conan_ref, package_id=self._package_reference.package_id) except Exception as exc: self._out.writeln("") self._out.error("Package '%s' build failed" % self._conan_file.info.package_id()) self._out.warn("Build folder %s" % self.build_folder) if isinstance(exc, ConanExceptionInUserConanfileMethod): raise exc raise ConanException(exc) finally: # Now remove all files that were imported with imports() remove_imports(self._conan_file, copied_files, self._out)
def check_output_runner(cmd, stderr=None): # Used to run several utilities, like Pacman detect, AIX version, uname, SCM tmp_file = tempfile.mktemp() try: # We don't want stderr to print warnings that will mess the pristine outputs stderr = stderr or subprocess.PIPE cmd = cmd if isinstance( cmd, six.string_types) else subprocess.list2cmdline(cmd) command = "{} > {}".format(cmd, tmp_file) logger.info("Calling command: {}".format(command)) process = subprocess.Popen(command, shell=True, stderr=stderr) stdout, stderr = process.communicate() logger.info("Return code: {}".format(int(process.returncode))) if process.returncode: # Only in case of error, we print also the stderr to know what happened raise CalledProcessErrorWithStderr(process.returncode, cmd, output=stderr) output = load(tmp_file) try: logger.info("Output: in file:{}\nstdout: {}\nstderr:{}".format( output, stdout, stderr)) except Exception as exc: logger.error("Error logging command output: {}".format(exc)) return output finally: try: os.unlink(tmp_file) except OSError: pass
def check_output(cmd, folder=None, return_code=False, stderr=None): tmp_file = tempfile.mktemp() try: # We don't want stderr to print warnings that will mess the pristine outputs stderr = stderr or PIPE cmd = cmd if isinstance( cmd, six.string_types) else subprocess.list2cmdline(cmd) command = "{} > {}".format(cmd, tmp_file) logger.info("Calling command: {}".format(command)) process = subprocess.Popen(command, shell=True, stderr=stderr, cwd=folder) stdout, stderr = process.communicate() logger.info("Return code: {}".format(int(process.returncode))) if return_code: return process.returncode if process.returncode: # Only in case of error, we print also the stderr to know what happened raise CalledProcessErrorWithStderr(process.returncode, cmd, output=stderr) output = load(tmp_file) try: logger.info("Output: in file:{}\nstdout: {}\nstderr:{}".format( output, stdout, stderr)) except Exception as exc: logger.error("Error logging command output: {}".format(exc)) return output finally: try: os.unlink(tmp_file) except Exception: pass
def _cmake_cross_build_defines(self, cmake_version): os_ = self._ss("os") arch = self._ss("arch") os_ver_str = "os.api_level" if os_ == "Android" else "os.version" op_system_version = self._ss(os_ver_str) env_sn = get_env("CONAN_CMAKE_SYSTEM_NAME", "") env_sn = {"False": False, "True": True, "": None}.get(env_sn, env_sn) cmake_system_name = env_sn or self._forced_cmake_system_name os_build, _, _, _ = get_cross_building_settings(self._conanfile) compiler = self._ss("compiler") libcxx = self._ss("compiler.libcxx") definitions = OrderedDict() os_ver = get_env("CONAN_CMAKE_SYSTEM_VERSION", op_system_version) toolchain_file = get_env("CONAN_CMAKE_TOOLCHAIN_FILE", "") if toolchain_file != "": logger.info("Setting Cross build toolchain file: %s" % toolchain_file) definitions["CMAKE_TOOLCHAIN_FILE"] = toolchain_file return definitions if cmake_system_name is False: return definitions # System name and system version if cmake_system_name is not True: # String not empty definitions["CMAKE_SYSTEM_NAME"] = cmake_system_name else: # detect if we are cross building and the system name and version skip_x64_x86 = os_ in ['Windows', 'Linux'] if cross_building(self._conanfile, skip_x64_x86=skip_x64_x86): # We are cross building apple_system_name = "Darwin" if Version(cmake_version) < Version("3.14") else None cmake_system_name_map = {"Macos": "Darwin", "iOS": apple_system_name or "iOS", "tvOS": apple_system_name or "tvOS", "watchOS": apple_system_name or "watchOS", "Neutrino": "QNX", "": "Generic", None: "Generic"} definitions["CMAKE_SYSTEM_NAME"] = cmake_system_name_map.get(os_, os_) if os_ver: definitions["CMAKE_SYSTEM_VERSION"] = os_ver if is_apple_os(os_): definitions["CMAKE_OSX_DEPLOYMENT_TARGET"] = os_ver # system processor cmake_system_processor = os.getenv("CONAN_CMAKE_SYSTEM_PROCESSOR") if cmake_system_processor: definitions["CMAKE_SYSTEM_PROCESSOR"] = cmake_system_processor if definitions: # If enabled cross compile for env_var in ["CONAN_CMAKE_FIND_ROOT_PATH", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"]: value = os.getenv(env_var) if value: definitions[env_var] = value if self._conanfile and self._conanfile.deps_cpp_info.sysroot: sysroot_path = self._conanfile.deps_cpp_info.sysroot else: sysroot_path = os.getenv("CONAN_CMAKE_FIND_ROOT_PATH", None) if sysroot_path: # Needs to be set here, can't be managed in the cmake generator, CMake needs # to know about the sysroot before any other thing definitions["CMAKE_SYSROOT"] = sysroot_path.replace("\\", "/") # Adjust Android stuff if str(os_) == "Android" and definitions["CMAKE_SYSTEM_NAME"] == "Android": arch_abi_settings = tools.to_android_abi(arch) if arch_abi_settings: definitions["CMAKE_ANDROID_ARCH_ABI"] = arch_abi_settings definitions["ANDROID_ABI"] = arch_abi_settings conan_cmake_android_ndk = os.getenv("CONAN_CMAKE_ANDROID_NDK") if conan_cmake_android_ndk: definitions["ANDROID_NDK"] = conan_cmake_android_ndk definitions["ANDROID_PLATFORM"] = "android-%s" % op_system_version definitions["ANDROID_TOOLCHAIN"] = compiler # More details about supported stdc++ libraries here: # https://developer.android.com/ndk/guides/cpp-support.html if libcxx: definitions["ANDROID_STL"] = libcxx else: definitions["ANDROID_STL"] = 'none' logger.info("Setting Cross build flags: %s" % ", ".join(["%s=%s" % (k, v) for k, v in definitions.items()])) return definitions
def _cmake_cross_build_defines(self): os_ = self._ss("os") arch = self._ss("arch") os_ver_str = "os.api_level" if os_ == "Android" else "os.version" op_system_version = self._ss(os_ver_str) env_sn = get_env("CONAN_CMAKE_SYSTEM_NAME", "") env_sn = {"False": False, "True": True, "": None}.get(env_sn, env_sn) cmake_system_name = env_sn or self._forced_cmake_system_name os_build, _, _, _ = get_cross_building_settings(self._conanfile.settings) ret = OrderedDict() os_ver = get_env("CONAN_CMAKE_SYSTEM_VERSION", op_system_version) toolchain_file = get_env("CONAN_CMAKE_TOOLCHAIN_FILE", "") if toolchain_file != "": logger.info("Setting Cross build toolchain file: %s" % toolchain_file) ret["CMAKE_TOOLCHAIN_FILE"] = toolchain_file return ret if cmake_system_name is False: return ret # System name and system version if cmake_system_name is not True: # String not empty ret["CMAKE_SYSTEM_NAME"] = cmake_system_name else: # detect if we are cross building and the system name and version if cross_building(self._conanfile.settings): # We are cross building if os_ != os_build: if os_: # the_os is the host (regular setting) ret["CMAKE_SYSTEM_NAME"] = ("Darwin" if os_ in ["iOS", "tvOS", "watchOS"] else os_) else: ret["CMAKE_SYSTEM_NAME"] = "Generic" if os_ver: ret["CMAKE_SYSTEM_VERSION"] = os_ver if str(os_) == "Macos": ret["CMAKE_OSX_DEPLOYMENT_TARGET"] = os_ver # system processor cmake_system_processor = os.getenv("CONAN_CMAKE_SYSTEM_PROCESSOR") if cmake_system_processor: ret["CMAKE_SYSTEM_PROCESSOR"] = cmake_system_processor if ret: # If enabled cross compile for env_var in ["CONAN_CMAKE_FIND_ROOT_PATH", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"]: value = os.getenv(env_var) if value: ret[env_var] = value if self._conanfile and self._conanfile.deps_cpp_info.sysroot: sysroot_path = self._conanfile.deps_cpp_info.sysroot else: sysroot_path = os.getenv("CONAN_CMAKE_FIND_ROOT_PATH", None) if sysroot_path: # Needs to be set here, can't be managed in the cmake generator, CMake needs # to know about the sysroot before any other thing ret["CMAKE_SYSROOT"] = sysroot_path.replace("\\", "/") # Adjust Android stuff if os_ == "Android": arch_abi_settings = {"armv8": "arm64-v8a", "armv7": "armeabi-v7a", "armv7hf": "armeabi-v7a", "armv6": "armeabi-v6", "armv5": "armeabi" }.get(arch, arch) if arch_abi_settings: ret["CMAKE_ANDROID_ARCH_ABI"] = arch_abi_settings logger.info("Setting Cross build flags: %s" % ", ".join(["%s=%s" % (k, v) for k, v in ret.items()])) return ret
def _cmake_cross_build_defines(self): ret = OrderedDict() os_ver = get_env("CONAN_CMAKE_SYSTEM_VERSION", self._op_system_version) toolchain_file = get_env("CONAN_CMAKE_TOOLCHAIN_FILE", "") if toolchain_file != "": logger.info("Setting Cross build toolchain file: %s" % toolchain_file) ret["CMAKE_TOOLCHAIN_FILE"] = toolchain_file return ret if self._cmake_system_name is False: return ret if self._cmake_system_name is not True: # String not empty ret["CMAKE_SYSTEM_NAME"] = self._cmake_system_name ret["CMAKE_SYSTEM_VERSION"] = os_ver else: # detect if we are cross building and the system name and version if cross_building( self._conanfile.settings): # We are cross building if self._os != self._os_build: if self._os: # the_os is the host (regular setting) ret["CMAKE_SYSTEM_NAME"] = "Darwin" if self._os in [ "iOS", "tvOS", "watchOS" ] else self._os if os_ver: ret["CMAKE_SYSTEM_VERSION"] = os_ver else: ret["CMAKE_SYSTEM_NAME"] = "Generic" if ret: # If enabled cross compile for env_var in [ "CONAN_CMAKE_SYSTEM_PROCESSOR", "CONAN_CMAKE_FIND_ROOT_PATH", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE" ]: value = os.getenv(env_var, None) if value: ret[env_var] = value if self._conanfile and self._conanfile.deps_cpp_info.sysroot: sysroot_path = self._conanfile.deps_cpp_info.sysroot else: sysroot_path = os.getenv("CONAN_CMAKE_FIND_ROOT_PATH", None) if sysroot_path: # Needs to be set here, can't be managed in the cmake generator, CMake needs # to know about the sysroot before any other thing ret["CMAKE_SYSROOT"] = sysroot_path.replace("\\", "/") # Adjust Android stuff if self._os == "Android": arch_abi_settings = { "armv8": "arm64-v8a", "armv7": "armeabi-v7a", "armv7hf": "armeabi-v7a", "armv6": "armeabi-v6", "armv5": "armeabi" }.get(self._arch, self._arch) if arch_abi_settings: ret["CMAKE_ANDROID_ARCH_ABI"] = arch_abi_settings logger.info("Setting Cross build flags: %s" % ", ".join(["%s=%s" % (k, v) for k, v in ret.items()])) return ret
def _cmake_cross_build_defines(self): ret = OrderedDict() os_ver = get_env("CONAN_CMAKE_SYSTEM_VERSION", self._op_system_version) toolchain_file = get_env("CONAN_CMAKE_TOOLCHAIN_FILE", "") if toolchain_file != "": logger.info("Setting Cross build toolchain file: %s" % toolchain_file) ret["CMAKE_TOOLCHAIN_FILE"] = toolchain_file return ret if self._cmake_system_name is False: return ret # System name and system version if self._cmake_system_name is not True: # String not empty ret["CMAKE_SYSTEM_NAME"] = self._cmake_system_name ret["CMAKE_SYSTEM_VERSION"] = os_ver else: # detect if we are cross building and the system name and version if cross_building(self._conanfile.settings): # We are cross building if self._os != self._os_build: if self._os: # the_os is the host (regular setting) ret["CMAKE_SYSTEM_NAME"] = "Darwin" if self._os in ["iOS", "tvOS", "watchOS"] else self._os if os_ver: ret["CMAKE_SYSTEM_VERSION"] = os_ver else: ret["CMAKE_SYSTEM_NAME"] = "Generic" # system processor cmake_system_processor = os.getenv("CONAN_CMAKE_SYSTEM_PROCESSOR", None) if cmake_system_processor: ret["CMAKE_SYSTEM_PROCESSOR"] = cmake_system_processor if ret: # If enabled cross compile for env_var in ["CONAN_CMAKE_FIND_ROOT_PATH", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"]: value = os.getenv(env_var, None) if value: ret[env_var] = value if self._conanfile and self._conanfile.deps_cpp_info.sysroot: sysroot_path = self._conanfile.deps_cpp_info.sysroot else: sysroot_path = os.getenv("CONAN_CMAKE_FIND_ROOT_PATH", None) if sysroot_path: # Needs to be set here, can't be managed in the cmake generator, CMake needs # to know about the sysroot before any other thing ret["CMAKE_SYSROOT"] = sysroot_path.replace("\\", "/") # Adjust Android stuff if self._os == "Android": arch_abi_settings = {"armv8": "arm64-v8a", "armv7": "armeabi-v7a", "armv7hf": "armeabi-v7a", "armv6": "armeabi-v6", "armv5": "armeabi" }.get(self._arch, self._arch) if arch_abi_settings: ret["CMAKE_ANDROID_ARCH_ABI"] = arch_abi_settings logger.info("Setting Cross build flags: %s" % ", ".join(["%s=%s" % (k, v) for k, v in ret.items()])) return ret