1+ #=============================================================================#
2+ # Attempts to find the Arduino SDK in the host system, searching at known locations.
3+ # For each host OS the locations are different, however, eventually they all search for the
4+ # 'lib/version.txt' file, which is located directly under the SDK directory under ALL OSs.
5+ # _return_var - Name of variable in parent-scope holding the return value.
6+ # Returns - Path to the found Arudino SDK.
7+ #=============================================================================#
18function (find_arduino_sdk _return_var)
29
310 if (${CMAKE_HOST_UNIX} )
@@ -12,24 +19,19 @@ function(find_arduino_sdk _return_var)
1219 set (platform_search_paths "C:/Program Files (x86)/Arduino" "C:/Program Files/Arduino" )
1320 endif ()
1421
15- find_program (arduino_program_path
16- NAMES arduino
22+ find_path (ARDUINO_SDK_PATH
23+ NAMES lib/ version .txt
1724 HINTS ${platform_search_paths}
1825 NO_DEFAULT_PATH
1926 NO_CMAKE_FIND_ROOT_PATH )
20- get_filename_component (sdk_path "${arduino_program_path} " DIRECTORY )
2127
22- if (NOT sdk_path OR " ${sdk_path} " MATCHES "NOTFOUND" )
28+ if (${ARDUINO_SDK_PATH} MATCHES "NOTFOUND" )
2329 string (CONCAT error_message
2430 "Couldn't find Arduino SDK path - Is it in a non-standard location?" "\n "
2531 "If so, please set the ARDUINO_SDK_PATH CMake-Variable" )
2632 message (FATAL_ERROR ${error_message} )
2733 else ()
28- if (${CMAKE_HOST_APPLE} )
29- get_filename_component (sdk_path "${sdk_path} " DIRECTORY )
30- string (APPEND sdk_path "/Java" )
31- endif ()
32- set (${_return_var} "${sdk_path} " PARENT_SCOPE)
34+ set (${_return_var} "${ARDUINO_SDK_PATH} " PARENT_SCOPE)
3335 endif ()
3436
3537endfunction ()
0 commit comments