From a70df0d6f08aaf87b9a1337eed5fba06ca5701d5 Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Thu, 30 Jul 2020 00:47:32 +0200 Subject: Compiler/TI: Avoid generic variable name in macro In commit a548a52230 (Compiler/TI: Refactor C/CXX to use a common file, 2020-07-11) a variable named `prefix` has been introduced. It is set in the callers namespace because it was defined inside a macro, not a function. Avoid such generic variable name. --- Modules/Compiler/TI.cmake | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Modules/Compiler/TI.cmake b/Modules/Compiler/TI.cmake index 9f2e813..d59fd49 100644 --- a/Modules/Compiler/TI.cmake +++ b/Modules/Compiler/TI.cmake @@ -8,21 +8,20 @@ if(__COMPILER_TI) endif() set(__COMPILER_TI 1) -macro(__compiler_ti lang) - string(TOLOWER ${lang} prefix) - if("x${lang}" STREQUAL "xCXX") - set(prefix "cpp") - endif() +set(__COMPILER_TI_SOURCE_FLAG_C "--c_file") +set(__COMPILER_TI_SOURCE_FLAG_CXX "--cpp_file") +set(__COMPILER_TI_SOURCE_FLAG_ASM "--asm_file") +macro(__compiler_ti lang) set(CMAKE_${lang}_RESPONSE_FILE_FLAG "--cmd_file=") set(CMAKE_INCLUDE_FLAG_${lang} "--include_path=") set(CMAKE_DEPFILE_FLAGS_${lang} "--preproc_with_compile --preproc_dependency=") - set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " --preproc_only --${prefix}_file= --output_file=") - set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " --compile_only --skip_assembler --${prefix}_file= --output_file=") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " --preproc_only ${__COMPILER_TI_SOURCE_FLAG_${lang}}= --output_file=") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " --compile_only --skip_assembler ${__COMPILER_TI_SOURCE_FLAG_${lang}}= --output_file=") - set(CMAKE_${lang}_COMPILE_OBJECT " --compile_only --${prefix}_file= --output_file=") + set(CMAKE_${lang}_COMPILE_OBJECT " --compile_only ${__COMPILER_TI_SOURCE_FLAG_${lang}}= --output_file=") set(CMAKE_${lang}_ARCHIVE_CREATE " qr ") set(CMAKE_${lang}_ARCHIVE_APPEND " qa ") -- cgit v0.12 From 0b4582f229db9fc2b6932c518ab816edd7709406 Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Tue, 1 Sep 2020 01:17:18 +0200 Subject: Compiler/TI: Fix definition of std options - The compile option variable has to be defined as list. - The compiler works in relaxed ANSI mode by default. Strict ANSI has to be explicitly set additionally to the language standard. --- Modules/Compiler/TI-C.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake index 8ea01b5..ec5a509 100644 --- a/Modules/Compiler/TI-C.cmake +++ b/Modules/Compiler/TI-C.cmake @@ -1,8 +1,8 @@ include(Compiler/TI) __compiler_ti(C) -set(CMAKE_C90_STANDARD_COMPILE_OPTION "--c89") -set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--c89 --relaxed_ansi") +set(CMAKE_C90_STANDARD_COMPILE_OPTION "--c89" "--strict_ansi") +set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--c89" "--relaxed_ansi") -set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99") -set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99 --relaxed_ansi") +set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99" "--strict_ansi") +set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99" "--relaxed_ansi") -- cgit v0.12 From 8300030f715a872adf2de9ebb1605a37423de5c5 Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Mon, 21 Sep 2020 00:42:14 +0200 Subject: Compiler/TI: Check compiler version for C99 support --- Modules/Compiler/TI-C.cmake | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake index ec5a509..69cf0a2 100644 --- a/Modules/Compiler/TI-C.cmake +++ b/Modules/Compiler/TI-C.cmake @@ -1,8 +1,39 @@ include(Compiler/TI) __compiler_ti(C) -set(CMAKE_C90_STANDARD_COMPILE_OPTION "--c89" "--strict_ansi") -set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--c89" "--relaxed_ansi") +# Architecture specific +# C99 versions: https://processors.wiki.ti.com/index.php/C99_Support_in_TI_Compilers -set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99" "--strict_ansi") -set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99" "--relaxed_ansi") +if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") + set(__COMPILER_TI_C99_VERSION_ARM 5.2) + +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") + set(__COMPILER_TI_C99_VERSION_MSP430 4.3) + +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C28x") + set(__COMPILER_TI_C99_VERSION_TMS320C28x 6.3) + +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C6x") + set(__COMPILER_TI_C99_VERSION_TMS320C6x 7.5) + +else() + # architecture not handled + return() + +endif() + + +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C99_VERSION_${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}}") + + set(CMAKE_C90_STANDARD_COMPILE_OPTION "--c89" "--strict_ansi") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--c89" "--relaxed_ansi") + + set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99" "--strict_ansi") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99" "--relaxed_ansi") + +else() + + set(CMAKE_C90_STANDARD_COMPILE_OPTION "--strict_ansi") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--relaxed_ansi") + +endif() -- cgit v0.12 From 2e69993101a0ee12cc5ce8419934ae40f0490749 Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Mon, 21 Sep 2020 00:42:48 +0200 Subject: Compiler/TI: Check default C standard --- Modules/Compiler/TI-C.cmake | 17 +++++++++++++++++ Modules/Compiler/TI.cmake | 2 ++ 2 files changed, 19 insertions(+) diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake index 69cf0a2..3941577 100644 --- a/Modules/Compiler/TI-C.cmake +++ b/Modules/Compiler/TI-C.cmake @@ -37,3 +37,20 @@ else() set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--relaxed_ansi") endif() + + +# Architecture specific + +if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") + __compiler_check_default_language_standard(C 2.0 90) + +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") + __compiler_check_default_language_standard(C 3.0 90) + +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C28x") + __compiler_check_default_language_standard(C 4.1 90) + +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C6x") + __compiler_check_default_language_standard(C 4.45 90) + +endif() diff --git a/Modules/Compiler/TI.cmake b/Modules/Compiler/TI.cmake index d59fd49..f631688 100644 --- a/Modules/Compiler/TI.cmake +++ b/Modules/Compiler/TI.cmake @@ -8,6 +8,8 @@ if(__COMPILER_TI) endif() set(__COMPILER_TI 1) +include(Compiler/CMakeCommonCompilerMacros) + set(__COMPILER_TI_SOURCE_FLAG_C "--c_file") set(__COMPILER_TI_SOURCE_FLAG_CXX "--cpp_file") set(__COMPILER_TI_SOURCE_FLAG_ASM "--asm_file") -- cgit v0.12 From 55fc045aa838ac2f2975df1208a3c7166c37305c Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Tue, 1 Sep 2020 01:45:09 +0200 Subject: Compiler/TI: Add std options for C11 --- Modules/Compiler/TI-C.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake index 3941577..3c97afb 100644 --- a/Modules/Compiler/TI-C.cmake +++ b/Modules/Compiler/TI-C.cmake @@ -6,12 +6,15 @@ __compiler_ti(C) if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") set(__COMPILER_TI_C99_VERSION_ARM 5.2) + set(__COMPILER_TI_C11_VERSION_ARM 18.12) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") set(__COMPILER_TI_C99_VERSION_MSP430 4.3) + set(__COMPILER_TI_C11_VERSION_MSP430 18.12) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C28x") set(__COMPILER_TI_C99_VERSION_TMS320C28x 6.3) + set(__COMPILER_TI_C11_VERSION_TMS320C28x 18.9) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C6x") set(__COMPILER_TI_C99_VERSION_TMS320C6x 7.5) @@ -31,6 +34,14 @@ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C99_VERSION_$ set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99" "--strict_ansi") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99" "--relaxed_ansi") + if(DEFINED __COMPILER_TI_C11_VERSION_${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C11_VERSION_${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}}") + + set(CMAKE_C11_STANDARD_COMPILE_OPTION "--c11" "--strict_ansi") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "--c11" "--relaxed_ansi") + + endif() + else() set(CMAKE_C90_STANDARD_COMPILE_OPTION "--strict_ansi") -- cgit v0.12 From fe9cddf181dbdc012127de04f5905d62c0d407bb Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Tue, 1 Sep 2020 01:52:45 +0200 Subject: Compiler/TI: Add std options for C++98 The TI compiler does not support C++98, only C++03 (based on manual of current version). This change sets the C++98 option to C++03 based on the fact that it is done this way for the SunPro compiler already. --- Help/manual/cmake-compile-features.7.rst | 2 +- Modules/Compiler/TI-CXX.cmake | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index 05dc038..690d293 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -358,6 +358,7 @@ versions specified for each: * ``Cray``: Cray Compiler Environment version 8.1+. * ``PGI``: PGI version 12.10+. +* ``TI``: Texas Instruments compiler. * ``XL``: IBM XL version 10.1+. CMake is currently aware of the :prop_tgt:`C standards ` and @@ -366,7 +367,6 @@ following :variable:`compiler ids _COMPILER_ID>` as of the versions specified for each: * all compilers and versions listed above with only meta-features for C++. -* ``TI``: Texas Instruments compiler. CMake is currently aware of the :prop_tgt:`CUDA standards ` and their associated meta-features (e.g. ``cuda_std_11``) available from the diff --git a/Modules/Compiler/TI-CXX.cmake b/Modules/Compiler/TI-CXX.cmake index c08d9a1..39e37f6 100644 --- a/Modules/Compiler/TI-CXX.cmake +++ b/Modules/Compiler/TI-CXX.cmake @@ -1,2 +1,53 @@ include(Compiler/TI) __compiler_ti(CXX) + +# Architecture specific + +if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") + set(__COMPILER_TI_CXX03_VERSION 5.2) + +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") + set(__COMPILER_TI_CXX03_VERSION 4.4) + +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C28x") + set(__COMPILER_TI_CXX03_VERSION 16.9) + +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C6x") + set(__COMPILER_TI_CXX03_VERSION 8.1) + +else() + # architecture not handled + return() + +endif() + + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_CXX03_VERSION}") + + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "--c++03" "--strict_ansi") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "--c++03" "--relaxed_ansi") + +else() + + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "--strict_ansi") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "--relaxed_ansi") + +endif() + + +# Architecture specific +# CXX98 versions: https://processors.wiki.ti.com/index.php/C%2B%2B_Support_in_TI_Compilers + +if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") + __compiler_check_default_language_standard(CXX 4.5 98) + +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") + __compiler_check_default_language_standard(CXX 3.0 98) + +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C28x") + __compiler_check_default_language_standard(CXX 5.1 98) + +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C6x") + __compiler_check_default_language_standard(CXX 6.1 98) + +endif() -- cgit v0.12 From 6a66bb13ed80398d908bc07a89589dae74069ef2 Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Tue, 1 Sep 2020 01:58:43 +0200 Subject: Compiler/TI: Add std options for C++14 The TI compiler does either support C++98 or C++14, but not both at the same time. --- Modules/Compiler/TI-CXX.cmake | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Modules/Compiler/TI-CXX.cmake b/Modules/Compiler/TI-CXX.cmake index 39e37f6..4b6efcd 100644 --- a/Modules/Compiler/TI-CXX.cmake +++ b/Modules/Compiler/TI-CXX.cmake @@ -5,15 +5,18 @@ __compiler_ti(CXX) if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") set(__COMPILER_TI_CXX03_VERSION 5.2) + set(__COMPILER_TI_CXX14_VERSION 18.1) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") set(__COMPILER_TI_CXX03_VERSION 4.4) + set(__COMPILER_TI_CXX14_VERSION 18.1) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C28x") set(__COMPILER_TI_CXX03_VERSION 16.9) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C6x") set(__COMPILER_TI_CXX03_VERSION 8.1) + set(__COMPILER_TI_CXX14_VERSION 8.3) else() # architecture not handled @@ -22,7 +25,22 @@ else() endif() -if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_CXX03_VERSION}") +if(DEFINED __COMPILER_TI_CXX14_VERSION AND + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_CXX14_VERSION}") + + # C++03 is not supported anymore + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "--strict_ansi") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "--relaxed_ansi") + + # C++11 was never supported + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "--strict_ansi") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "--relaxed_ansi") + + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "--c++14" "--strict_ansi") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "--c++14" "--relaxed_ansi") + + +elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_CXX03_VERSION}") set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "--c++03" "--strict_ansi") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "--c++03" "--relaxed_ansi") @@ -39,15 +57,15 @@ endif() # CXX98 versions: https://processors.wiki.ti.com/index.php/C%2B%2B_Support_in_TI_Compilers if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - __compiler_check_default_language_standard(CXX 4.5 98) + __compiler_check_default_language_standard(CXX 4.5 98 ${__COMPILER_TI_CXX14_VERSION} 14) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") - __compiler_check_default_language_standard(CXX 3.0 98) + __compiler_check_default_language_standard(CXX 3.0 98 ${__COMPILER_TI_CXX14_VERSION} 14) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C28x") __compiler_check_default_language_standard(CXX 5.1 98) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "TMS320C6x") - __compiler_check_default_language_standard(CXX 6.1 98) + __compiler_check_default_language_standard(CXX 6.1 98 ${__COMPILER_TI_CXX14_VERSION} 14) endif() -- cgit v0.12