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
20 # if it's the MS C/CXX compiler, search for link
21 IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
22 OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
23 OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
25 FIND_PROGRAM(CMAKE_LINKER NAMES link PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
26 FIND_PROGRAM(CMAKE_LINKER NAMES link)
28 MARK_AS_ADVANCED(CMAKE_LINKER)
30 # in all other cases search for ar, ranlib, etc.
31 ELSE("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
32 OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
33 OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
35 FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
36 FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar)
38 FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
39 FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib)
41 SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
42 ENDIF(NOT CMAKE_RANLIB)
44 FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
45 FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip)
47 FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
48 FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld)
50 FIND_PROGRAM(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
51 FIND_PROGRAM(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm)
53 FIND_PROGRAM(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
54 FIND_PROGRAM(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump)
56 FIND_PROGRAM(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
57 FIND_PROGRAM(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy)
59 MARK_AS_ADVANCED(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
61 ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
62 OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
63 OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
66 # on Apple there really should be install_name_tool
68 FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
69 FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool)
71 IF(NOT CMAKE_INSTALL_NAME_TOOL)
72 MESSAGE(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
73 ENDIF(NOT CMAKE_INSTALL_NAME_TOOL)
75 MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_TOOL)
78 # if we are on an ELF system, search for chrpath
79 # according to the binutils mailing list chrpath has problems when cross compiling
80 # i.e. if the target has different endianness than the host
81 IF("${CMAKE_EXECUTABLE_FORMAT}" STREQUAL "ELF" AND NOT CMAKE_CROSSCOMPILING)
82 # on ELF platforms there might be chrpath, which works similar to install_name_tool
83 OPTION(CMAKE_USE_CHRPATH "Enable this to use chrpath if available" OFF)
85 FIND_PROGRAM(CMAKE_CHRPATH chrpath PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
86 FIND_PROGRAM(CMAKE_CHRPATH chrpath)
88 MARK_AS_ADVANCED(CMAKE_CHRPATH CMAKE_USE_CHRPATH)
89 ENDIF("${CMAKE_EXECUTABLE_FORMAT}" STREQUAL "ELF" AND NOT CMAKE_CROSSCOMPILING)