summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-09-27 18:56:32 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-09-27 18:56:53 (GMT)
commitc88cf48bbe775c45c36c23b990c89d85b7b9a220 (patch)
treece4d0700523fa6bcb989e125c6e6d37eec6a2e5f
parentf30f1625c25afb44861eff1f69ca4fa966077c73 (diff)
parentb2fd479df595394734ed1a830848cba2f57729f2 (diff)
downloadCMake-c88cf48bbe775c45c36c23b990c89d85b7b9a220.zip
CMake-c88cf48bbe775c45c36c23b990c89d85b7b9a220.tar.gz
CMake-c88cf48bbe775c45c36c23b990c89d85b7b9a220.tar.bz2
Merge topic 'FindBinUtils-ask-compiler'
b2fd479df5 FindBinUtils: Use the compiler to get the path to compiler tools 587ccffe74 Tests: Add symbols to FortranModules static libraries Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Alex Turbov <i.zaufi@gmail.com> Merge-request: !3854
-rw-r--r--Modules/CMakeFindBinUtils.cmake70
-rw-r--r--Modules/Compiler/GNU-FindBinUtils.cmake26
-rw-r--r--Tests/FortranModules/Library/a.f903
-rw-r--r--Tests/FortranModules/Library/b.f903
-rw-r--r--Tests/FortranModules/Subdir/subdir.f903
5 files changed, 84 insertions, 21 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake
index 781b48c..3887b2d 100644
--- a/Modules/CMakeFindBinUtils.cmake
+++ b/Modules/CMakeFindBinUtils.cmake
@@ -57,6 +57,44 @@ endfunction()
__resolve_tool_path(CMAKE_LINKER "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Linker")
__resolve_tool_path(CMAKE_MT "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Manifest Tool")
+function(__get_compiler_component CMAKE_TOOL NAME)
+ get_property(_CMAKE_TOOL_CACHED CACHE ${CMAKE_TOOL} PROPERTY TYPE)
+ # If CMAKE_TOOL is present in the CMake Cache, return
+ if(_CMAKE_TOOL_CACHED)
+ return()
+ endif()
+
+ cmake_parse_arguments(_COMPILER_COMP_ARGS "" "DOC" "HINTS;NAMES" ${ARGN})
+
+ set(_LOCATION_FROM_COMPILER )
+ set(_NAME_FROM_COMPILER )
+
+ if (NOT DEFINED ${CMAKE_TOOL})
+ if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xGNU" OR
+ "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang")
+ execute_process(
+ COMMAND ${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER} -print-prog-name=${NAME}
+ RESULT_VARIABLE _CMAKE_TOOL_PROG_NAME_RESULT
+ OUTPUT_VARIABLE _CMAKE_TOOL_PROG_NAME_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if (_CMAKE_TOOL_PROG_NAME_RESULT STREQUAL "0" AND IS_ABSOLUTE "${_CMAKE_TOOL_PROG_NAME_OUTPUT}")
+ get_filename_component(_LOCATION_FROM_COMPILER "${_CMAKE_TOOL_PROG_NAME_OUTPUT}" DIRECTORY)
+ get_filename_component(_NAME_FROM_COMPILER "${_CMAKE_TOOL_PROG_NAME_OUTPUT}" NAME)
+ endif()
+ endif()
+ endif()
+
+ if (NOT _COMPILER_COMP_ARGS_DOC)
+ set(_COMPILER_COMP_ARGS_DOC "Path to ${NAME} program")
+ endif()
+ find_program(${CMAKE_TOOL}
+ NAMES ${_NAME_FROM_COMPILER} ${_COMPILER_COMP_ARGS_NAMES}
+ HINTS ${_LOCATION_FROM_COMPILER} ${_COMPILER_COMP_ARGS_HINTS}
+ DOC "${_COMPILER_COMP_ARGS_DOC}"
+ )
+endfunction()
+
set(_CMAKE_TOOL_VARS "")
# if it's the MS C/CXX compiler, search for link
@@ -101,22 +139,32 @@ else()
set(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES "llvm-addr2line")
endif()
- find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_AR ar NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_RANLIB ranlib NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
if(NOT CMAKE_RANLIB)
set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
endif()
- find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_STRIP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${_CMAKE_ADDITIONAL_LINKER_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm ${_CMAKE_ADDITIONAL_NM_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${_CMAKE_ADDITIONAL_OBJDUMP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy ${_CMAKE_ADDITIONAL_OBJCOPY_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_READELF NAMES ${_CMAKE_TOOLCHAIN_PREFIX}readelf ${_CMAKE_ADDITIONAL_READELF_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_DLLTOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}dlltool ${_CMAKE_ADDITIONAL_DLLTOOL_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_ADDR2LINE NAMES ${_CMAKE_TOOLCHAIN_PREFIX}addr2line ${_CMAKE_ADDITIONAL_ADDR2LINE_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_STRIP strip NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_STRIP_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_LINKER ld NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${_CMAKE_ADDITIONAL_LINKER_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_NM nm NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm ${_CMAKE_ADDITIONAL_NM_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_OBJDUMP objdump NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${_CMAKE_ADDITIONAL_OBJDUMP_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_OBJCOPY objcopy NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy ${_CMAKE_ADDITIONAL_OBJCOPY_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_READELF readelf NAMES ${_CMAKE_TOOLCHAIN_PREFIX}readelf ${_CMAKE_ADDITIONAL_READELF_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_DLLTOOL dlltool NAMES ${_CMAKE_TOOLCHAIN_PREFIX}dlltool ${_CMAKE_ADDITIONAL_DLLTOOL_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_ADDR2LINE addr2line NAMES ${_CMAKE_TOOLCHAIN_PREFIX}addr2line ${_CMAKE_ADDITIONAL_ADDR2LINE_NAMES}
+ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE)
@@ -134,7 +182,7 @@ else()
endif()
if(CMAKE_PLATFORM_HAS_INSTALLNAME)
- find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ __get_compiler_component(CMAKE_INSTALL_NAME_TOOL install_name_tool NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
if(NOT CMAKE_INSTALL_NAME_TOOL)
message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake
index 097fbf3..a47b7ad 100644
--- a/Modules/Compiler/GNU-FindBinUtils.cmake
+++ b/Modules/Compiler/GNU-FindBinUtils.cmake
@@ -15,21 +15,27 @@ string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y
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_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES
- "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}"
- "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}"
- "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_COMPILER_SUFFIX}"
- HINTS ${__gcc_hints}
+__get_compiler_component(
+ CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR gcc-ar
+ HINTS
+ ${__gcc_hints}
+ NAMES
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}"
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}"
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar"
DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler"
)
mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR)
# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ranlib.1.html
-find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES
- "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}"
- "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}"
- "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib${_CMAKE_COMPILER_SUFFIX}"
- HINTS ${__gcc_hints}
+__get_compiler_component(
+ CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB gcc-ranlib
+ HINTS
+ ${__gcc_hints}
+ NAMES
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}"
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}"
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib"
DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler"
)
mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB)
diff --git a/Tests/FortranModules/Library/a.f90 b/Tests/FortranModules/Library/a.f90
index 3031c07..c180cc0 100644
--- a/Tests/FortranModules/Library/a.f90
+++ b/Tests/FortranModules/Library/a.f90
@@ -1,3 +1,6 @@
MODULE libraryModuleA
USE libraryModuleB
+CONTAINS
+ SUBROUTINE libA
+ END SUBROUTINE
END MODULE
diff --git a/Tests/FortranModules/Library/b.f90 b/Tests/FortranModules/Library/b.f90
index ae1edcb..f550996 100644
--- a/Tests/FortranModules/Library/b.f90
+++ b/Tests/FortranModules/Library/b.f90
@@ -1,2 +1,5 @@
MODULE libraryModuleB
+CONTAINS
+ SUBROUTINE libB
+ END SUBROUTINE
END MODULE
diff --git a/Tests/FortranModules/Subdir/subdir.f90 b/Tests/FortranModules/Subdir/subdir.f90
index 68955f6..5288b06 100644
--- a/Tests/FortranModules/Subdir/subdir.f90
+++ b/Tests/FortranModules/Subdir/subdir.f90
@@ -1,2 +1,5 @@
MODULE subdirModuleA
+CONTAINS
+ SUBROUTINE subdirLibA
+ END SUBROUTINE
END MODULE