diff options
author | Brad King <brad.king@kitware.com> | 2024-02-12 15:57:09 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-02-12 15:57:18 (GMT) |
commit | 4977739fc978a0480fc1cde3f03a88a083e955a5 (patch) | |
tree | 7dc1726c205cfc722f308f7751eed4ed9a863fa5 /Tests | |
parent | f3acc9b1ceb151c1b85574b5ea2fcf8c6d810225 (diff) | |
parent | 4c51136b8c345adffc4052eb5bd70978d8bc903e (diff) | |
download | CMake-4977739fc978a0480fc1cde3f03a88a083e955a5.zip CMake-4977739fc978a0480fc1cde3f03a88a083e955a5.tar.gz CMake-4977739fc978a0480fc1cde3f03a88a083e955a5.tar.bz2 |
Merge topic 'ticlang-compilers' into release-3.29
4c51136b8c ci: Enable TIClang test on Debian Clang jobs in nightly pipeline
9ba0a54554 TIClang: Add support for TI Clang-based compilers, including tiarmclang
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9228
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/RunCMakeTest.cmake | 61 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/libmod.c | 4 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/module.c | 14 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/module.cxx | 7 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/module.h | 12 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/module.s | 9 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/ticlang-asm.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/ticlang-c.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/ticlang-cxx.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/TIClang/ticlang-lib.cmake | 10 |
12 files changed, 141 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 3e22247..d9090d6 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -1177,3 +1177,9 @@ if(CMake_TEST_IAR_TOOLCHAINS) add_RunCMake_test(IAR -DCMake_TEST_IAR_TOOLCHAINS=${CMake_TEST_IAR_TOOLCHAINS}) set_property(TEST RunCMake.IAR APPEND PROPERTY LABELS "IAR") endif() +if(CMake_TEST_TICLANG_TOOLCHAINS) + # This is necessary to preserve the LIST variable contents given by user. + string(REPLACE ";" "$<SEMICOLON>" TOOLCHAINS "${CMake_TEST_TICLANG_TOOLCHAINS}") + add_RunCMake_test(TIClang "-DCMake_TEST_TICLANG_TOOLCHAINS=${TOOLCHAINS}") + set_property(TEST RunCMake.TIClang APPEND PROPERTY LABELS "TIClang") +endif() 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}) |