ADSP: Add dedicated platform module

This commit is contained in:
Chris Wright
2022-03-24 11:35:40 +00:00
parent e9eabb0dcd
commit 87142bbd5f
12 changed files with 118 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ macro(__compiler_adsp lang)
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-flags-link" " ")
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
set(_CMAKE_${lang}_ADSP_FLAGS "-proc=${CMAKE_SYSTEM_PROCESSOR}")
set(_CMAKE_${lang}_ADSP_FLAGS "-proc=${CMAKE_ADSP_PROCESSOR}")
set(CMAKE_${lang}_COMPILE_OBJECT
"<CMAKE_${lang}_COMPILER> ${_CMAKE_${lang}_ADSP_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")

View File

@@ -0,0 +1,2 @@
include(Platform/ADSP-Common)
__platform_adsp(C)

View File

@@ -0,0 +1,2 @@
include(Platform/ADSP-Common)
__platform_adsp(CXX)

View File

@@ -0,0 +1,36 @@
include_guard()
macro(__platform_adsp_init)
if(NOT CMAKE_ADSP_PLATFORM_INITIALIZED)
if(NOT CMAKE_SYSTEM_PROCESSOR)
message(FATAL_ERROR "ADSP: CMAKE_SYSTEM_PROCESSOR is required but not set")
endif()
set(CMAKE_ADSP_PROCESSOR "ADSP-${CMAKE_SYSTEM_PROCESSOR}")
string(TOUPPER "${CMAKE_ADSP_PROCESSOR}" CMAKE_ADSP_PROCESSOR)
set(CMAKE_ADSP_COMPILER_NAME cc21k.exe)
if(CMAKE_ADSP_PROCESSOR MATCHES "^ADSP-BF")
set(CMAKE_ADSP_COMPILER_NAME ccblkfn.exe)
endif()
set(CMAKE_ADSP_PLATFORM_INITIALIZED TRUE)
endif()
endmacro()
macro(__platform_adsp lang)
__platform_adsp_init()
set(CMAKE_${lang}_COMPILER "${CMAKE_ADSP_ROOT}/${CMAKE_ADSP_COMPILER_NAME}")
execute_process(
COMMAND "${CMAKE_${lang}_COMPILER}" "-proc=${CMAKE_ADSP_PROCESSOR}" "-version"
OUTPUT_QUIET ERROR_QUIET
RESULT_VARIABLE _adsp_is_valid_proc
)
if(NOT _adsp_is_valid_proc EQUAL 0)
message(FATAL_ERROR
"ADSP: unsupported processor '${CMAKE_ADSP_PROCESSOR}' for CMAKE_${lang}_COMPILER:\n"
" ${CMAKE_${lang}_COMPILER}"
)
endif()
endmacro()

View File

@@ -0,0 +1,26 @@
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 IS_DIRECTORY "${CMAKE_ADSP_ROOT}")
message(FATAL_ERROR "ADSP: could not find CCES/VDSP++ install directory ${CMAKE_ADSP_ROOT}")
endif()

View File

@@ -0,0 +1,4 @@
include(Platform/ADSP-Common)
__platform_adsp_init()
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)