Skip to content

Commit

Permalink
Python script to generate cmake config file for mlc_chat_cli (octom…
Browse files Browse the repository at this point in the history
…l#221)

* upd

* add cmake build type

* fix
  • Loading branch information
yzh119 authored May 23, 2023
1 parent 1f53191 commit 7db313c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cmake/gen_cmake_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from collections import namedtuple

Backend = namedtuple("Backend", ["name", "cmake_config_name", "prompt_str"])

if __name__ == "__main__":
cmake_config_str = "set(CMAKE_BUILD_TYPE RelWithDebInfo)\n"
backends = [
Backend("CUDA", "USE_CUDA", "Use CUDA? (y/n): "),
Backend("Vulkan", "USE_VULKAN", "Use Vulkan? (y/n): "),
Backend(
"Metal",
"USE_METAL",
"Use Metal (Apple M1/M2 GPU) ? (y/n): ",
),
]

for backend in backends:
while True:
use_backend = input(backend.prompt_str)
if use_backend in ["yes", "Y", "y"]:
cmake_config_str += "set({} ON)\n".format(backend.cmake_config_name)
break
elif use_backend in ["no", "N", "n"]:
cmake_config_str += "set({} OFF)\n".format(backend.cmake_config_name)
break
else:
print("Invalid input: {}. Please input again.".format(use_backend))
print(cmake_config_str)
print("Writing configuration to config.cmake...")

with open("config.cmake", "w") as f:
f.write(cmake_config_str)

0 comments on commit 7db313c

Please sign in to comment.