1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-25 12:57:53 +00:00
MarlinFirmware/buildroot/share/cmake/CMakeLists.txt

124 lines
6.5 KiB
CMake
Raw Normal View History

2016-11-18 04:07:47 +00:00
cmake_minimum_required(VERSION 2.8)
#====================================================================#
# Usage under Linux: #
# #
# From Marlin/buildroot/share/cmake folder: #
# mkdir -p build && cd build #
# cmake .. #
# make #
# #
# Usage under Windows: #
# #
2017-01-15 05:39:26 +00:00
# From Marlin/buildroot/share/cmake folder: #
2016-11-18 04:07:47 +00:00
# mkdir build && cd build #
# cmake -G"Unix Makefiles" .. #
# make #
#====================================================================#
2017-04-20 22:43:19 +00:00
2016-11-18 04:07:47 +00:00
#====================================================================#
# Download marlin-cmake scriptfiles if not already installed #
# and add the path to the module path #
#====================================================================#
2017-01-15 05:39:26 +00:00
set(SCRIPT_BRANCH 1.0.2) #Set to wanted marlin-cmake release tag or branch
2016-11-18 04:07:47 +00:00
2017-01-15 05:39:26 +00:00
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake)
file(DOWNLOAD https://github.com/tohara/marlin-cmake/archive/${SCRIPT_BRANCH}.tar.gz
${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz SHOW_PROGRESS)
2017-04-20 22:43:19 +00:00
2017-01-15 05:39:26 +00:00
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xvf ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
2017-04-20 22:43:19 +00:00
2017-01-15 05:39:26 +00:00
file(RENAME ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-${SCRIPT_BRANCH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake)
file(REMOVE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz)
2017-04-20 22:43:19 +00:00
2017-01-15 05:39:26 +00:00
endif()
2016-11-18 04:07:47 +00:00
2017-01-15 05:39:26 +00:00
if(WIN32 AND NOT EXISTS ${CMAKE_BINARY_DIR}/make.exe)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/resources/make.exe DESTINATION ${CMAKE_BINARY_DIR}/)
2016-11-18 04:07:47 +00:00
endif()
2017-01-15 05:39:26 +00:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules)
2016-11-18 04:07:47 +00:00
#====================================================================#
# Custom path to Arduino SDK can be set here. #
# It can also be set from command line. eg.: #
# cmake .. -DARDUINO_SDK_PATH="/path/to/arduino-1.x.x" #
#====================================================================#
#set(ARDUINO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}/arduino-1.6.8)
#set(ARDUINO_SDK_PATH /home/tom/git/BigBox-Dual-Marlin/ArduinoAddons/Arduino_1.6.x)
#set(ARDUINO_SDK_PATH /home/tom/test/arduino-1.6.11)
#====================================================================#
# Set included cmake files #
#====================================================================#
include(Arduino_SDK) # Find the intallpath of Arduino SDK
include(marlin_cmake_functions)
#====================================================================#
# Set toolchain file for arduino #
#====================================================================#
2017-01-15 05:39:26 +00:00
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake) # Arduino Toolchain
2016-11-18 04:07:47 +00:00
#====================================================================#
# Setup Project #
#====================================================================#
project(Marlin C CXX)
#====================================================================#
# Register non standard hardware #
#====================================================================#
#register_hardware_platform(/home/tom/test/Sanguino)
#====================================================================#
# Print any info #
# print_board_list() #
# print_programmer_list() #
# print_board_settings(mega) #
#====================================================================#
print_board_list()
print_programmer_list()
#====================================================================#
# Get motherboard settings from Configuration.h #
# setup_motherboard(TARGET Marlin_src_folder) #
# Returns ${TARGET}_BOARD and ${TARGET}_CPU #
# #
# To set it manually: #
# set(${PROJECT_NAME}_BOARD mega) #
# set(${PROJECT_NAME}_CPU atmega2560) #
#====================================================================#
setup_motherboard(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../../Marlin)
#====================================================================#
# Setup all source files #
2017-09-06 11:28:32 +00:00
# Include Marlin.ino to compile libs not included in *.cpp files #
2016-11-18 04:07:47 +00:00
#====================================================================#
2017-09-06 11:28:32 +00:00
file(GLOB SOURCES "../../../src/*.cpp")
set(${PROJECT_NAME}_SRCS "${SOURCES};../../../src/Marlin.ino")
2016-11-18 04:07:47 +00:00
#====================================================================#
# Define the port for uploading code to the Arduino #
# Can be set from commandline with: #
# cmake .. -DUPLOAD_PORT=/dev/ttyACM0 #
#====================================================================#
if(UPLOAD_PORT)
set(${PROJECT_NAME}_PORT ${UPLOAD_PORT})
else()
set(${PROJECT_NAME}_PORT /dev/ttyACM0)
endif()
#====================================================================#
# Register arduino libraries not included in SDK #
#====================================================================#
#link_directories(/home/tom/test/ArduinoAddons) #U8glib
#set(${PROJECT_NAME}_ARDLIBS U8glib)
#set(U8glib_RECURSE True)
#====================================================================#
# Command to generate code arduino firmware (.hex file) #
#====================================================================#
generate_arduino_firmware(${PROJECT_NAME})