0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-01-22 09:42:34 +00:00

🔨 Fix cmake build on Linux (#27605)

This commit is contained in:
Andrew 2025-01-11 16:09:49 -05:00 committed by GitHub
parent a7d79618b9
commit 8d7ecad531
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,15 +1,17 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10)
#====================================================================#
# Usage under Linux: #
# #
# From Marlin/buildroot/share/cmake folder: #
# From the project folder: #
# cd buildroot/share/cmake #
# mkdir -p build && cd build #
# cmake .. #
# make #
# #
# Usage under Windows: #
# #
# From Marlin/buildroot/share/cmake folder: #
# From the project folder: #
# cd buildroot/share/cmake #
# mkdir build && cd build #
# cmake -G"Unix Makefiles" .. #
# make #
@ -82,9 +84,20 @@ message("-- Running CMake version: " ${CMAKE_VERSION})
# Replace the CMake Ver. in the Arduino.cmake
file(READ "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake" ORIGINAL_FILE_CONTENTS)
string(REGEX REPLACE "cmake_minimum_required\\(VERSION[^\n]*\n" "cmake_minimum_required(VERSION 3.5)\n" NEW_FILE_CONTENTS "${ORIGINAL_FILE_CONTENTS}")
string(REGEX REPLACE "cmake_minimum_required\\(VERSION[^\n]*\n" "cmake_minimum_required(VERSION 3.10)\n" NEW_FILE_CONTENTS "${ORIGINAL_FILE_CONTENTS}")
file(WRITE "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake" "${NEW_FILE_CONTENTS}")
# Fix "CMake Error... avr-gcc / avr-g++ is not a full path..."
if(UNIX)
set(ORIGINAL_FILE_CONTENTS "")
set(NEW_FILE_CONTENTS "")
file(READ "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake" ORIGINAL_FILE_CONTENTS)
string(REPLACE "set(CMAKE_C_COMPILER avr-gcc)\nset(CMAKE_CXX_COMPILER avr-g++)"
"set(CMAKE_C_COMPILER /usr/bin/gcc)\nset(CMAKE_CXX_COMPILER /usr/bin/gcc)"
NEW_FILE_CONTENTS "${ORIGINAL_FILE_CONTENTS}")
file(WRITE "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake" "${NEW_FILE_CONTENTS}")
endif(UNIX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules)
#====================================================================#
@ -116,6 +129,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/Arduin
# Go to the file in your CMake directory #
# #
# For Windows: cmake\Modules\Platform\WindowsPaths.cmake #
# For macOS: cmake/Modules/Platform/UnixPaths.cmake #
# For Linux: cmake/Modules/Platform/UnixPaths.cmake #
# #
# Comment out "_cmake_record_install_prefix()" #