Marlin_Firmware/buildroot/share/cmake/CMakeLists.txt

124 lines
6.4 KiB
CMake
Raw Permalink Normal View History

2016-11-17 22:07:47 -06: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-14 23:39:26 -06:00
# From Marlin/buildroot/share/cmake folder: #
2016-11-17 22:07:47 -06:00
# mkdir build && cd build #
# cmake -G"Unix Makefiles" .. #
# make #
#====================================================================#
2017-04-20 17:43:19 -05:00
2016-11-17 22:07:47 -06:00
#====================================================================#
# Download marlin-cmake scriptfiles if not already installed #
# and add the path to the module path #
#====================================================================#
2017-01-14 23:39:26 -06:00
set(SCRIPT_BRANCH 1.0.2) #Set to wanted marlin-cmake release tag or branch
2016-11-17 22:07:47 -06:00
2017-01-14 23:39:26 -06: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 17:43:19 -05:00
2017-01-14 23:39:26 -06: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 17:43:19 -05:00
2017-01-14 23:39:26 -06: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 17:43:19 -05:00
2017-01-14 23:39:26 -06:00
endif()
2016-11-17 22:07:47 -06:00
2017-01-14 23:39:26 -06: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-17 22:07:47 -06:00
endif()
2017-01-14 23:39:26 -06:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules)
2016-11-17 22:07:47 -06: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 /Applications/Arduino.app/Contents/Java)
#set(ARDUINO_SDK_PATH $HOME/ArduinoAddons/Arduino_1.6.x)
2016-11-17 22:07:47 -06:00
#====================================================================#
# Set included cmake files #
#====================================================================#
include(Arduino_SDK) # Find the intallpath of Arduino SDK
include(marlin_cmake_functions)
#====================================================================#
# Set toolchain file for arduino #
#====================================================================#
2017-01-14 23:39:26 -06:00
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake) # Arduino Toolchain
2016-11-17 22:07:47 -06: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 06:28:32 -05:00
# Include Marlin.ino to compile libs not included in *.cpp files #
2016-11-17 22:07:47 -06:00
#====================================================================#
file(GLOB_RECURSE SOURCES "../../../Marlin/*.cpp")
set(${PROJECT_NAME}_SRCS "${SOURCES};../../../Marlin/Marlin.ino")
2016-11-17 22:07:47 -06: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})