summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-04-06 16:04:35 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-04-06 16:04:43 (GMT)
commitc508935dad210a19b3a2eb4b78f1dddac5efe6dc (patch)
tree3a48868554b22d40dbc823ae6cc32e068e78b874 /Modules
parent2b4081660c1cc1c43de7b48a948ee4b01cad8f12 (diff)
parent87142bbd5f94de9591b0a5531e427a5f491f56fd (diff)
downloadCMake-c508935dad210a19b3a2eb4b78f1dddac5efe6dc.zip
CMake-c508935dad210a19b3a2eb4b78f1dddac5efe6dc.tar.gz
CMake-c508935dad210a19b3a2eb4b78f1dddac5efe6dc.tar.bz2
Merge topic 'adsp-platform-and-compilers'
87142bbd5f ADSP: Add dedicated platform module e9eabb0dcd ADSP: Configure compiler in compiler module 88b38f531a ADSP: Support both VDSP++ and CCES for ADSP compilers Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7123
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake11
-rw-r--r--Modules/CMakePlatformId.h.in9
-rw-r--r--Modules/Compiler/ADSP-C.cmake11
-rw-r--r--Modules/Compiler/ADSP-CXX.cmake16
-rw-r--r--Modules/Compiler/ADSP-DetermineCompiler.cmake13
-rw-r--r--Modules/Compiler/ADSP.cmake26
-rw-r--r--Modules/Platform/ADSP-C.cmake2
-rw-r--r--Modules/Platform/ADSP-CXX.cmake2
-rw-r--r--Modules/Platform/ADSP-Common.cmake36
-rw-r--r--Modules/Platform/ADSP-Determine.cmake26
-rw-r--r--Modules/Platform/ADSP.cmake4
11 files changed, 149 insertions, 7 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 0317f34..a90fa5d 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -841,15 +841,24 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(ARCHITECTURE_ID)
set(SIMULATE_ID)
set(SIMULATE_VERSION)
+ set(CMAKE_${lang}_COMPILER_ID_STRING_REGEX ".?I.?N.?F.?O.?:.?[A-Za-z0-9_]+\\[[^]]*\\]")
foreach(encoding "" "ENCODING;UTF-16LE" "ENCODING;UTF-16BE")
file(STRINGS "${file}" CMAKE_${lang}_COMPILER_ID_STRINGS
LIMIT_COUNT 38 ${encoding}
- REGEX ".?I.?N.?F.?O.?:.?[A-Za-z0-9_]+\\[[^]]*\\]")
+ REGEX "${CMAKE_${lang}_COMPILER_ID_STRING_REGEX}")
if(NOT CMAKE_${lang}_COMPILER_ID_STRINGS STREQUAL "")
break()
endif()
endforeach()
+ # Some ADSP processors result in characters being detected as separate strings
+ if(CMAKE_${lang}_COMPILER_ID_STRINGS STREQUAL "")
+ file(STRINGS "${file}" CMAKE_${lang}_COMPILER_ID_STRINGS LENGTH_MAXIMUM 1)
+ string(REGEX REPLACE ";" "" CMAKE_${lang}_COMPILER_ID_STRING "${CMAKE_${lang}_COMPILER_ID_STRINGS}")
+ string(REGEX MATCHALL "${CMAKE_${lang}_COMPILER_ID_STRING_REGEX}"
+ CMAKE_${lang}_COMPILER_ID_STRINGS "${CMAKE_${lang}_COMPILER_ID_STRING}")
+ endif()
+
# With the IAR Compiler, some strings are found twice, first time as incomplete
# list like "?<Constant "INFO:compiler[IAR]">". Remove the incomplete copies.
list(FILTER CMAKE_${lang}_COMPILER_ID_STRINGS EXCLUDE REGEX "\\?<Constant \\\"")
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index 59195f8..06f5ecd 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -105,6 +105,9 @@
# define PLATFORM_ID "Integrity"
# endif
+# elif defined(_ADI_COMPILER)
+# define PLATFORM_ID "ADSP"
+
#else /* unknown platform */
# define PLATFORM_ID
@@ -233,6 +236,12 @@
# define ARCHITECTURE_ID ""
# endif
+# elif defined(__ADSPSHARC__)
+# define ARCHITECTURE_ID "SHARC"
+
+# elif defined(__ADSPBLACKFIN__)
+# define ARCHITECTURE_ID "Blackfin"
+
#else
# define ARCHITECTURE_ID
#endif
diff --git a/Modules/Compiler/ADSP-C.cmake b/Modules/Compiler/ADSP-C.cmake
new file mode 100644
index 0000000..cef3fb1
--- /dev/null
+++ b/Modules/Compiler/ADSP-C.cmake
@@ -0,0 +1,11 @@
+include(Compiler/CMakeCommonCompilerMacros)
+include(Compiler/ADSP)
+
+__compiler_adsp(C)
+
+set(CMAKE_C90_STANDARD_COMPILE_OPTION -c89)
+set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
+
+set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
+
+__compiler_check_default_language_standard(C 8.0.0.0 99)
diff --git a/Modules/Compiler/ADSP-CXX.cmake b/Modules/Compiler/ADSP-CXX.cmake
new file mode 100644
index 0000000..b01cab1
--- /dev/null
+++ b/Modules/Compiler/ADSP-CXX.cmake
@@ -0,0 +1,16 @@
+include(Compiler/CMakeCommonCompilerMacros)
+include(Compiler/ADSP)
+
+__compiler_adsp(CXX)
+
+set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -c++)
+set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -g++)
+set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
+
+if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.3.0.0)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -c++11)
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -c++11 -g++)
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
+
+__compiler_check_default_language_standard(CXX 8.0.0.0 98)
diff --git a/Modules/Compiler/ADSP-DetermineCompiler.cmake b/Modules/Compiler/ADSP-DetermineCompiler.cmake
index 0340f69..96c88f9 100644
--- a/Modules/Compiler/ADSP-DetermineCompiler.cmake
+++ b/Modules/Compiler/ADSP-DetermineCompiler.cmake
@@ -1,10 +1,11 @@
-set(_compiler_id_pp_test "defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)")
+set(_compiler_id_pp_test "defined(_ADI_COMPILER)")
set(_compiler_id_version_compute "
-#if defined(__VISUALDSPVERSION__)
- /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
-# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__VISUALDSPVERSION__>>24)
-# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__VISUALDSPVERSION__>>16 & 0xFF)
-# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__VISUALDSPVERSION__>>8 & 0xFF)
+#if defined(__VERSIONNUM__)
+ /* __VERSIONNUM__ = 0xVVRRPPTT */
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__VERSIONNUM__ >> 24 & 0xFF)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__VERSIONNUM__ >> 16 & 0xFF)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__VERSIONNUM__ >> 8 & 0xFF)
+# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__VERSIONNUM__ & 0xFF)
#endif")
diff --git a/Modules/Compiler/ADSP.cmake b/Modules/Compiler/ADSP.cmake
new file mode 100644
index 0000000..62566a0
--- /dev/null
+++ b/Modules/Compiler/ADSP.cmake
@@ -0,0 +1,26 @@
+include_guard()
+
+set(CMAKE_EXECUTABLE_SUFFIX ".dxe")
+
+macro(__compiler_adsp lang)
+ set(CMAKE_${lang}_OUTPUT_EXTENSION ".doj")
+
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-flags-link" " ")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
+
+ 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>")
+
+ set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
+ "<CMAKE_${lang}_COMPILER> ${_CMAKE_${lang}_ADSP_FLAGS} -build-lib -o <TARGET> <CMAKE_${lang}_LINK_FLAGS> <OBJECTS>")
+
+ set(CMAKE_${lang}_LINK_EXECUTABLE
+ "<CMAKE_${lang}_COMPILER> ${_CMAKE_${lang}_ADSP_FLAGS} <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+
+ unset(_CMAKE_${lang}_ADSP_FLAGS)
+
+ set(CMAKE_${lang}_CREATE_SHARED_LIBRARY)
+ set(CMAKE_${lang}_CREATE_MODULE_LIBRARY)
+endmacro()
diff --git a/Modules/Platform/ADSP-C.cmake b/Modules/Platform/ADSP-C.cmake
new file mode 100644
index 0000000..c85e746
--- /dev/null
+++ b/Modules/Platform/ADSP-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/ADSP-Common)
+__platform_adsp(C)
diff --git a/Modules/Platform/ADSP-CXX.cmake b/Modules/Platform/ADSP-CXX.cmake
new file mode 100644
index 0000000..d827c80
--- /dev/null
+++ b/Modules/Platform/ADSP-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/ADSP-Common)
+__platform_adsp(CXX)
diff --git a/Modules/Platform/ADSP-Common.cmake b/Modules/Platform/ADSP-Common.cmake
new file mode 100644
index 0000000..2ba90b2
--- /dev/null
+++ b/Modules/Platform/ADSP-Common.cmake
@@ -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()
diff --git a/Modules/Platform/ADSP-Determine.cmake b/Modules/Platform/ADSP-Determine.cmake
new file mode 100644
index 0000000..6ccf1ea
--- /dev/null
+++ b/Modules/Platform/ADSP-Determine.cmake
@@ -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()
diff --git a/Modules/Platform/ADSP.cmake b/Modules/Platform/ADSP.cmake
new file mode 100644
index 0000000..15e9dd2
--- /dev/null
+++ b/Modules/Platform/ADSP.cmake
@@ -0,0 +1,4 @@
+include(Platform/ADSP-Common)
+__platform_adsp_init()
+
+set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)