|
@@ -0,0 +1,89 @@
|
|
1
|
+#=============================================================================#
|
|
2
|
+# Author: Tomasz Bogdal (QueezyTheGreat)
|
|
3
|
+# Home: https://github.com/queezythegreat/arduino-cmake
|
|
4
|
+#
|
|
5
|
+# This Source Code Form is subject to the terms of the Mozilla Public
|
|
6
|
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
7
|
+# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
8
|
+#=============================================================================#
|
|
9
|
+set(CMAKE_SYSTEM_NAME Arduino)
|
|
10
|
+
|
|
11
|
+set(CMAKE_C_COMPILER avr-gcc)
|
|
12
|
+set(CMAKE_CXX_COMPILER avr-g++)
|
|
13
|
+
|
|
14
|
+# Add current directory to CMake Module path automatically
|
|
15
|
+if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/Platform/Arduino.cmake)
|
|
16
|
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
|
|
17
|
+endif()
|
|
18
|
+
|
|
19
|
+#=============================================================================#
|
|
20
|
+# System Paths #
|
|
21
|
+#=============================================================================#
|
|
22
|
+if(UNIX)
|
|
23
|
+ include(Platform/UnixPaths)
|
|
24
|
+ if(APPLE)
|
|
25
|
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH ~/Applications
|
|
26
|
+ /Applications
|
|
27
|
+ /Developer/Applications
|
|
28
|
+ /sw # Fink
|
|
29
|
+ /opt/local) # MacPorts
|
|
30
|
+ endif()
|
|
31
|
+elseif(WIN32)
|
|
32
|
+ include(Platform/WindowsPaths)
|
|
33
|
+endif()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+#=============================================================================#
|
|
37
|
+# Detect Arduino SDK #
|
|
38
|
+#=============================================================================#
|
|
39
|
+if(NOT ARDUINO_SDK_PATH)
|
|
40
|
+ set(ARDUINO_PATHS)
|
|
41
|
+
|
|
42
|
+ foreach(DETECT_VERSION_MAJOR 1)
|
|
43
|
+ foreach(DETECT_VERSION_MINOR RANGE 5 0)
|
|
44
|
+ list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR})
|
|
45
|
+ foreach(DETECT_VERSION_PATCH RANGE 3 0)
|
|
46
|
+ list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR}.${DETECT_VERSION_PATCH})
|
|
47
|
+ endforeach()
|
|
48
|
+ endforeach()
|
|
49
|
+ endforeach()
|
|
50
|
+
|
|
51
|
+ foreach(VERSION RANGE 23 19)
|
|
52
|
+ list(APPEND ARDUINO_PATHS arduino-00${VERSION})
|
|
53
|
+ endforeach()
|
|
54
|
+
|
|
55
|
+ if(UNIX)
|
|
56
|
+ file(GLOB SDK_PATH_HINTS /usr/share/arduino*
|
|
57
|
+ /opt/local/arduino*
|
|
58
|
+ /opt/arduino*
|
|
59
|
+ /usr/local/share/arduino*)
|
|
60
|
+ elseif(WIN32)
|
|
61
|
+ set(SDK_PATH_HINTS "C:\\Program Files\\Arduino"
|
|
62
|
+ "C:\\Program Files (x86)\\Arduino"
|
|
63
|
+ )
|
|
64
|
+ endif()
|
|
65
|
+ list(SORT SDK_PATH_HINTS)
|
|
66
|
+ list(REVERSE SDK_PATH_HINTS)
|
|
67
|
+endif()
|
|
68
|
+
|
|
69
|
+find_path(ARDUINO_SDK_PATH
|
|
70
|
+ NAMES lib/version.txt
|
|
71
|
+ PATH_SUFFIXES share/arduino
|
|
72
|
+ Arduino.app/Contents/Java/
|
|
73
|
+ Arduino.app/Contents/Resources/Java/
|
|
74
|
+ ${ARDUINO_PATHS}
|
|
75
|
+ HINTS ${SDK_PATH_HINTS}
|
|
76
|
+ DOC "Arduino SDK path.")
|
|
77
|
+
|
|
78
|
+if(ARDUINO_SDK_PATH)
|
|
79
|
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr)
|
|
80
|
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils)
|
|
81
|
+else()
|
|
82
|
+ message(FATAL_ERROR "Could not find Arduino SDK (set ARDUINO_SDK_PATH)!")
|
|
83
|
+endif()
|
|
84
|
+
|
|
85
|
+set(ARDUINO_CPUMENU)
|
|
86
|
+if(ARDUINO_CPU)
|
|
87
|
+ set(ARDUINO_CPUMENU ".menu.cpu.${ARDUINO_CPU}")
|
|
88
|
+endif(ARDUINO_CPU)
|
|
89
|
+
|