Browse Source

Added CMake support

tohara 8 years ago
parent
commit
f579ec2e7a
1 changed files with 128 additions and 0 deletions
  1. 128
    0
      buildroot/share/cmake/CMakeLists.txt

+ 128
- 0
buildroot/share/cmake/CMakeLists.txt View File

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
+#====================================================================#
19
+# Download marlin-cmake scriptfiles if not already installed         #
20
+# and add the path to the module path                                #
21
+#====================================================================#
22
+
23
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/marlin-cmake)
24
+
25
+    file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/v1.0.0/modules/Arduino_SDK.cmake
26
+                  ${CMAKE_BINARY_DIR}/marlin-cmake/modules/Arduino_SDK.cmake SHOW_PROGRESS)
27
+                  
28
+    file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/v1.0.0/modules/marlin_cmake_functions.cmake
29
+                  ${CMAKE_BINARY_DIR}/marlin-cmake/modules/marlin_cmake_functions.cmake SHOW_PROGRESS)             
30
+    
31
+    file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/v1.0.0/Platform/Arduino.cmake
32
+                  ${CMAKE_BINARY_DIR}/marlin-cmake/Platform/Arduino.cmake SHOW_PROGRESS)
33
+    
34
+    file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/v1.0.0/settings/marlin_boards.txt
35
+                  ${CMAKE_BINARY_DIR}/marlin-cmake/settings/marlin_boards.txt SHOW_PROGRESS)
36
+                  
37
+    file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/v1.0.0/toolchain/ArduinoToolchain.cmake
38
+                  ${CMAKE_BINARY_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake SHOW_PROGRESS)
39
+              
40
+    if(WIN32)
41
+        file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/v1.0.0/resources/make.exe
42
+                      ${CMAKE_BINARY_DIR}/make.exe SHOW_PROGRESS)
43
+    endif(WIN32)
44
+
45
+endif()
46
+
47
+set(CMAKE_MODULE_PATH  ${CMAKE_MODULE_PATH} ${CMAKE_BINARY_DIR}/marlin-cmake/modules)
48
+
49
+#====================================================================#
50
+#  Custom path to Arduino SDK can be set here.                       #
51
+#  It can also be set from command line. eg.:                        #
52
+#  cmake .. -DARDUINO_SDK_PATH="/path/to/arduino-1.x.x"              #
53
+#====================================================================#
54
+#set(ARDUINO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}/arduino-1.6.8)
55
+#set(ARDUINO_SDK_PATH /home/tom/git/BigBox-Dual-Marlin/ArduinoAddons/Arduino_1.6.x)
56
+#set(ARDUINO_SDK_PATH  /home/tom/test/arduino-1.6.11)
57
+#====================================================================#
58
+#  Set included cmake files                                          #
59
+#====================================================================#
60
+include(Arduino_SDK) # Find the intallpath of Arduino SDK
61
+include(marlin_cmake_functions)
62
+
63
+#====================================================================#
64
+#  Set toolchain file for arduino                                    #
65
+#====================================================================#
66
+set(CMAKE_TOOLCHAIN_FILE ${CMAKE_BINARY_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake) # Arduino Toolchain
67
+
68
+#====================================================================#
69
+#  Setup Project                                                     #
70
+#====================================================================#
71
+project(Marlin C CXX)
72
+
73
+#====================================================================#
74
+#  Register non standard hardware                                    #
75
+#====================================================================#
76
+#register_hardware_platform(/home/tom/test/Sanguino)
77
+
78
+#====================================================================#
79
+#  Print any info                                                    #
80
+#  print_board_list()                                                #
81
+#  print_programmer_list()                                           #
82
+#  print_board_settings(mega)                                        #
83
+#====================================================================#
84
+print_board_list()
85
+print_programmer_list()
86
+
87
+
88
+#====================================================================#
89
+#  Get motherboard settings from Configuration.h                     #
90
+#  setup_motherboard(TARGET Marlin_src_folder)                       #
91
+#  Returns ${TARGET}_BOARD and ${TARGET}_CPU                         #
92
+#                                                                    #
93
+#  To set it manually:                                               #
94
+#    set(${PROJECT_NAME}_BOARD mega)                                 #
95
+#    set(${PROJECT_NAME}_CPU atmega2560)                             #
96
+#====================================================================#
97
+setup_motherboard(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../../Marlin)
98
+
99
+#====================================================================#
100
+#  Setup all source files                                            #
101
+#  Incude Marlin.ino to compile libs not included in *.cpp files     #
102
+#====================================================================#
103
+
104
+file(GLOB SOURCES "../../../Marlin/*.cpp")
105
+set(${PROJECT_NAME}_SRCS "${SOURCES};../../../Marlin/Marlin.ino")
106
+
107
+#====================================================================#
108
+#  Define the port for uploading code to the Arduino                 #
109
+#  Can be set from commandline with:                                 #
110
+#    cmake .. -DUPLOAD_PORT=/dev/ttyACM0                             #
111
+#====================================================================#
112
+if(UPLOAD_PORT)
113
+    set(${PROJECT_NAME}_PORT ${UPLOAD_PORT})
114
+else()
115
+    set(${PROJECT_NAME}_PORT /dev/ttyACM0)
116
+endif()
117
+
118
+#====================================================================#
119
+#  Register arduino libraries not included in SDK                    #
120
+#====================================================================#
121
+#link_directories(/home/tom/test/ArduinoAddons) #U8glib
122
+#set(${PROJECT_NAME}_ARDLIBS U8glib)
123
+#set(U8glib_RECURSE True)
124
+
125
+#====================================================================#
126
+# Command to generate code arduino firmware (.hex file)              #
127
+#====================================================================#
128
+generate_arduino_firmware(${PROJECT_NAME})

Loading…
Cancel
Save