summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/TIClang
diff options
context:
space:
mode:
authorAlan Phipps <a-phipps@ti.com>2023-12-06 18:53:02 (GMT)
committerBrad King <brad.king@kitware.com>2024-02-09 20:54:40 (GMT)
commit9ba0a54554c15fe28ea0612c6e166ad114c87cda (patch)
treede9acfaf9bc733eace186169e7b97936ff24f2a0 /Tests/RunCMake/TIClang
parentc673511263822c688fa302120a29e1e0cf812c0b (diff)
downloadCMake-9ba0a54554c15fe28ea0612c6e166ad114c87cda.zip
CMake-9ba0a54554c15fe28ea0612c6e166ad114c87cda.tar.gz
CMake-9ba0a54554c15fe28ea0612c6e166ad114c87cda.tar.bz2
TIClang: Add support for TI Clang-based compilers, including tiarmclang
Add TIClang compiler ID and support in compiler modules. Update documentation. Add rudimentary RunCMake test for TIClang to test basic functionality. Fixes: #24619
Diffstat (limited to 'Tests/RunCMake/TIClang')
-rw-r--r--Tests/RunCMake/TIClang/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/TIClang/RunCMakeTest.cmake61
-rw-r--r--Tests/RunCMake/TIClang/libmod.c4
-rw-r--r--Tests/RunCMake/TIClang/module.c14
-rw-r--r--Tests/RunCMake/TIClang/module.cxx7
-rw-r--r--Tests/RunCMake/TIClang/module.h12
-rw-r--r--Tests/RunCMake/TIClang/module.s9
-rw-r--r--Tests/RunCMake/TIClang/ticlang-asm.cmake5
-rw-r--r--Tests/RunCMake/TIClang/ticlang-c.cmake5
-rw-r--r--Tests/RunCMake/TIClang/ticlang-cxx.cmake5
-rw-r--r--Tests/RunCMake/TIClang/ticlang-lib.cmake10
11 files changed, 135 insertions, 0 deletions
diff --git a/Tests/RunCMake/TIClang/CMakeLists.txt b/Tests/RunCMake/TIClang/CMakeLists.txt
new file mode 100644
index 0000000..94e43ba
--- /dev/null
+++ b/Tests/RunCMake/TIClang/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.29)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/TIClang/RunCMakeTest.cmake b/Tests/RunCMake/TIClang/RunCMakeTest.cmake
new file mode 100644
index 0000000..898de74
--- /dev/null
+++ b/Tests/RunCMake/TIClang/RunCMakeTest.cmake
@@ -0,0 +1,61 @@
+include(RunCMake)
+
+# Test expects to be given a LIST of toolchain directories where a TIClang
+# compiler binary is expected to be found relative to the "bin" directory:
+# "-DCMake_TEST_TICLANG_TOOLCHAINS=<path1>;<path2>;<path3>"
+if(RunCMake_GENERATOR MATCHES "Makefile|Ninja")
+ set(_ticlang_toolchains "${CMake_TEST_TICLANG_TOOLCHAINS}" )
+endif()
+
+function(run_toolchain case)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
+ run_cmake_with_options(${case} ${ARGN})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+foreach(_ticlang_toolchain_path IN LISTS _ticlang_toolchains)
+ file(GLOB _ticlang_toolchain "${_ticlang_toolchain_path}/bin/*clang" )
+ if(_ticlang_toolchain STREQUAL "")
+ message(WARNING
+ "Could not find a TIClang toolchain at: ${_ticlang_toolchain_path}.")
+ continue()
+ endif()
+
+ message(STATUS "Found TIClang toolchain: ${_ticlang_toolchain}")
+
+ if(_ticlang_toolchain MATCHES "tiarmclang")
+ set(LINK_OPTS "--use_memcpy=fast,--use_memset=fast,-llnk.cmd")
+ set(CMAKE_FLAGS "-mcpu=cortex-r5 -Oz")
+ else()
+ set(CMAKE_FLAGS "")
+ set(LINK_OPTS "")
+ endif()
+
+ run_toolchain(ticlang-c
+ -DCMAKE_SYSTEM_NAME=Generic
+ -DCMAKE_C_COMPILER=${_ticlang_toolchain}
+ -DCMAKE_C_FLAGS=${CMAKE_FLAGS}
+ -DCMAKE_C_LINKER_FLAGS=${LINK_OPTS}
+ )
+
+ run_toolchain(ticlang-cxx
+ -DCMAKE_SYSTEM_NAME=Generic
+ -DCMAKE_CXX_COMPILER=${_ticlang_toolchain}
+ -DCMAKE_CXX_FLAGS=${CMAKE_FLAGS}
+ -DCMAKE_CXX_LINKER_FLAGS=${LINK_OPTS}
+ )
+
+ run_toolchain(ticlang-asm
+ -DCMAKE_SYSTEM_NAME=Generic
+ -DCMAKE_ASM_COMPILER=${_ticlang_toolchain}
+ -DCMAKE_ASM_FLAGS=${CMAKE_FLAGS}
+ )
+
+ run_toolchain(ticlang-lib
+ -DCMAKE_SYSTEM_NAME=Generic
+ -DCMAKE_C_COMPILER=${_ticlang_toolchain}
+ -DCMAKE_C_FLAGS=${CMAKE_FLAGS}
+ -DCMAKE_C_LINKER_FLAGS=${LINK_OPTS}
+ )
+endforeach()
diff --git a/Tests/RunCMake/TIClang/libmod.c b/Tests/RunCMake/TIClang/libmod.c
new file mode 100644
index 0000000..50666c9
--- /dev/null
+++ b/Tests/RunCMake/TIClang/libmod.c
@@ -0,0 +1,4 @@
+int ticlang_libfun()
+{
+ return 42;
+}
diff --git a/Tests/RunCMake/TIClang/module.c b/Tests/RunCMake/TIClang/module.c
new file mode 100644
index 0000000..46d7571
--- /dev/null
+++ b/Tests/RunCMake/TIClang/module.c
@@ -0,0 +1,14 @@
+#include "module.h"
+#if defined(__USE_LIBFUN)
+extern int ticlang_libfun();
+#endif
+int i;
+int main()
+{
+#if defined(__USE_LIBFUN)
+ i = ticlang_libfun();
+#else
+ i = INTERNAL;
+#endif
+ return i;
+}
diff --git a/Tests/RunCMake/TIClang/module.cxx b/Tests/RunCMake/TIClang/module.cxx
new file mode 100644
index 0000000..b4d46b1
--- /dev/null
+++ b/Tests/RunCMake/TIClang/module.cxx
@@ -0,0 +1,7 @@
+#include "module.h"
+int i;
+int main()
+{
+ i = INTERNAL;
+ return i;
+}
diff --git a/Tests/RunCMake/TIClang/module.h b/Tests/RunCMake/TIClang/module.h
new file mode 100644
index 0000000..a8a85a6
--- /dev/null
+++ b/Tests/RunCMake/TIClang/module.h
@@ -0,0 +1,12 @@
+#ifndef __MODULE_H__
+#define __MODULE_H__
+
+#if defined(__cplusplus)
+# define INTERNAL 64
+#elif !defined(__cplusplus)
+# define INTERNAL 32
+#else
+# error "Unable to determine INTERNAL symbol."
+#endif
+
+#endif /* __MODULE_H__ */
diff --git a/Tests/RunCMake/TIClang/module.s b/Tests/RunCMake/TIClang/module.s
new file mode 100644
index 0000000..df16350
--- /dev/null
+++ b/Tests/RunCMake/TIClang/module.s
@@ -0,0 +1,9 @@
+ .text
+ .syntax unified
+ .section .text.main,"ax",%progbits
+ .hidden main
+ .globl main
+ .p2align 4
+main:
+ nop
+ bx lr
diff --git a/Tests/RunCMake/TIClang/ticlang-asm.cmake b/Tests/RunCMake/TIClang/ticlang-asm.cmake
new file mode 100644
index 0000000..f6c27fc
--- /dev/null
+++ b/Tests/RunCMake/TIClang/ticlang-asm.cmake
@@ -0,0 +1,5 @@
+enable_language(ASM)
+
+add_executable(exec-asm)
+target_sources(exec-asm PRIVATE module.s)
+target_link_options(exec-asm PRIVATE ${LINKER_OPTS})
diff --git a/Tests/RunCMake/TIClang/ticlang-c.cmake b/Tests/RunCMake/TIClang/ticlang-c.cmake
new file mode 100644
index 0000000..a36f096
--- /dev/null
+++ b/Tests/RunCMake/TIClang/ticlang-c.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+add_executable(exec-c)
+target_sources(exec-c PRIVATE module.c)
+target_link_options(exec-c PRIVATE ${LINKER_OPTS})
diff --git a/Tests/RunCMake/TIClang/ticlang-cxx.cmake b/Tests/RunCMake/TIClang/ticlang-cxx.cmake
new file mode 100644
index 0000000..6b005b5
--- /dev/null
+++ b/Tests/RunCMake/TIClang/ticlang-cxx.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+
+add_executable(exec-cxx)
+target_sources(exec-cxx PRIVATE module.cxx)
+target_link_options(exec-cxx PRIVATE ${LINKER_OPTS})
diff --git a/Tests/RunCMake/TIClang/ticlang-lib.cmake b/Tests/RunCMake/TIClang/ticlang-lib.cmake
new file mode 100644
index 0000000..e47647c
--- /dev/null
+++ b/Tests/RunCMake/TIClang/ticlang-lib.cmake
@@ -0,0 +1,10 @@
+enable_language(C)
+
+add_library(ticlang-test-lib)
+target_sources(ticlang-test-lib PRIVATE libmod.c)
+
+add_executable(exec-lib-c)
+target_sources(exec-lib-c PRIVATE module.c)
+target_compile_definitions(exec-lib-c PRIVATE __USE_LIBFUN)
+target_link_libraries(exec-lib-c LINK_PUBLIC ticlang-test-lib)
+target_link_options(exec-lib-c PRIVATE ${LINKER_OPTS})