Skip to content

Commit

Permalink
check for build requirements and abort build process if not satisied
Browse files Browse the repository at this point in the history
- python>=3.9
- cmake>=3.22
- clang>=18 on windows use the msvc-clang (>=17)

fix microsoft#34
  • Loading branch information
bmerkle committed Oct 19, 2024
1 parent e9ab883 commit f30c1de
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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 @@ -173,7 +173,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
19 changes: 19 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@ 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
(NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
message(FATAL_ERROR "Clang 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()

0 comments on commit f30c1de

Please sign in to comment.