CMake/Modules/Platform/ADSP-Determine.cmake
Josh Channings 33e6862cbc
ADSP: Allow progress with CMAKE_ADSP_ROOT unset
This is a behavior change. You can still set ADSP_ROOT/CMAKE_ADSP_ROOT
to hint the find_program() invocations for the CCES binaries, but it is
no longer necessary if they are already in PATH.

The reason is: CMAKE_ADSP_ROOT is only used to find the binaries. If
they are in PATH, there is no need to supply the root path. If they are
not in PATH, you can hint still hint it as before.

The other option would be to use find_path() to get CMAKE_ADSP_ROOT from
the path to one of the bins, but that would be convoluted and pointless.

There are some circumstances where the binaries are available, but the
ADSP install is not. For example, from my own dev environment:

https://github.com/joshchngs/macos-sharc-tools

Here, the `cc21k` et. al. binaries are actually shell scripts which
launch the real binary inside a running VM.
2023-11-30 16:49:03 +00:00

27 lines
901 B
CMake

if(IS_DIRECTORY "$ENV{ADSP_ROOT}")
file(TO_CMAKE_PATH "$ENV{ADSP_ROOT}" CMAKE_ADSP_ROOT)
endif()
macro(_find_adsp_root path_pattern)
set(CMAKE_ADSP_ROOT "")
set(_adsp_root_version "0")
file(GLOB _adsp_root_paths "${path_pattern}")
foreach(_current_adsp_root_path IN LISTS _adsp_root_paths)
string(REGEX MATCH "([0-9\\.]+)/?$" _current_adsp_root_version "${_current_adsp_root_path}")
if(_current_adsp_root_version VERSION_GREATER _adsp_root_version)
set(CMAKE_ADSP_ROOT "${_current_adsp_root_path}")
set(_adsp_root_version "${_current_adsp_root_version}")
endif()
endforeach()
endmacro()
if(NOT CMAKE_ADSP_ROOT)
_find_adsp_root("C:/Analog Devices/CrossCore Embedded Studio *")
endif()
if(NOT CMAKE_ADSP_ROOT)
_find_adsp_root("C:/Program Files (x86)/Analog Devices/VisualDSP *")
endif()
if(NOT CMAKE_ADSP_ROOT)
_find_adsp_root("/opt/analog/cces *")
endif()