diff --git a/Arduino/System/PackagePathIndex.cmake b/Arduino/System/PackagePathIndex.cmake index 0ec6986..65c57bc 100644 --- a/Arduino/System/PackagePathIndex.cmake +++ b/Arduino/System/PackagePathIndex.cmake @@ -19,7 +19,8 @@ function(InitializeArduinoPackagePathList) if (${CMAKE_HOST_APPLE}) - set(install_search_paths "$ENV{HOME}/Applications" /Applications + set(install_search_paths "$ENV{HOME}/Applications" + "$ENV{HOME}/Library/Arduino15" /Applications /Developer/Applications /sw /opt/local) set(install_path_suffixes Arduino.app/Contents/Java Arduino.app/Contents/Resources/Java) @@ -57,6 +58,8 @@ function(InitializeArduinoPackagePathList) DIRECTORY) list(APPEND install_search_paths "${_install_path}") endif() + elseif(EXISTS "$ENV{HOME}/.arduino15/inventory.yaml") + list(APPEND install_search_paths "$ENV{HOME}/.arduino15") endif() endif() @@ -76,17 +79,21 @@ function(InitializeArduinoPackagePathList) set(Prog86Path "ProgramFiles(x86)") set(install_search_paths "$ENV{${Prog86Path}}/Arduino" - "$ENV{ProgramFiles}/Arduino") + "$ENV{ProgramFiles}/Arduino" + "$ENV{LOCALAPPDATA}/Arduino15") set(install_path_suffixes "") file(GLOB package_search_paths "$ENV{LOCALAPPDATA}/Arduino15") set(package_path_suffixes "") - set(_reg_software "HKEY_LOCAL_MACHINE\\SOFTWARE") + set(_reg_software "HKEY_CURRENT_USER\\SOFTWARE") set(_reg_win "${_reg_software}\\Microsoft\\Windows\\CurrentVersion") set(_reg_explorer "${_reg_win}\\Explorer") + get_filename_component(_reg_documents + "[${_reg_explorer}\\User Shell Folders;Personal]" ABSOLUTE) + file(GLOB sketchbook_search_paths "$ENV{LOCALAPPDATA}/Arduino15" - "[${_reg_explorer}\\User Shell Folders;Personal]/ArduinoData") + "${_reg_documents}/ArduinoData") set(sketchbook_path_suffixes "") else() @@ -97,7 +104,7 @@ function(InitializeArduinoPackagePathList) # Search for Arduino install path find_path(ARDUINO_INSTALL_PATH - NAMES lib/version.txt + NAMES lib/version.txt inventory.yaml PATH_SUFFIXES ${install_path_suffixes} HINTS ${install_search_paths} NO_DEFAULT_PATH @@ -110,13 +117,18 @@ function(InitializeArduinoPackagePathList) "Use -DARDUINO_INSTALL_PATH= to manually specify the path (OR)\n" "Use -DARDUINO_BOARD_MANAGER_URL= to try downloading\n") elseif(ARDUINO_INSTALL_PATH AND NOT "${ARDUINO_ENABLE_PACKAGE_MANAGER}" - AND "${ARDUINO_BOARD_MANAGER_URL}" STREQUAL "") - message("${ARDUINO_INSTALL_PATH}") - file(READ "${ARDUINO_INSTALL_PATH}/lib/version.txt" _version) - string(REGEX MATCH "[0-9]+\\.[0-9]" _ard_version "${_version}") - if (_version AND "${_ard_version}" VERSION_LESS "1.5") - message(WARNING "${ARDUINO_INSTALL_PATH} may be unsupported version " - "${_version}. Please install newer version!") + AND "${ARDUINO_BOARD_MANAGER_URL}" STREQUAL "") + if (EXISTS "${ARDUINO_INSTALL_PATH}/lib/version.txt") + message("${ARDUINO_INSTALL_PATH}") + file(READ "${ARDUINO_INSTALL_PATH}/lib/version.txt" _version) + string(REGEX MATCH "[0-9]+\\.[0-9]" _ard_version "${_version}") + message("${_ard_version}") + if (_version AND "${_ard_version}" VERSION_LESS "1.5") + message(WARNING "${ARDUINO_INSTALL_PATH} may be unsupported version " + "${_version}. Please install newer version!") + endif() + elseif(EXISTS "${ARDUINO_INSTALL_PATH}/inventory.yaml") + message("arduino-cli found at ${ARDUINO_INSTALL_PATH}") endif() endif() @@ -150,6 +162,18 @@ function(InitializeArduinoPackagePathList) endif() # message("ARDUINO_SKETCHBOOK_PATH:${ARDUINO_SKETCHBOOK_PATH}") + # support arduino-cli package downloads on Windows. Sketchbook path will be + # not found if IDE is not installed, so use the Documents/Arduino as + # additional library lookup paths. This is the expected location when running + # arduino-cli lib install . + if (NOT ARDUINO_SKETCHBOOK_PATH AND _reg_documents) + file(GLOB _reg_doc_lib "${_reg_documents}/Arduino") + if (_reg_doc_lib) + set(ARDUINO_SKETCHBOOK_PATH "${_reg_doc_lib}" + CACHE PATH "Path to Arduino Libraries") + endif() + endif() + # Arduino local package management path if (NOT ARDUINO_PACKAGE_MANAGER_PATH) set(ARDUINO_PACKAGE_MANAGER_PATH