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: # # Usage under Linux: #
# # # #
# From Marlin/buildroot/share/cmake folder: # # From the project folder: #
# cd buildroot/share/cmake #
# mkdir -p build && cd build # # mkdir -p build && cd build #
# cmake .. # # cmake .. #
# make # # make #
# # # #
# Usage under Windows: # # Usage under Windows: #
# # # #
# From Marlin/buildroot/share/cmake folder: # # From the project folder: #
# cd buildroot/share/cmake #
# mkdir build && cd build # # mkdir build && cd build #
# cmake -G"Unix Makefiles" .. # # cmake -G"Unix Makefiles" .. #
# make # # make #
@ -82,10 +84,21 @@ message("-- Running CMake version: " ${CMAKE_VERSION})
# Replace the CMake Ver. in the Arduino.cmake # Replace the CMake Ver. in the Arduino.cmake
file(READ "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake" ORIGINAL_FILE_CONTENTS) 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}") file(WRITE "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake" "${NEW_FILE_CONTENTS}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules) # 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)
#====================================================================# #====================================================================#
# Custom path to Arduino SDK can be set here # # Custom path to Arduino SDK can be set here #
@ -116,6 +129,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/Arduin
# Go to the file in your CMake directory # # Go to the file in your CMake directory #
# # # #
# For Windows: cmake\Modules\Platform\WindowsPaths.cmake # # For Windows: cmake\Modules\Platform\WindowsPaths.cmake #
# For macOS: cmake/Modules/Platform/UnixPaths.cmake #
# For Linux: cmake/Modules/Platform/UnixPaths.cmake # # For Linux: cmake/Modules/Platform/UnixPaths.cmake #
# # # #
# Comment out "_cmake_record_install_prefix()" # # Comment out "_cmake_record_install_prefix()" #