2 # search for additional tools required for C/C++ (and other languages ?)
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.
10 # Sets the following variables:
15 # CMAKE_INSTALL_NAME_TOOL
17 # on UNIX, cygwin and mingw
19 #=============================================================================
20 # Copyright 2007-2009 Kitware, Inc.
22 # Distributed under the OSI-approved BSD License (the "License");
23 # see accompanying file Copyright.txt for details.
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.)
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")
37 find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
39 mark_as_advanced(CMAKE_LINKER)
41 # in all other cases search for ar, ranlib, etc.
44 find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
46 find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
48 set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
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})
57 mark_as_advanced(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
62 # on Apple there really should be install_name_tool
64 find_program(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
66 if(NOT CMAKE_INSTALL_NAME_TOOL)
67 message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
70 mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)