Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / CMakeFindBinUtils.cmake
1
2 # search for additional tools required for C/C++ (and other languages ?)
3 #
4 # If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used
5 # as prefix for the tools (e.g. arm-elf-gcc etc.)
6 # If the cmake variable _CMAKE_TOOLCHAIN_LOCATION is set, the compiler is
7 # searched only there. The other tools are at first searched there, then
8 # also in the default locations.
9 #
10 # Sets the following variables:
11 #   CMAKE_AR
12 #   CMAKE_RANLIB
13 #   CMAKE_LINKER
14 #   CMAKE_STRIP
15 #   CMAKE_INSTALL_NAME_TOOL
16
17 # on UNIX, cygwin and mingw
18
19 #=============================================================================
20 # Copyright 2007-2009 Kitware, Inc.
21 #
22 # Distributed under the OSI-approved BSD License (the "License");
23 # see accompanying file Copyright.txt for details.
24 #
25 # This software is distributed WITHOUT ANY WARRANTY; without even the
26 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 # See the License for more information.
28 #=============================================================================
29 # (To distribute this file outside of CMake, substitute the full
30 #  License text for the above reference.)
31
32 # if it's the MS C/CXX compiler, search for link
33 if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
34    OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
35    OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
36
37   find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
38
39   mark_as_advanced(CMAKE_LINKER)
40
41 # in all other cases search for ar, ranlib, etc.
42 else()
43
44   find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
45
46   find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
47   if(NOT CMAKE_RANLIB)
48     set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
49   endif()
50
51   find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
52   find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
53   find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
54   find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
55   find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
56
57   mark_as_advanced(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
58
59 endif()
60
61
62 # on Apple there really should be install_name_tool
63 if(APPLE)
64   find_program(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
65
66   if(NOT CMAKE_INSTALL_NAME_TOOL)
67     message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
68   endif()
69
70   mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)
71 endif()