On Mar 23 [10:33], Brad King wrote: > On 03/23/2015 04:37 AM, Steven Vancoillie wrote: > Thanks. I split out the -KPIE removal: > > SunPro: Drop non-existent -KPIE flag > http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=209c142f > > Please rebase the revisions below on that. > > The current patch does not account for differences in the > flags for each language: > > * The _VERBOSE_FLAG is -v for most languages and -# for ASM.
The verbose flags for SunPro compilers are documented as: Sun C compiler: -# (-v enables stricter semantic checks) Sun CXX compiler: -# (-v turns on -verbose=diags, seems similar) Sun ASM compiler: none (-v/-# are not recognized) Sun Fortran compiler: -v (-# works too) Since the current verbose flags are thus not correct, I've left this alone in this patch, as it should be pure refactoring. Maybe they can go in a separate patch? > * The _CREATE_PREPROCESSED_SOURCE rule for Fortran uses -F > instead of -E. The _CREATE_PREPROCESSED_SOURCE rule for Fortran is now overwritten again in the Fortran-specific file to use the -F option. > Please revise the patch accordingly and check that the values > set after refactoring match those from before. It is okay for > flags that are not shared by all languages to be set as they > are now or overridden after the macro call. I've attached the new patch. This does not strictly follow your rule, as now there will be a CMAKE_ASM_COMPILE_OPTIONS_PIC variable set because of the macro (before this was not set). Should I unset it again in the ASM-specific file? Steven
>From f524d09ae0b8315fded0299866da6770e76144af Mon Sep 17 00:00:00 2001 From: Steven Vancoillie <[email protected]> Date: Tue, 24 Mar 2015 09:10:31 +0100 Subject: [PATCH] Refactor SunPro per-language options into single macro Move SunPro compiler options that are shared between languages into a single macro inside a languange-independent helper module Compiler/SunPro.cmake which is then invoked from the per-language modules Compiler/SunPro-<lang>.cmake --- Modules/Compiler/SunPro-ASM.cmake | 10 --------- Modules/Compiler/SunPro-C.cmake | 14 ------------ Modules/Compiler/SunPro-CXX.cmake | 15 +------------ Modules/Compiler/SunPro-Fortran.cmake | 12 ----------- Modules/Compiler/SunPro.cmake | 40 +++++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 50 deletions(-) create mode 100644 Modules/Compiler/SunPro.cmake diff --git a/Modules/Compiler/SunPro-ASM.cmake b/Modules/Compiler/SunPro-ASM.cmake index 2fa8b99..fd7c5ab 100644 --- a/Modules/Compiler/SunPro-ASM.cmake +++ b/Modules/Compiler/SunPro-ASM.cmake @@ -2,17 +2,7 @@ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) set(CMAKE_ASM_VERBOSE_FLAG "-#") -set(CMAKE_SHARED_LIBRARY_ASM_FLAGS "-KPIC") -set(CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS "-G") -set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG "-R") -set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG_SEP ":") -set(CMAKE_SHARED_LIBRARY_SONAME_ASM_FLAG "-h") -set(CMAKE_ASM_FLAGS_INIT "") -set(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") -set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") -set(CMAKE_ASM_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") -set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") # Initialize ASM link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 92252cb..ed2c927 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -1,17 +1,6 @@ set(CMAKE_C_VERBOSE_FLAG "-#") -set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC) -set(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC") -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G") -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R") -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") -set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-h") -set(CMAKE_C_FLAGS_INIT "") -set(CMAKE_C_FLAGS_DEBUG_INIT "-g") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links @@ -21,6 +10,3 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Bstatic") set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Bdynamic") endforeach() - -set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") -set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 022b4d4..a3f0c6b 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -1,17 +1,6 @@ set(CMAKE_CXX_VERBOSE_FLAG "-v") -set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC) -set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC") -set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G") -set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R") -set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ":") -set(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-h") - -set(CMAKE_CXX_FLAGS_INIT "") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") + # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links @@ -22,8 +11,6 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Bdynamic") endforeach() -set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") -set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") # Create archives with "CC -xar" in case user adds "-instances=extern" # so that template instantiations are available to archive members. diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index 196aae4..fdd96a9 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -2,21 +2,9 @@ set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") -set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-KPIC") -set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC") -set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G") -set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-R") -set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ":") -set(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-h") set(CMAKE_EXECUTABLE_RUNTIME_Fortran_FLAG "-R") -set(CMAKE_Fortran_FLAGS_INIT "") -set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") -set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") -set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") -set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") set(CMAKE_Fortran_MODDIR_FLAG "-moddir=") set(CMAKE_Fortran_MODPATH_FLAG "-M") set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -F <SOURCE> -o <PREPROCESSED_SOURCE>") -set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/SunPro.cmake b/Modules/Compiler/SunPro.cmake new file mode 100644 index 0000000..6db19b4 --- /dev/null +++ b/Modules/Compiler/SunPro.cmake @@ -0,0 +1,40 @@ + +#============================================================================= +# Copyright 2002-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_SUNPRO) + return() +endif() +set(__COMPILER_SUNPRO 1) + +macro(__compiler_sunpro lang) + # Feature flags. + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC -KPIC) + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-KPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-G") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-R") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-h") + + # Initial configuration flags. + set(CMAKE_${lang}_FLAGS_INIT "") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") + + # Preprocessing and assembly rules. + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") +endmacro() -- 2.3.3
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
