From 87b9d6d93f2e5e6076992cae7395647359de306d Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Mon, 1 May 2017 09:29:03 -0400 Subject: [PATCH] XL: Use common compiler macros for language standard default --- Modules/Compiler/XL-C.cmake | 41 ++++++++++----------------- Modules/Compiler/XL-CXX.cmake | 53 +++++++++++++---------------------- Modules/Compiler/XL.cmake | 2 ++ 3 files changed, 37 insertions(+), 59 deletions(-) diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake index ac84da22f4..5dc8bc17fa 100644 --- a/Modules/Compiler/XL-C.cmake +++ b/Modules/Compiler/XL-C.cmake @@ -12,21 +12,21 @@ string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded") # little-endian, all versions on Linux ppc64 big-endian, all versions on AIX # and BGQ, etc) are derived from the UNIX compiler and only accept the # -qlanglvl option. -if (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND - CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) - set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") - set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") - set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") +if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) + if (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") + set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + else () + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") + endif () else () - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") - endif () -else () - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89") set(CMAKE_C99_STANDARD_COMPILE_OPTION "-qlanglvl=stdc99") @@ -38,15 +38,4 @@ else () endif () endif() -if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) - if (NOT CMAKE_C_COMPILER_FORCED) - if (NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT) - message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}") - else () - set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT}) - endif () - elseif (NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT) - # Compiler id was forced so just guess the default standard level. - set(CMAKE_C_STANDARD_DEFAULT 90) - endif () -endif () +__compiler_check_default_language_standard(C 10.1 90) diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake index 98ccb295f1..b87e9238bc 100644 --- a/Modules/Compiler/XL-CXX.cmake +++ b/Modules/Compiler/XL-CXX.cmake @@ -12,32 +12,30 @@ string(APPEND CMAKE_CXX_FLAGS_INIT " -qthreaded") # little-endian, all versions on Linux ppc64 big-endian, all versions on AIX # and BGQ, etc) are derived from the UNIX compiler and only accept the # -qlanglvl option. -if (CMAKE_SYSTEM MATCHES "Linux.*ppc64") - if (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND - CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") - set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") - set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-qlanglvl=extended1y") +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) + if (CMAKE_SYSTEM MATCHES "Linux.*ppc64") + if (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-qlanglvl=extended1y") + else () + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") + endif () else () - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") - endif () - else () - # The non-clang based Linux ppc64 compiler, both big-endian and - # little-endian lacks, the non-extension language level flags - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) + # The non-clang based Linux ppc64 compiler, both big-endian and + # little-endian lacks, the non-extension language level flags set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-qlanglvl=extended") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-qlanglvl=extended") set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") endif () - endif () -else () - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) + else () set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-qlanglvl=strict98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-qlanglvl=extended") set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") @@ -45,18 +43,7 @@ else () endif () endif () +__compiler_check_default_language_standard(CXX 10.1 98) + set(CMAKE_CXX_COMPILE_OBJECT " -+ -o -c ") - -if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) - if (NOT CMAKE_CXX_COMPILER_FORCED) - if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT) - message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}") - else () - set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}) - endif () - elseif (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT) - # Compiler id was forced so just guess the default standard level. - set(CMAKE_CXX_STANDARD_DEFAULT 98) - endif () -endif () diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index 55f71bd83d..4783785708 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -8,6 +8,8 @@ if(__COMPILER_XL) endif() set(__COMPILER_XL 1) +include(Compiler/CMakeCommonCompilerMacros) + # Find the CreateExportList program that comes with this toolchain. find_program(CMAKE_XL_CreateExportList NAMES CreateExportList