2009-09-28 19:46:51 +04:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2007-2009 Kitware, Inc.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:46:51 +04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2007-06-28 17:14:27 +04:00
|
|
|
# determine the compiler to use for ASM programs
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
|
2012-08-02 19:08:55 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
2007-06-28 17:14:27 +04:00
|
|
|
# prefer the environment variable ASM
|
2012-08-13 21:47:32 +04:00
|
|
|
if($ENV{ASM${ASM_DIALECT}} MATCHES ".+")
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT "$ENV{ASM${ASM_DIALECT}}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-06-28 17:14:27 +04:00
|
|
|
|
|
|
|
# finally list compilers to try
|
2012-08-13 21:47:32 +04:00
|
|
|
if("ASM${ASM_DIALECT}" STREQUAL "ASM") # the generic assembler support
|
|
|
|
if(NOT CMAKE_ASM_COMPILER_INIT)
|
|
|
|
if(CMAKE_C_COMPILER)
|
|
|
|
set(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "The ASM compiler")
|
|
|
|
set(CMAKE_ASM_COMPILER_ID "${CMAKE_C_COMPILER_ID}")
|
|
|
|
elseif(CMAKE_CXX_COMPILER)
|
|
|
|
set(CMAKE_ASM_COMPILER "${CMAKE_CXX_COMPILER}" CACHE FILEPATH "The ASM compiler")
|
|
|
|
set(CMAKE_ASM_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}")
|
|
|
|
else()
|
2011-01-30 23:03:37 +03:00
|
|
|
# List all default C and CXX compilers
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST
|
2012-08-02 19:53:25 +04:00
|
|
|
${_CMAKE_TOOLCHAIN_PREFIX}cc ${_CMAKE_TOOLCHAIN_PREFIX}gcc cl bcc xlc
|
|
|
|
CC ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ aCC cl bcc xlC)
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
else() # some specific assembler "dialect"
|
2013-06-11 23:06:35 +04:00
|
|
|
if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT AND NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST)
|
|
|
|
message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT or CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST must be preset !")
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2007-06-28 17:14:27 +04:00
|
|
|
|
|
|
|
# Find the compiler.
|
2012-08-02 19:08:55 +04:00
|
|
|
_cmake_find_compiler(ASM${ASM_DIALECT})
|
2007-06-28 17:14:27 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2007-06-28 17:14:27 +04:00
|
|
|
|
2009-09-26 13:20:03 +04:00
|
|
|
# we only get here if CMAKE_ASM${ASM_DIALECT}_COMPILER was specified using -D or a pre-made CMakeCache.txt
|
2007-06-28 17:14:27 +04:00
|
|
|
# (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
|
|
|
|
#
|
2010-08-15 18:08:54 +04:00
|
|
|
# if a compiler was specified by the user but without path,
|
2007-06-28 17:14:27 +04:00
|
|
|
# now try to find it with the full path
|
2010-08-15 18:08:54 +04:00
|
|
|
# if it is found, force it into the cache,
|
2007-06-28 17:14:27 +04:00
|
|
|
# if not, don't overwrite the setting (which was given by the user) with "NOTFOUND"
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(_CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH)
|
|
|
|
if(NOT _CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH)
|
|
|
|
find_program(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER})
|
|
|
|
if(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH)
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER ${CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH} CACHE FILEPATH "Assembler" FORCE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2013-10-24 19:31:58 +04:00
|
|
|
unset(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH CACHE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
2007-06-28 17:14:27 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if (NOT _CMAKE_TOOLCHAIN_LOCATION)
|
|
|
|
get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2007-06-28 17:14:27 +04:00
|
|
|
|
2010-08-15 18:36:38 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
|
2010-08-15 18:36:38 +04:00
|
|
|
|
|
|
|
# Table of per-vendor compiler id flags with expected output.
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS GNU )
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_GNU "--version")
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "(GNU assembler)|(GCC)|(Free Software Foundation)")
|
2011-01-30 23:03:37 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS HP )
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_HP "-V")
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_HP "HP C")
|
2011-02-12 12:33:39 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS Intel )
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_Intel "--version")
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_Intel "(ICC)")
|
2011-01-30 23:14:53 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS SunPro )
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_SunPro "-V")
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_SunPro "Sun C")
|
2011-02-09 00:23:54 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS XL )
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_XL "-qversion")
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_XL "XL C")
|
2011-02-12 12:24:24 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS MSVC )
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_MSVC "/?")
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_MSVC "Microsoft")
|
2011-10-06 19:57:32 +04:00
|
|
|
|
2013-03-14 02:11:29 +04:00
|
|
|
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI )
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI "-h")
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI "Texas Instruments")
|
2010-08-15 18:36:38 +04:00
|
|
|
|
2013-04-11 00:41:15 +04:00
|
|
|
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS GNU IAR)
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_IAR )
|
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_IAR "IAR Assembler")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(CMakeDetermineCompilerId)
|
2010-08-15 18:36:38 +04:00
|
|
|
CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT})
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
2010-08-15 18:36:38 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
|
|
|
|
message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2011-03-02 00:58:26 +03:00
|
|
|
|
|
|
|
|
2010-08-15 18:36:38 +04:00
|
|
|
|
2010-08-15 18:08:54 +04:00
|
|
|
# If we have a gas/as cross compiler, they have usually some prefix, like
|
2011-01-26 22:52:34 +03:00
|
|
|
# e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas , optionally
|
|
|
|
# with a 3-component version number at the end
|
2008-05-15 20:07:43 +04:00
|
|
|
# The other tools of the toolchain usually have the same prefix
|
|
|
|
# NAME_WE cannot be used since then this test will fail for names lile
|
2010-08-15 18:08:54 +04:00
|
|
|
# "arm-unknown-nto-qnx6.3.0-gas.exe", where BASENAME would be
|
2008-05-15 20:07:43 +04:00
|
|
|
# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
|
2012-08-13 21:47:32 +04:00
|
|
|
if (NOT _CMAKE_TOOLCHAIN_PREFIX)
|
|
|
|
get_filename_component(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME)
|
|
|
|
if (COMPILER_BASENAME MATCHES "^(.+-)g?as(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
|
|
|
|
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2007-06-28 17:14:27 +04:00
|
|
|
|
2011-01-30 23:03:37 +03:00
|
|
|
# Now try the C compiler regexp:
|
2012-08-13 21:47:32 +04:00
|
|
|
if (NOT _CMAKE_TOOLCHAIN_PREFIX)
|
|
|
|
if (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
|
|
|
|
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2011-01-30 23:03:37 +03:00
|
|
|
|
|
|
|
# Finally try the CXX compiler regexp:
|
2012-08-13 21:47:32 +04:00
|
|
|
if (NOT _CMAKE_TOOLCHAIN_PREFIX)
|
|
|
|
if (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
|
|
|
|
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2011-01-30 23:03:37 +03:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(CMakeFindBinUtils)
|
2007-06-28 17:14:27 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR "ASM${ASM_DIALECT}")
|
2007-06-28 17:14:27 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
|
|
|
message(STATUS "Found assembler: ${CMAKE_ASM${ASM_DIALECT}_COMPILER}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "Didn't find assembler")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-06-28 17:14:27 +04:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_CMAKE_ASM_COMPILER "${CMAKE_ASM${ASM_DIALECT}_COMPILER}")
|
|
|
|
set(_CMAKE_ASM_COMPILER_ID "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}")
|
|
|
|
set(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}")
|
|
|
|
set(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}")
|
2007-06-28 17:14:27 +04:00
|
|
|
|
|
|
|
# configure variables set in this file for fast reload later on
|
2012-08-13 21:47:32 +04:00
|
|
|
configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in
|
2013-11-13 12:50:56 +04:00
|
|
|
${CMAKE_PLATFORM_INFO_DIR}/CMakeASM${ASM_DIALECT}Compiler.cmake @ONLY)
|
2007-06-28 17:14:27 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_CMAKE_ASM_COMPILER)
|
|
|
|
set(_CMAKE_ASM_COMPILER_ARG1)
|
|
|
|
set(_CMAKE_ASM_COMPILER_ENV_VAR)
|