You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. set(CMAKE_C_COMPILER avr-gcc)
  11. set(CMAKE_CXX_COMPILER avr-g++)
  12. # Add current directory to CMake Module path automatically
  13. if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/Platform/Arduino.cmake)
  14. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
  15. endif()
  16. #=============================================================================#
  17. # System Paths #
  18. #=============================================================================#
  19. if(UNIX)
  20. include(Platform/UnixPaths)
  21. if(APPLE)
  22. list(APPEND CMAKE_SYSTEM_PREFIX_PATH ~/Applications
  23. /Applications
  24. /Developer/Applications
  25. /sw # Fink
  26. /opt/local) # MacPorts
  27. endif()
  28. elseif(WIN32)
  29. include(Platform/WindowsPaths)
  30. endif()
  31. #=============================================================================#
  32. # Detect Arduino SDK #
  33. #=============================================================================#
  34. if(NOT ARDUINO_SDK_PATH)
  35. set(ARDUINO_PATHS)
  36. foreach(DETECT_VERSION_MAJOR 1)
  37. foreach(DETECT_VERSION_MINOR RANGE 5 0)
  38. list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR})
  39. foreach(DETECT_VERSION_PATCH RANGE 3 0)
  40. list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR}.${DETECT_VERSION_PATCH})
  41. endforeach()
  42. endforeach()
  43. endforeach()
  44. foreach(VERSION RANGE 23 19)
  45. list(APPEND ARDUINO_PATHS arduino-00${VERSION})
  46. endforeach()
  47. if(UNIX)
  48. file(GLOB SDK_PATH_HINTS /usr/share/arduino*
  49. /opt/local/arduino*
  50. /opt/arduino*
  51. /usr/local/share/arduino*)
  52. elseif(WIN32)
  53. set(SDK_PATH_HINTS "C:\\Program Files\\Arduino"
  54. "C:\\Program Files (x86)\\Arduino"
  55. )
  56. endif()
  57. list(SORT SDK_PATH_HINTS)
  58. list(REVERSE SDK_PATH_HINTS)
  59. endif()
  60. find_path(ARDUINO_SDK_PATH
  61. NAMES lib/version.txt
  62. PATH_SUFFIXES share/arduino
  63. Arduino.app/Contents/Java/
  64. Arduino.app/Contents/Resources/Java/
  65. ${ARDUINO_PATHS}
  66. HINTS ${SDK_PATH_HINTS}
  67. DOC "Arduino SDK path.")
  68. if(ARDUINO_SDK_PATH)
  69. list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr)
  70. list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils)
  71. else()
  72. message(FATAL_ERROR "Could not find Arduino SDK (set ARDUINO_SDK_PATH)!")
  73. endif()
  74. set(ARDUINO_CPUMENU)
  75. if(ARDUINO_CPU)
  76. set(ARDUINO_CPUMENU ".menu.cpu.${ARDUINO_CPU}")
  77. endif(ARDUINO_CPU)