Lines Matching +full:cmake +full:- +full:version
1 "Manages CMake."
10 from distutils.version import LooseVersion
19 def _mkdir_p(d: str) -> None:
29 # Use ninja if it is on the PATH. Previous version of PyTorch required the
36 class CMake: class
37 "Manages cmake."
39 def __init__(self, build_dir: str = BUILD_DIR) -> None:
40 self._cmake_command = CMake._get_cmake_command()
44 def _cmake_cache_file(self) -> str:
53 def _get_cmake_command() -> str:
54 "Returns cmake command."
56 cmake_command = "cmake"
59 cmake3_version = CMake._get_version(which("cmake3"))
60 cmake_version = CMake._get_version(which("cmake"))
67 raise RuntimeError("no cmake or cmake3 with version >= 3.18.0 found")
70 cmake_command = "cmake"
77 cmake_command = "cmake"
81 def _get_version(cmd: str | None) -> Any:
82 "Returns cmake version."
86 for line in check_output([cmd, "--version"]).decode("utf-8").split("\n"):
87 if "version" in line:
89 raise RuntimeError("no version found")
91 def run(self, args: list[str], env: dict[str, str]) -> None:
92 "Executes cmake with arguments and an environment."
99 # This error indicates that there was a problem with cmake, the
105 def defines(args: list[str], **kwargs: CMakeValue) -> None:
106 "Adds definitions to a cmake argument list."
109 args.append(f"-D{key}={value}")
111 def get_cmake_cache_variables(self) -> dict[str, CMakeValue]:
114 dict: A ``dict`` containing the value of cached CMake variables.
121 version: str | None,
127 ) -> None:
128 "Runs cmake to generate native build files."
142 # Avoid conflicts in '-G' and the `CMAKE_GENERATOR`
144 args.append("-GNinja")
153 args.append("-G" + generator)
157 toolset_dict["version"] = toolset_version
162 "activate the vs environment of this version. Please read the notes "
168 args.append("-A ARM64")
170 args.append("-Ax64")
174 args.append("-T" + toolset_expr)
188 … # This is a dict that maps environment variables to the corresponding variable name in CMake.
190 …ey: environment variable name. Value: Corresponding variable name to be passed to CMake. If you are
199 …# Build options that have the same environment variable name and CMake variable name and that do n…
249 …# CMakeLists.txt. (`cmake -L` won't print dependent options when the dependency condition is not m…
275 …# Some options must be post-processed. Ideally, this list will be shrunk to only one or two option…
276 …# future, as CMake can detect many of these libraries pretty comfortably. We have them here for no…
277 …# integration is completed. They appear here not in the CMake.defines call below because they star…
281 …: Do not add new build options to this dict if it is directly read from environment variable -- you
283 … # are automatically passed to CMake; For other options you can add to additional_options above.
286 …# Most library detection should go to CMake script, except this one, which Python can do a much be…
298 # error if the user also attempts to set these CMAKE options directly.
308 CMake.defines(
311 TORCH_BUILD_VERSION=version,
318 CMake.defines(args, CMAKE_C_COMPILER=f"{expected_wrapper}/gcc")
320 CMake.defines(args, CMAKE_CXX_COMPILER=f"{expected_wrapper}/g++")
324 # github env vars use utf-8, on windows, non-ascii code may
327 my_env[env_var_name] = str(my_env[env_var_name].encode("utf-8"))
335 # According to the CMake manual, we should pass the arguments first,
339 # 1. https://cmake.org/cmake/help/latest/manual/cmake.1.html#synopsis
344 def build(self, my_env: dict[str, str]) -> None:
345 "Runs cmake to build binaries."
350 "--build",
352 "--target",
354 "--config",
380 # This ``if-else'' clause would be unnecessary when cmake
381 # 3.12 becomes minimum, which provides a '-j' option:
382 # build_args += ['-j', max_jobs] would be sufficient by
383 # then. Until then, we use "--" to pass parameters to the
385 build_args += ["--"]
390 build_args += ["-j", max_jobs]