From b9d36826c5676bf3d0bb55fb47c6ce62f4f3470d Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 8 Mar 2017 11:25:47 +0800 Subject: Add 'CMAKE_GCC_AR' and 'CMAKE_GCC_RANLIB' variables --- Help/manual/cmake-variables.7.rst | 2 ++ Help/release/dev/gcc_archiving_tools.rst | 8 ++++++++ Help/variable/CMAKE_GCC_AR.rst | 7 +++++++ Help/variable/CMAKE_GCC_RANLIB.rst | 7 +++++++ Modules/CMakeASMCompiler.cmake.in | 2 ++ Modules/CMakeCCompiler.cmake.in | 2 ++ Modules/CMakeCXXCompiler.cmake.in | 2 ++ Modules/CMakeDetermineCCompiler.cmake | 4 ++++ Modules/CMakeDetermineCXXCompiler.cmake | 4 ++++ Modules/CMakeDetermineFortranCompiler.cmake | 3 +++ Modules/CMakeFortranCompiler.cmake.in | 2 ++ Modules/Compiler/GNU-FindBinUtils.cmake | 27 +++++++++++++++++++++++++++ 12 files changed, 70 insertions(+) create mode 100644 Help/release/dev/gcc_archiving_tools.rst create mode 100644 Help/variable/CMAKE_GCC_AR.rst create mode 100644 Help/variable/CMAKE_GCC_RANLIB.rst create mode 100644 Modules/Compiler/GNU-FindBinUtils.cmake diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 3ec0c19..2606ba0 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -40,6 +40,8 @@ Variables that Provide Information /variable/CMAKE_FIND_PACKAGE_NAME /variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION /variable/CMAKE_FIND_PACKAGE_SORT_ORDER + /variable/CMAKE_GCC_AR + /variable/CMAKE_GCC_RANLIB /variable/CMAKE_GENERATOR /variable/CMAKE_GENERATOR_PLATFORM /variable/CMAKE_GENERATOR_TOOLSET diff --git a/Help/release/dev/gcc_archiving_tools.rst b/Help/release/dev/gcc_archiving_tools.rst new file mode 100644 index 0000000..b3cc7d6 --- /dev/null +++ b/Help/release/dev/gcc_archiving_tools.rst @@ -0,0 +1,8 @@ +gcc_archiving_tools +------------------- + +* The :variable:`CMAKE_GCC_AR` variable with the path to GCC wrapper of ``ar`` + utility was added. + +* The :variable:`CMAKE_GCC_RANLIB` variable with the path to GCC wrapper of + ``ranlib`` utility was added. diff --git a/Help/variable/CMAKE_GCC_AR.rst b/Help/variable/CMAKE_GCC_AR.rst new file mode 100644 index 0000000..ac90b46 --- /dev/null +++ b/Help/variable/CMAKE_GCC_AR.rst @@ -0,0 +1,7 @@ +CMAKE_GCC_AR +------------ + +A wrapper around ``ar`` adding the appropriate ``--plugin`` option for the +GCC compiler. For other compilers variable is not defined. + +See also :variable:`CMAKE_AR`. diff --git a/Help/variable/CMAKE_GCC_RANLIB.rst b/Help/variable/CMAKE_GCC_RANLIB.rst new file mode 100644 index 0000000..3d42aba --- /dev/null +++ b/Help/variable/CMAKE_GCC_RANLIB.rst @@ -0,0 +1,7 @@ +CMAKE_GCC_RANLIB +---------------- + +A wrapper around ``ranlib`` adding the appropriate ``--plugin`` option for the +GCC compiler. For other compilers variable is not defined. + +See also :variable:`CMAKE_RANLIB`. diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in index 8e58307..ad65698 100644 --- a/Modules/CMakeASMCompiler.cmake.in +++ b/Modules/CMakeASMCompiler.cmake.in @@ -1,7 +1,9 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER "@_CMAKE_ASM_COMPILER@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ARG1 "@_CMAKE_ASM_COMPILER_ARG1@") set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_GCC_AR "@CMAKE_GCC_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_GCC_RANLIB "@CMAKE_GCC_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_LOADED 1) set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ID "@_CMAKE_ASM_COMPILER_ID@") diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 50b12f2..ab068a2 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -14,7 +14,9 @@ set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@") set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@") @SET_MSVC_C_ARCHITECTURE_ID@ set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_GCC_AR "@CMAKE_GCC_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_GCC_RANLIB "@CMAKE_GCC_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@) set(CMAKE_C_COMPILER_LOADED 1) diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 6d56488..27c8881 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -15,7 +15,9 @@ set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@") set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@") @SET_MSVC_CXX_ARCHITECTURE_ID@ set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_GCC_AR "@CMAKE_GCC_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_GCC_RANLIB "@CMAKE_GCC_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) set(CMAKE_CXX_COMPILER_LOADED 1) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 4a315e0..5d9850d 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -166,6 +166,10 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) endif () include(CMakeFindBinUtils) +set(_CMAKE_PROCESSING_LANGUAGE "C") +include(Compiler/${CMAKE_C_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) + if(MSVC_C_ARCHITECTURE_ID) set(SET_MSVC_C_ARCHITECTURE_ID "set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index f2e0bb2..4d85150 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -161,6 +161,10 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) endif () include(CMakeFindBinUtils) +set(_CMAKE_PROCESSING_LANGUAGE "CXX") +include(Compiler/${CMAKE_CXX_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) + if(MSVC_CXX_ARCHITECTURE_ID) set(SET_MSVC_CXX_ARCHITECTURE_ID "set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})") diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 484fa66..9e9770a 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -255,6 +255,9 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) endif () include(CMakeFindBinUtils) +set(_CMAKE_PROCESSING_LANGUAGE "Fortran") +include(Compiler/${CMAKE_Fortran_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) if(MSVC_Fortran_ARCHITECTURE_ID) set(SET_MSVC_Fortran_ARCHITECTURE_ID diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index 69800d7..c49621b 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -8,7 +8,9 @@ set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@") set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@") @SET_MSVC_Fortran_ARCHITECTURE_ID@ set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_GCC_AR "@CMAKE_GCC_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_GCC_RANLIB "@CMAKE_GCC_RANLIB@") set(CMAKE_COMPILER_IS_GNUG77 @CMAKE_COMPILER_IS_GNUG77@) set(CMAKE_Fortran_COMPILER_LOADED 1) set(CMAKE_Fortran_COMPILER_WORKS @CMAKE_Fortran_COMPILER_WORKS@) diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake new file mode 100644 index 0000000..e314eb9 --- /dev/null +++ b/Modules/Compiler/GNU-FindBinUtils.cmake @@ -0,0 +1,27 @@ +cmake_policy(SET CMP0054 NEW) + +if("${_CMAKE_PROCESSING_LANGUAGE}" STREQUAL "") + message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set") +endif() + +string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}") + +# Try to find tools in the same directory as GCC itself +get_filename_component(__gcc_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) + +# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ar.1.html +find_program(CMAKE_GCC_AR NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}" + HINTS ${__gcc_hints} + DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler" +) + +# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ranlib.1.html +find_program(CMAKE_GCC_RANLIB NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}" + HINTS ${__gcc_hints} + DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler" +) -- cgit v0.12