Skip to content

Commit 65848d8

Browse files
Added dependency detection for Windows
Added Windows enviroment setup to README
1 parent 5e84f75 commit 65848d8

File tree

5 files changed

+55
-24
lines changed

5 files changed

+55
-24
lines changed

README.markdown

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ TODO:
2828

2929
* Sketch conversion (PDE files)
3030
* Setup dependency detection for:
31-
* Windows
3231
* Mac OS X
3332
* Test more complex configurations and error handling
3433

@@ -39,6 +38,7 @@ Contents
3938
2. Setting up Arduino CMake
4039
3. Creating firmware images
4140
4. Creating libraries
41+
5. Windows Enviroment Setup
4242

4343
Getting Started
4444
----------------
@@ -206,3 +206,12 @@ Once that library is defined we can use it in our other firmware images... Lets
206206

207207
generate_arduino_firmware(blink)
208208

209+
210+
Windows Enviroment Setup
211+
------------------------
212+
213+
On Windows the *Arduino SDK* is self contained and has everything needed for building. The only thing that has to be done is to place the *Arduino SDK* either on the **system path** or within the system **Program Files** directory. Also you will need to add the ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils/bin directory path to your system path, just make sure it is the first thing on list.
214+
215+
Once that is done you can start using CMake the usual way, just make sure to chose a **MSYS Makefile** type generator.
216+
217+
NOTE: Don't change the default **Arduino SDK** directory name, otherwise auto detection will no work properly!

cmake/modules/FindArduino.cmake

+20-22
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848

4949
find_path(ARDUINO_SDK_PATH
50-
NAMES examples lib libraries reference tools hardware revisions.txt
50+
NAMES lib/version.txt hardware libraries
5151
PATH_SUFFIXES share/arduino
5252
DOC "Arduino Development Kit path.")
5353

@@ -57,7 +57,7 @@ find_path(ARDUINO_SDK_PATH
5757
# Load the Arduino SDK board settings from the boards.txt file.
5858
#
5959
function(LOAD_BOARD_SETTINGS)
60-
if(NOT ARDUINO_BOARDS)
60+
if(NOT ARDUINO_BOARDS AND ARDUINO_BOARDS_PATH)
6161
file(STRINGS ${ARDUINO_BOARDS_PATH} BOARD_SETTINGS)
6262
foreach(BOARD_SETTING ${BOARD_SETTINGS})
6363
if("${BOARD_SETTING}" MATCHES "^.*=.*")
@@ -479,13 +479,12 @@ endfunction()
479479
# Detects the Arduino SDK Version based on the revisions.txt file.
480480
#
481481
function(detect_arduino_version VAR_NAME)
482-
file(STRINGS ${ARDUINO_REVISIONS_PATH} REVISIONS_CONTENT)
483-
foreach(LINE ${REVISIONS_CONTENT})
484-
if("${LINE}" MATCHES " *ARDUINO [0]+([0-9]+) - (.*)")
482+
if(ARDUINO_VERSION_PATH)
483+
file(READ ${ARDUINO_VERSION_PATH} ARD_VERSION)
484+
if("${ARD_VERSION}" MATCHES " *[0]+([0-9]+)")
485485
set(${VAR_NAME} ${CMAKE_MATCH_1} PARENT_SCOPE)
486-
return()
487486
endif()
488-
endforeach()
487+
endif()
489488
endfunction()
490489

491490

@@ -518,6 +517,10 @@ if(NOT ARDUINO_FOUND)
518517
NAMES revisions.txt
519518
PATHS ${ARDUINO_SDK_PATH})
520519

520+
find_file(ARDUINO_VERSION_PATH
521+
NAMES lib/version.txt
522+
PATHS ${ARDUINO_SDK_PATH})
523+
521524
find_program(ARDUINO_AVRDUDE_PROGRAM
522525
NAMES avrdude
523526
PATHS ${ARDUINO_SDK_PATH}
@@ -533,8 +536,16 @@ if(NOT ARDUINO_FOUND)
533536
set(ARDUINO_OBJCOPY_HEX_FLAGS -O ihex -R .eeprom
534537
CACHE STRING "")
535538

536-
detect_arduino_version(ARDUINO_SDK_VERSION)
537-
set(ARDUINO_SDK_VERSION ${ARDUINO_SDK_VERSION} CACHE STRING "Arduino SDK Version")
539+
if(ARDUINO_SDK_PATH)
540+
detect_arduino_version(ARDUINO_SDK_VERSION)
541+
set(ARDUINO_SDK_VERSION ${ARDUINO_SDK_VERSION} CACHE STRING "Arduino SDK Version")
542+
endif(ARDUINO_SDK_PATH)
543+
544+
include(FindPackageHandleStandardArgs)
545+
find_package_handle_standard_args(Arduino
546+
REQUIRED_VARS ARDUINO_SDK_PATH
547+
ARDUINO_SDK_VERSION
548+
VERSION_VAR ARDUINO_SDK_VERSION)
538549

539550

540551
mark_as_advanced(ARDUINO_CORES_PATH
@@ -549,18 +560,5 @@ if(NOT ARDUINO_FOUND)
549560
ARDUINO_OBJCOPY_HEX_FLAGS)
550561
load_board_settings()
551562

552-
include(FindPackageHandleStandardArgs)
553-
find_package_handle_standard_args(Arduino
554-
REQUIRED_VARS ARDUINO_SDK_PATH
555-
ARDUINO_CORES_PATH
556-
ARDUINO_SDK_VERSION
557-
ARDUINO_LIBRARIES_PATH
558-
ARDUINO_BOARDS_PATH
559-
ARDUINO_PROGRAMMERS_PATH
560-
ARDUINO_REVISIONS_PATH
561-
ARDUINO_AVRDUDE_PROGRAM
562-
ARDUINO_AVRDUDE_CONFIG_PATH
563-
ARDUINO_SDK_VERSION
564-
VERSION_VAR ARDUINO_SDK_VERSION)
565563
endif()
566564

cmake/modules/Platform/Arduino.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
INCLUDE(Platform/UnixPaths)
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if(UNIX)
2+
INCLUDE(Platform/UnixPaths)
3+
elseif(WIN32)
4+
INCLUDE(Platform/WindowsPaths)
5+
endif()
6+
7+
if(ARDUINO_SDK_PATH)
8+
if(WIN32)
9+
LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/bin)
10+
LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils/bin)
11+
endif()
12+
endif()

cmake/toolchains/Arduino.cmake

+13
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,16 @@ set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions")
99
set(CMAKE_EXE_LINKER_FLAGS "-Os -Wl,--gc-sections")
1010
set(CMAKE_SHARED_LINKER_FLAGS)
1111
set(CMAKE_MODULE_LINKER_FLAGS)
12+
13+
set(ARDUINO_PATHS)
14+
foreach(VERSION RANGE 22 1)
15+
list(APPEND ARDUINO_PATHS arduino-00${VERSION})
16+
endforeach()
17+
18+
find_path(ARDUINO_SDK_PATH
19+
NAMES lib/version.txt
20+
PATH_SUFFIXES share/arduino
21+
${ARDUINO_PATHS}
22+
DOC "Arduino Development Kit path.")
23+
24+
include(Platform/ArduinoPaths)

0 commit comments

Comments
 (0)