diff options
author | Ryan Krattiger <ryan.krattiger@kitware.com> | 2023-09-06 21:57:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-09-22 13:39:52 (GMT) |
commit | 80838316a85f601d19dcc4033c6250227bfcd0e6 (patch) | |
tree | d32c82d8264faea7669a93b288d70225e92c29fb | |
parent | 122ec98dcfa273d17c2ae7ccacbaf3a47d14152c (diff) | |
download | CMake-80838316a85f601d19dcc4033c6250227bfcd0e6.zip CMake-80838316a85f601d19dcc4033c6250227bfcd0e6.tar.gz CMake-80838316a85f601d19dcc4033c6250227bfcd0e6.tar.bz2 |
CrayClang: Add support for this compiler
Add `CrayClang` compiler ID for newer Cray compilers.
Fixes: #25102
-rw-r--r-- | Help/release/dev/CrayClang-compiler.rst | 5 | ||||
-rw-r--r-- | Help/variable/CMAKE_LANG_COMPILER_ID.rst | 1 | ||||
-rw-r--r-- | Modules/CMakeCompilerIdDetection.cmake | 1 | ||||
-rw-r--r-- | Modules/Compiler/CrayClang-C.cmake | 30 | ||||
-rw-r--r-- | Modules/Compiler/CrayClang-CXX.cmake | 35 | ||||
-rw-r--r-- | Modules/Compiler/CrayClang-DetermineCompiler.cmake | 8 | ||||
-rw-r--r-- | Modules/Compiler/CrayClang.cmake | 17 | ||||
-rw-r--r-- | Tests/CMakeCommands/target_compile_options/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/codemodel-v2-check.py | 2 |
10 files changed, 104 insertions, 7 deletions
diff --git a/Help/release/dev/CrayClang-compiler.rst b/Help/release/dev/CrayClang-compiler.rst new file mode 100644 index 0000000..ea26b50 --- /dev/null +++ b/Help/release/dev/CrayClang-compiler.rst @@ -0,0 +1,5 @@ +CrayClang-compiler +------------------ + +* Cray Clang-based compilers are now supported with + :variable:`compiler id <CMAKE_<LANG>_COMPILER_ID>` ``CrayClang``. diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 5eb86c6..c89b3ab 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -18,6 +18,7 @@ Value Name ``CCur`` Concurrent Fortran ``Clang`` `LLVM Clang`_ ``Cray`` Cray Compiler +``CrayClang`` Cray Clang-based Compiler ``Embarcadero``, ``Borland`` `Embarcadero`_ ``Flang`` `Classic Flang Fortran Compiler`_ ``LLVMFlang`` `LLVM Flang Fortran Compiler`_ diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index eef2bd5..3a2b51f 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -65,6 +65,7 @@ function(compiler_id_detection outvar lang) VisualAge NVHPC PGI + CrayClang Cray TI FujitsuClang diff --git a/Modules/Compiler/CrayClang-C.cmake b/Modules/Compiler/CrayClang-C.cmake new file mode 100644 index 0000000..bf878fc --- /dev/null +++ b/Modules/Compiler/CrayClang-C.cmake @@ -0,0 +1,30 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Compiler/CrayClang) +__compiler_cray_clang(C) + +set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) + +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") + +set(CMAKE_C90_STANDARD_COMPILE_OPTION -std=c90) +set(CMAKE_C90_EXTENSION_COMPILE_OPTION -std=gnu90) +set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_C99_STANDARD_COMPILE_OPTION -std=c99) +set(CMAKE_C99_EXTENSION_COMPILE_OPTION -std=gnu99) +set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_C11_STANDARD_COMPILE_OPTION -std=c11) +set(CMAKE_C11_EXTENSION_COMPILE_OPTION -std=gnu11) +set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_C17_STANDARD_COMPILE_OPTION -std=c17) +set(CMAKE_C17_EXTENSION_COMPILE_OPTION -std=gnu17) + +set(CMAKE_C23_STANDARD_COMPILE_OPTION -std=c2x) +set(CMAKE_C23_EXTENSION_COMPILE_OPTION -std=gnu2x) + +__compiler_check_default_language_standard(C 15.0.0 17) diff --git a/Modules/Compiler/CrayClang-CXX.cmake b/Modules/Compiler/CrayClang-CXX.cmake new file mode 100644 index 0000000..de6a53c --- /dev/null +++ b/Modules/Compiler/CrayClang-CXX.cmake @@ -0,0 +1,35 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Compiler/CrayClang) +__compiler_cray_clang(CXX) + + +set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) +set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") + +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") + +set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -std=c++98) +set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -std=gnu++98) +set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -std=c++11) +set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -std=gnu++11) +set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -std=c++14) +set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -std=gnu++14) +set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_CXX17_STANDARD_COMPILE_OPTION -std=c++17) +set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION -std=gnu++17) + +set(CMAKE_CXX20_STANDARD_COMPILE_OPTION -std=c++20) +set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION -std=gnu++20) + +set(CMAKE_CXX23_STANDARD_COMPILE_OPTION -std=c++2b) +set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION -std=gnu++2b) + +__compiler_check_default_language_standard(CXX 15.0.0 14) diff --git a/Modules/Compiler/CrayClang-DetermineCompiler.cmake b/Modules/Compiler/CrayClang-DetermineCompiler.cmake new file mode 100644 index 0000000..1828444 --- /dev/null +++ b/Modules/Compiler/CrayClang-DetermineCompiler.cmake @@ -0,0 +1,8 @@ +set(_compiler_id_pp_test "defined(__clang__) && defined(__cray__)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__cray_major__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__cray_minor__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__cray_patchlevel__) +# define @PREFIX@COMPILER_VERSION_INTERNAL_STR __clang_version__ +") diff --git a/Modules/Compiler/CrayClang.cmake b/Modules/Compiler/CrayClang.cmake new file mode 100644 index 0000000..d2db9dd --- /dev/null +++ b/Modules/Compiler/CrayClang.cmake @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_CRAYCLANG) + return() +endif() +set(__COMPILER_CRAYCLANG 1) + +include(Compiler/Clang) + +macro (__compiler_cray_clang lang) + set(__crayclang_ver "${CMAKE_${lang}_COMPILER_VERSION}") + set("CMAKE_${lang}_COMPILER_VERSION" "${CMAKE_${lang}_COMPILER_VERSION_INTERNAL}") + __compiler_clang(${lang}) + set("CMAKE_${lang}_COMPILER_VERSION" "${__crayclang_ver}") +endmacro () diff --git a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt index dd4fe02..f20eb5d 100644 --- a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt @@ -11,11 +11,11 @@ add_executable(target_compile_options "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ) target_compile_options(target_compile_options - PRIVATE $<$<CXX_COMPILER_ID:AppleClang,IBMClang,Clang,GNU,LCC>:-DMY_PRIVATE_DEFINE> + PRIVATE $<$<CXX_COMPILER_ID:AppleClang,IBMClang,CrayClang,Clang,GNU,LCC>:-DMY_PRIVATE_DEFINE> PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,LCC>:-DMY_PUBLIC_DEFINE> - PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,LCC,Clang,AppleClang,IBMClang>:-DMY_MUTLI_COMP_PUBLIC_DEFINE> + PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,LCC,Clang,AppleClang,CrayClang,IBMClang>:-DMY_MUTLI_COMP_PUBLIC_DEFINE> INTERFACE $<$<CXX_COMPILER_ID:GNU,LCC>:-DMY_INTERFACE_DEFINE> - INTERFACE $<$<CXX_COMPILER_ID:GNU,LCC,Clang,AppleClang,IBMClang>:-DMY_MULTI_COMP_INTERFACE_DEFINE> + INTERFACE $<$<CXX_COMPILER_ID:GNU,LCC,Clang,AppleClang,CrayClang,IBMClang>:-DMY_MULTI_COMP_INTERFACE_DEFINE> ) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC") @@ -51,7 +51,7 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio") endif() target_compile_options(consumer - PRIVATE $<$<CXX_COMPILER_ID:GNU,LCC,Clang,AppleClang,IBMClang>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>> + PRIVATE $<$<CXX_COMPILER_ID:GNU,LCC,Clang,AppleClang,CrayClang,IBMClang>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>> ) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC") diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 0df05b9..f6a26e7 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -55,7 +55,7 @@ endmacro() # detailed features tables, not just meta-features if (CMAKE_C_COMPILE_FEATURES) - if (NOT CMAKE_C_COMPILER_ID MATCHES "^(LCC|Cray|PGI|NVHPC|XL|XLClang|IBMClang|IntelLLVM|Fujitsu|FujitsuClang)$") + if (NOT CMAKE_C_COMPILER_ID MATCHES "^(LCC|Cray|CrayClang|PGI|NVHPC|XL|XLClang|IBMClang|IntelLLVM|Fujitsu|FujitsuClang)$") set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") endif() @@ -98,7 +98,7 @@ if (C_expected_features) endif() if (CMAKE_CXX_COMPILE_FEATURES) - if (NOT CMAKE_CXX_COMPILER_ID MATCHES "^(LCC|Cray|PGI|NVHPC|XL|XLClang|IBMClang|IntelLLVM|Fujitsu|FujitsuClang)$") + if (NOT CMAKE_CXX_COMPILER_ID MATCHES "^(LCC|Cray|CrayClang|PGI|NVHPC|XL|XLClang|IBMClang|IntelLLVM|Fujitsu|FujitsuClang)$") set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") endif() diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 8911e18..807d92b 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -846,7 +846,7 @@ def gen_check_targets(c, g, inSource): e["compileGroups"] = apple_exe_framework["compileGroups"] e["link"] = apple_exe_framework["link"] - if cxx_compiler_id in ['Clang', 'AppleClang', 'LCC', 'GNU', 'Intel', 'IntelLLVM', 'MSVC', 'Embarcadero', 'IBMClang'] and g["name"] != "Xcode": + if cxx_compiler_id in ['Clang', 'AppleClang', 'LCC', 'GNU', 'Intel', 'IntelLLVM', 'MSVC', 'Embarcadero', 'CrayClang', 'IBMClang'] and g["name"] != "Xcode": for e in expected: if e["name"] == "cxx_exe": if matches(g["name"], "^(Visual Studio |Ninja Multi-Config)"): |