# Copyright (c) 2020 Egor Tensin # This file is part of the "cmake-common" project. # For details, see https://github.com/egor-tensin/cmake-common # Distributed under the MIT License. from enum import auto, StrEnum import platform class OS(StrEnum): WINDOWS = auto() LINUX = auto() MACOS = auto() @staticmethod def current(): system = platform.system() mapping = { "Windows": OS.WINDOWS, "Linux": OS.LINUX, "Darwin": OS.MACOS, } if system not in mapping: raise NotImplementedError(f"unsupported OS: {system}") return mapping[system] def on_windows(): return OS.current() is OS.WINDOWS def on_windows_like(): os = OS.current() return os is OS.WINDOWS def on_linux(): return OS.current() is OS.LINUX def on_linux_like(): os = OS.current() return os is OS.LINUX or os is OS.MACOS