diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ddaa51f..72da3ba3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/setup_env.py b/setup_env.py index 8a9c4b46..ee44d4ee 100644 --- a/setup_env.py +++ b/setup_env.py @@ -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() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bac84596..2674de60 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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() +