Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for build requirements and abort build process if not satisfied #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14) # for add_link_options and implicit target directories.
cmake_minimum_required(VERSION 3.22) # for add_link_options and implicit target directories.
project("bitnet.cpp" C CXX)
include(CheckIncludeFileCXX)

Expand Down
8 changes: 8 additions & 0 deletions setup_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,15 @@ def compile():
# run_command(["cmake", "--build", "build", "--target", "llama-cli", "--config", "Release"])
run_command(["cmake", "--build", "build", "--config", "Release"], log_step="compile")

def check_python_version():
python_version = sys.version_info
if python_version < (3, 9):
logging.error("Python 3.9 or higher is required for Bitnet.cpp.")
sys.exit(1)
logging.info(f"Python version: {python_version.major}.{python_version.minor}.{python_version.micro}")

def main():
check_python_version()
setup_gguf()
gen_code()
compile()
Expand Down
21 changes: 21 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@ set(GGML_SOURCES_BITNET ggml-bitnet-lut.cpp)

include_directories(3rdparty/llama.cpp/ggml/include)


if(CMAKE_VERSION VERSION_LESS "3.22")
message(FATAL_ERROR "CMake version 3.22 or higher is required for Bitnet.cpp compilation")
endif()

if (NOT (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
message(FATAL_ERROR "Clang or GCC is required for Bitnet.cpp compilation")
else()
# Check for minimum Clang version:
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
# on Windows we use the Visual Studio Clang compiler (in 2022 it is version 17.)
message(STATUS "Visual Studio Clang compiler is being used.")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
message(FATAL_ERROR "Visual Studio Clang version 17.0 or higher is required for Bitnet.cpp compilation")
endif()
else()
# on Linux Clang compiler >= 18.0 is required.
message(STATUS "Linux/Mac Clang compiler is being used.")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Clang version 18.0 or higher is required for Bitnet.cpp compilation")
endif()
endif()
endif()