diff options
author | Brad King <brad.king@kitware.com> | 2022-01-28 14:50:06 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-01-28 14:50:15 (GMT) |
commit | 6108352f0ac004ea94b0c8bab481fcf0611c35d1 (patch) | |
tree | a4195b4118211182a67f55fc49ec7f1cc0963376 /Modules | |
parent | ba069c10dd6a52e58b2a846136fbfa6846aec971 (diff) | |
parent | 8c1731546c275ed4aadea36b2533ff653f0ef601 (diff) | |
download | CMake-6108352f0ac004ea94b0c8bab481fcf0611c35d1.zip CMake-6108352f0ac004ea94b0c8bab481fcf0611c35d1.tar.gz CMake-6108352f0ac004ea94b0c8bab481fcf0611c35d1.tar.bz2 |
Merge topic 'ibmclang-compiler'
8c1731546c Help: Add release note for IBM Open XL C/C++ compiler support
24da80b70a Utilities: Suppress warnings in third-party code with IBMClang
6da99e671c IBMClang: Add support for IBM Open XL C/C++
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6785
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeCompilerIdDetection.cmake | 1 | ||||
-rw-r--r-- | Modules/Compiler/IBMClang-ASM.cmake | 5 | ||||
-rw-r--r-- | Modules/Compiler/IBMClang-C-DetermineCompiler.cmake | 8 | ||||
-rw-r--r-- | Modules/Compiler/IBMClang-C.cmake | 30 | ||||
-rw-r--r-- | Modules/Compiler/IBMClang-CXX-DetermineCompiler.cmake | 8 | ||||
-rw-r--r-- | Modules/Compiler/IBMClang-CXX.cmake | 39 | ||||
-rw-r--r-- | Modules/Compiler/IBMClang.cmake | 79 | ||||
-rw-r--r-- | Modules/GenerateExportHeader.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/AIX-IBMClang-C.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/AIX-IBMClang-CXX.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/AIX-IBMClang.cmake | 15 |
11 files changed, 190 insertions, 1 deletions
diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 044326c..f15974a 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -59,6 +59,7 @@ function(compiler_id_detection outvar lang) HP Compaq zOS + IBMClang XLClang XL VisualAge diff --git a/Modules/Compiler/IBMClang-ASM.cmake b/Modules/Compiler/IBMClang-ASM.cmake new file mode 100644 index 0000000..dffc085 --- /dev/null +++ b/Modules/Compiler/IBMClang-ASM.cmake @@ -0,0 +1,5 @@ +include(Compiler/IBMClang) + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) + +__compiler_ibmclang(ASM) diff --git a/Modules/Compiler/IBMClang-C-DetermineCompiler.cmake b/Modules/Compiler/IBMClang-C-DetermineCompiler.cmake new file mode 100644 index 0000000..623c8af --- /dev/null +++ b/Modules/Compiler/IBMClang-C-DetermineCompiler.cmake @@ -0,0 +1,8 @@ +set(_compiler_id_pp_test "defined(__open_xl__) && defined(__clang__)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__open_xl_version__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__open_xl_release__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__open_xl_modification__) +# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__open_xl_ptf_fix_level__) +") diff --git a/Modules/Compiler/IBMClang-C.cmake b/Modules/Compiler/IBMClang-C.cmake new file mode 100644 index 0000000..b69b1b8 --- /dev/null +++ b/Modules/Compiler/IBMClang-C.cmake @@ -0,0 +1,30 @@ +include(Compiler/IBMClang) +__compiler_ibmclang(C) + +set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_C) + # dependencies are computed by the compiler itself + set(CMAKE_C_DEPFILE_FORMAT gcc) + set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) +endif() + +set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") +set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") + +set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") +set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + +set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") +set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + +if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1.0) + set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") + set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") +endif () +__compiler_check_default_language_standard(C 17.1.0 17) diff --git a/Modules/Compiler/IBMClang-CXX-DetermineCompiler.cmake b/Modules/Compiler/IBMClang-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..623c8af --- /dev/null +++ b/Modules/Compiler/IBMClang-CXX-DetermineCompiler.cmake @@ -0,0 +1,8 @@ +set(_compiler_id_pp_test "defined(__open_xl__) && defined(__clang__)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__open_xl_version__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__open_xl_release__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__open_xl_modification__) +# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__open_xl_ptf_fix_level__) +") diff --git a/Modules/Compiler/IBMClang-CXX.cmake b/Modules/Compiler/IBMClang-CXX.cmake new file mode 100644 index 0000000..5431b17 --- /dev/null +++ b/Modules/Compiler/IBMClang-CXX.cmake @@ -0,0 +1,39 @@ +include(Compiler/IBMClang) +__compiler_ibmclang(CXX) + +if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_CXX) + # dependencies are computed by the compiler itself + set(CMAKE_CXX_DEPFILE_FORMAT gcc) + set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) + endif() + + set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") +endif() + +set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") +set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + +set(CMAKE_CXX11_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_CXX14_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") +set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") + +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1.0) + 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") +endif() + +__compiler_check_default_language_standard(CXX 17.1.0 17) + +set(CMAKE_CXX_COMPILE_OBJECT + "<CMAKE_CXX_COMPILER> -x c++ <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") diff --git a/Modules/Compiler/IBMClang.cmake b/Modules/Compiler/IBMClang.cmake new file mode 100644 index 0000000..9ed7658 --- /dev/null +++ b/Modules/Compiler/IBMClang.cmake @@ -0,0 +1,79 @@ +# 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_IBMClang) + return() +endif() +set(__COMPILER_IBMClang 1) + +include(Compiler/CMakeCommonCompilerMacros) + +set(__pch_header_C "c-header") +set(__pch_header_CXX "c++-header") +set(__pch_header_OBJC "objective-c-header") +set(__pch_header_OBJCXX "objective-c++-header") + +include(Compiler/GNU) + +macro(__compiler_ibmclang lang) + __compiler_gnu(${lang}) + + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIC") + set(CMAKE_${lang}_RESPONSE_FILE_FLAG "@") + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") + + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") + set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") + set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "--gcc-toolchain=") + + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP) + + if(CMAKE_${lang}_COMPILER_TARGET) + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}") + endif() + + set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) + set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + + set(_CMAKE_LTO_THIN TRUE) + + if(_CMAKE_LTO_THIN) + set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto=thin") + else() + set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto") + endif() + + set(__ar "${CMAKE_${lang}_COMPILER_AR}") + set(__ranlib "${CMAKE_${lang}_COMPILER_RANLIB}") + + set(CMAKE_${lang}_ARCHIVE_CREATE_IPO + "\"${__ar}\" cr <TARGET> <LINK_FLAGS> <OBJECTS>" + ) + + set(CMAKE_${lang}_ARCHIVE_APPEND_IPO + "\"${__ar}\" r <TARGET> <LINK_FLAGS> <OBJECTS>" + ) + + set(CMAKE_${lang}_ARCHIVE_FINISH_IPO + "\"${__ranlib}\" <TARGET>" + ) + + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + + set(CMAKE_PCH_EXTENSION .pch) + + set(CMAKE_PCH_PROLOGUE "#pragma clang system_header") + + set(CMAKE_${lang}_COMPILE_OPTIONS_INSTANTIATE_TEMPLATES_PCH -fpch-instantiate-templates) + + set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>) + set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}}) +endmacro() diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index a9a9c59..7461a3e 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -231,7 +231,7 @@ macro(_test_compiler_hidden_visibility) AND NOT _INTEL_TOO_OLD AND NOT WIN32 AND NOT CYGWIN - AND NOT CMAKE_CXX_COMPILER_ID MATCHES XL + AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^(IBMClang|XLClang|XL)$" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^(PGI|NVHPC)$" AND NOT CMAKE_CXX_COMPILER_ID MATCHES Watcom) if (CMAKE_CXX_COMPILER_LOADED) diff --git a/Modules/Platform/AIX-IBMClang-C.cmake b/Modules/Platform/AIX-IBMClang-C.cmake new file mode 100644 index 0000000..db21f29 --- /dev/null +++ b/Modules/Platform/AIX-IBMClang-C.cmake @@ -0,0 +1,2 @@ +include(Platform/AIX-IBMClang) +__aix_compiler_ibmclang(C) diff --git a/Modules/Platform/AIX-IBMClang-CXX.cmake b/Modules/Platform/AIX-IBMClang-CXX.cmake new file mode 100644 index 0000000..5cbe719 --- /dev/null +++ b/Modules/Platform/AIX-IBMClang-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/AIX-IBMClang) +__aix_compiler_ibmclang(CXX) diff --git a/Modules/Platform/AIX-IBMClang.cmake b/Modules/Platform/AIX-IBMClang.cmake new file mode 100644 index 0000000..ffb402c --- /dev/null +++ b/Modules/Platform/AIX-IBMClang.cmake @@ -0,0 +1,15 @@ +# 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(__AIX_COMPILER_IBMCLANG) + return() +endif() +set(__AIX_COMPILER_IBMCLANG 1) + +include(Platform/AIX-GNU) + +macro(__aix_compiler_ibmclang lang) + __aix_compiler_gnu(${lang}) +endmacro() |