1 # determine the compiler to use for ASM programs
3 IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
4 # prefer the environment variable ASM
5 IF($ENV{ASM${ASM_DIALECT}} MATCHES ".+")
6 SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT "$ENV{ASM${ASM_DIALECT}}")
7 ENDIF($ENV{ASM${ASM_DIALECT}} MATCHES ".+")
9 # finally list compilers to try
10 IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
11 SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT})
12 ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
13 SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}as ${_CMAKE_TOOLCHAIN_PREFIX}gas)
14 ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
17 IF (_CMAKE_USER_CXX_COMPILER_PATH OR _CMAKE_USER_C_COMPILER_PATH)
18 FIND_PROGRAM(CMAKE_ASM${ASM_DIALECT}_COMPILER NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST} PATHS ${_CMAKE_USER_C_COMPILER_PATH} ${_CMAKE_USER_CXX_COMPILER_PATH} DOC "Assembler" NO_DEFAULT_PATH)
19 ENDIF (_CMAKE_USER_CXX_COMPILER_PATH OR _CMAKE_USER_C_COMPILER_PATH)
20 FIND_PROGRAM(CMAKE_ASM${ASM_DIALECT}_COMPILER NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST} PATHS ${_CMAKE_TOOLCHAIN_LOCATION} DOC "Assembler")
22 ELSE(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
24 # we only get here if CMAKE_C_COMPILER was specified using -D or a pre-made CMakeCache.txt
25 # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
27 # if a compiler was specified by the user but without path,
28 # now try to find it with the full path
29 # if it is found, force it into the cache,
30 # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND"
31 GET_FILENAME_COMPONENT(_CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH)
32 IF(NOT _CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH)
33 FIND_PROGRAM(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER})
34 MARK_AS_ADVANCED(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH)
35 IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH)
36 SET(CMAKE_ASM${ASM_DIALECT}_COMPILER ${CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH} CACHE FILEPATH "Assembler" FORCE)
37 ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH)
38 ENDIF(NOT _CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH)
39 ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
40 MARK_AS_ADVANCED(CMAKE_ASM${ASM_DIALECT}_COMPILER)
42 IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
43 GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH)
44 ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION)
46 # If we have a gcc cross compiler, they have usually some prefix, like
47 # e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc .
48 # The other tools of the toolchain usually have the same prefix
49 # NAME_WE cannot be used since then this test will fail for names lile
50 # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be
51 # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
52 IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
53 GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME)
54 IF (COMPILER_BASENAME MATCHES "^(.+-)g?as(\\.exe)?$")
55 STRING(REGEX REPLACE "^(.+-)g?as(\\.exe)?$" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
56 ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as(\\.exe)?$")
57 ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
59 INCLUDE(CMakeFindBinUtils)
61 SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR "ASM")
63 IF(CMAKE_ASM${ASM_DIALECT}_COMPILER)
64 MESSAGE(STATUS "Found assembler: ${CMAKE_ASM${ASM_DIALECT}_COMPILER}")
65 ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER)
66 MESSAGE(STATUS "Didn't find assembler")
67 ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER)
70 SET(_CMAKE_ASM_COMPILER "${CMAKE_ASM${ASM_DIALECT}_COMPILER}")
71 SET(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}")
72 SET(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}")
74 # configure variables set in this file for fast reload later on
75 CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in
76 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeASM${ASM_DIALECT}Compiler.cmake IMMEDIATE @ONLY)
78 SET(_CMAKE_ASM_COMPILER)
79 SET(_CMAKE_ASM_COMPILER_ARG1)
80 SET(_CMAKE_ASM_COMPILER_ENV_VAR)