CMakeLists.txt 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. cmake_minimum_required(VERSION 2.8)
  2. #====================================================================#
  3. # Usage under Linux: #
  4. # #
  5. # From Marlin/buildroot/share/cmake folder: #
  6. # mkdir -p build && cd build #
  7. # cmake .. #
  8. # make #
  9. # #
  10. # Usage under Windows: #
  11. # #
  12. # From Marlin/buildroot/share/cmake folder: #
  13. # mkdir build && cd build #
  14. # cmake -G"Unix Makefiles" .. #
  15. # make #
  16. #====================================================================#
  17. #====================================================================#
  18. # Download marlin-cmake scriptfiles if not already installed #
  19. # and add the path to the module path #
  20. #====================================================================#
  21. set(SCRIPT_BRANCH 1.0.2) #Set to wanted marlin-cmake release tag or branch
  22. if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake)
  23. file(DOWNLOAD https://github.com/tohara/marlin-cmake/archive/${SCRIPT_BRANCH}.tar.gz
  24. ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz SHOW_PROGRESS)
  25. execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xvf ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
  26. file(RENAME ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-${SCRIPT_BRANCH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake)
  27. file(REMOVE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz)
  28. endif()
  29. if(WIN32 AND NOT EXISTS ${CMAKE_BINARY_DIR}/make.exe)
  30. file(COPY ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/resources/make.exe DESTINATION ${CMAKE_BINARY_DIR}/)
  31. endif()
  32. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules)
  33. #====================================================================#
  34. # Custom path to Arduino SDK can be set here. #
  35. # It can also be set from command line. eg.: #
  36. # cmake .. -DARDUINO_SDK_PATH="/path/to/arduino-1.x.x" #
  37. #====================================================================#
  38. #set(ARDUINO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}/arduino-1.6.8)
  39. #set(ARDUINO_SDK_PATH /Applications/Arduino.app/Contents/Java)
  40. #set(ARDUINO_SDK_PATH $HOME/ArduinoAddons/Arduino_1.6.x)
  41. #====================================================================#
  42. # Set included cmake files #
  43. #====================================================================#
  44. include(Arduino_SDK) # Find the intallpath of Arduino SDK
  45. include(marlin_cmake_functions)
  46. #====================================================================#
  47. # Set toolchain file for arduino #
  48. #====================================================================#
  49. set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake) # Arduino Toolchain
  50. #====================================================================#
  51. # Setup Project #
  52. #====================================================================#
  53. project(Marlin C CXX)
  54. #====================================================================#
  55. # Register non standard hardware #
  56. #====================================================================#
  57. #register_hardware_platform(/home/tom/test/Sanguino)
  58. #====================================================================#
  59. # Print any info #
  60. # print_board_list() #
  61. # print_programmer_list() #
  62. # print_board_settings(mega) #
  63. #====================================================================#
  64. print_board_list()
  65. print_programmer_list()
  66. #====================================================================#
  67. # Get motherboard settings from Configuration.h #
  68. # setup_motherboard(TARGET Marlin_src_folder) #
  69. # Returns ${TARGET}_BOARD and ${TARGET}_CPU #
  70. # #
  71. # To set it manually: #
  72. # set(${PROJECT_NAME}_BOARD mega) #
  73. # set(${PROJECT_NAME}_CPU atmega2560) #
  74. #====================================================================#
  75. setup_motherboard(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../../Marlin)
  76. #====================================================================#
  77. # Setup all source files #
  78. # Include Marlin.ino to compile libs not included in *.cpp files #
  79. #====================================================================#
  80. file(GLOB_RECURSE SOURCES "../../../Marlin/*.cpp")
  81. set(${PROJECT_NAME}_SRCS "${SOURCES};../../../Marlin/Marlin.ino")
  82. #====================================================================#
  83. # Define the port for uploading code to the Arduino #
  84. # Can be set from commandline with: #
  85. # cmake .. -DUPLOAD_PORT=/dev/ttyACM0 #
  86. #====================================================================#
  87. if(UPLOAD_PORT)
  88. set(${PROJECT_NAME}_PORT ${UPLOAD_PORT})
  89. else()
  90. set(${PROJECT_NAME}_PORT /dev/ttyACM0)
  91. endif()
  92. #====================================================================#
  93. # Register arduino libraries not included in SDK #
  94. #====================================================================#
  95. #link_directories(/home/tom/test/ArduinoAddons) #U8glib
  96. #set(${PROJECT_NAME}_ARDLIBS U8glib)
  97. #set(U8glib_RECURSE True)
  98. #====================================================================#
  99. # Command to generate code arduino firmware (.hex file) #
  100. #====================================================================#
  101. generate_arduino_firmware(${PROJECT_NAME})