소스 검색

FujitsuClang: Add support for the Fujitsu compiler in Clang mode

This should be front end compatible with vanilla clang but giving it a
unique identifier allows a project to pass additional options unique to
Fujitsu and outside the scope of a CMake builtin.
Chuck Atkins 4 년 전
부모
커밋
27579e9cf1

+ 1 - 0
Help/variable/CMAKE_LANG_COMPILER_ID.rst

@@ -20,6 +20,7 @@ include:
   Embarcadero, Borland = Embarcadero (embarcadero.com)
   Flang = Flang LLVM Fortran Compiler
   Fujitsu = Fujitsu HPC compiler (Trad mode)
+  FujitsuClang = Fujitsu HPC compiler (Clang mode)
   G95 = G95 Fortran (g95.org)
   GNU = GNU Compiler Collection (gcc.gnu.org)
   GHS = Green Hills Software (www.ghs.com)

+ 1 - 0
Modules/CMakeCompilerIdDetection.cmake

@@ -66,6 +66,7 @@ function(compiler_id_detection outvar lang)
       PGI
       Cray
       TI
+      FujitsuClang
       Fujitsu
       GHS
     )

+ 2 - 0
Modules/CMakePlatformId.h.in

@@ -285,6 +285,8 @@ char const info_version_internal[] = {
   'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
   'i','n','t','e','r','n','a','l','[',
   COMPILER_VERSION_INTERNAL,']','\0'};
+#elif defined(COMPILER_VERSION_INTERNAL_STR)
+char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]";
 #endif
 
 /* Construct a string literal encoding the version number components. */

+ 1 - 1
Modules/Compiler/Fujitsu-DetermineCompiler.cmake

@@ -1,5 +1,5 @@
 
-set(_compiler_id_pp_test "defined(__FUJITSU) && !defined(__CLANG_FUJITSU)")
+set(_compiler_id_pp_test "defined(__FUJITSU)")
 
 set(_compiler_id_version_compute "
 # if defined(__FCC_version__)

+ 6 - 0
Modules/Compiler/FujitsuClang-C.cmake

@@ -0,0 +1,6 @@
+include(Compiler/FujitsuClang)
+
+set(_fjclang_ver "${CMAKE_C_COMPILER_VERSION_INTERNAL}")
+set(CMAKE_C_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION_INTERNAL}")
+include(Compiler/Clang-C)
+set(CMAKE_C_COMPILER_VERSION "${_fjclang_ver}")

+ 6 - 0
Modules/Compiler/FujitsuClang-CXX.cmake

@@ -0,0 +1,6 @@
+include(Compiler/FujitsuClang)
+
+set(_fjclang_ver "${CMAKE_CXX_COMPILER_VERSION_INTERNAL}")
+set(CMAKE_CXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION_INTERNAL}")
+include(Compiler/Clang-CXX)
+set(CMAKE_CXX_COMPILER_VERSION "${_fjclang_ver}")

+ 9 - 0
Modules/Compiler/FujitsuClang-DetermineCompiler.cmake

@@ -0,0 +1,9 @@
+
+set(_compiler_id_pp_test "defined(__CLANG_FUJITSU)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__FCC_major__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__FCC_minor__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__FCC_patchlevel__)
+# define @PREFIX@COMPILER_VERSION_INTERNAL_STR __clang_version__
+")

+ 11 - 0
Modules/Compiler/FujitsuClang.cmake

@@ -0,0 +1,11 @@
+# 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_FUJITSUCLANG)
+  return()
+endif()
+set(__COMPILER_FUJITSUCLANG 1)
+
+include(Compiler/Clang)

+ 1 - 0
Modules/Platform/Linux-Fujitsu-C.cmake

@@ -0,0 +1 @@
+include(Platform/Linux-Clang-C)

+ 1 - 8
Modules/Platform/Linux-Fujitsu-CXX.cmake

@@ -1,8 +1 @@
-# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details
-
-include(Platform/Linux-Fujitsu)
-__linux_compiler_fujitsu(CXX)
-
-# Special sauce to propagate the -std=xxx flag when linking
-set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION ON)
+include(Platform/Linux-Clang-CXX)