mirror of
https://github.com/reactos/CMake.git
synced 2024-11-23 19:49:51 +00:00
ENH: initial support for assembler in cmake, needs testing by our users
Alex
This commit is contained in:
parent
43de8c8628
commit
5b18b80b58
4
Modules/CMakeASM-ATTInformation.cmake
Normal file
4
Modules/CMakeASM-ATTInformation.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
SET(ASM_DIALECT "-ATT")
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS s;S;asm)
|
||||
INCLUDE(CMakeASMInformation)
|
||||
SET(ASM_DIALECT)
|
11
Modules/CMakeASMCompiler.cmake.in
Normal file
11
Modules/CMakeASMCompiler.cmake.in
Normal file
@ -0,0 +1,11 @@
|
||||
SET(CMAKE_ASM@ASM_DIALECT@_COMPILER "@_CMAKE_ASM_COMPILER@")
|
||||
SET(CMAKE_ASM@ASM_DIALECT@_COMPILER_ARG1 "@_CMAKE_ASM_COMPILER_ARG1@")
|
||||
SET(CMAKE_AR "@CMAKE_AR@")
|
||||
SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
|
||||
SET(CMAKE_LINKER "@CMAKE_LINKER@")
|
||||
SET(CMAKE_ASM@ASM_DIALECT@_COMPILER_LOADED 1)
|
||||
SET(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@")
|
||||
|
||||
SET(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
SET(CMAKE_ASM@ASM_DIALECT@_LINKER_PREFERENCE None)
|
||||
|
62
Modules/CMakeASMInformation.cmake
Normal file
62
Modules/CMakeASMInformation.cmake
Normal file
@ -0,0 +1,62 @@
|
||||
MESSAGE(STATUS "Loaded CMakeASM${ASM_DIALECT}Information - ASM${ASM_DIALECT} support is still experimental, please report issues")
|
||||
|
||||
IF(UNIX)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_OUTPUT_EXTENSION .o)
|
||||
ELSE(UNIX)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_OUTPUT_EXTENSION .obj)
|
||||
ENDIF(UNIX)
|
||||
|
||||
|
||||
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME_WE)
|
||||
|
||||
IF("${CMAKE_BASE_NAME}" STREQUAL "as")
|
||||
SET(CMAKE_BASE_NAME gas)
|
||||
ENDIF("${CMAKE_BASE_NAME}" STREQUAL "as")
|
||||
|
||||
INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL)
|
||||
|
||||
IF(CMAKE_SYSTEM_AND_ASM${ASM_DIALECT}_COMPILER_AND_PROCESSOR_INFO_FILE)
|
||||
INCLUDE(${CMAKE_SYSTEM_AND_ASM${ASM_DIALECT}_COMPILER_AND_PROCESSOR_INFO_FILE} OPTIONAL)
|
||||
ELSE(CMAKE_SYSTEM_AND_ASM${ASM_DIALECT}_COMPILER_AND_PROCESSOR_INFO_FILE)
|
||||
IF(CMAKE_SYSTEM_PROCESSOR)
|
||||
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
|
||||
ENDIF(CMAKE_SYSTEM_PROCESSOR)
|
||||
ENDIF(CMAKE_SYSTEM_AND_ASM${ASM_DIALECT}_COMPILER_AND_PROCESSOR_INFO_FILE)
|
||||
|
||||
IF(CMAKE_SYSTEM_AND_ASM${ASM_DIALECT}_COMPILER_INFO_FILE)
|
||||
INCLUDE(${CMAKE_SYSTEM_AND_ASM${ASM_DIALECT}_COMPILER_INFO_FILE} OPTIONAL)
|
||||
ELSE(CMAKE_SYSTEM_AND_ASM${ASM_DIALECT}_COMPILER_INFO_FILE)
|
||||
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
|
||||
ENDIF(CMAKE_SYSTEM_AND_ASM${ASM_DIALECT}_COMPILER_INFO_FILE)
|
||||
|
||||
IF(NOT CMAKE_ASM@ASM_DIALECT@_SOURCE_FILE_EXTENSIONS)
|
||||
SET(CMAKE_ASM@ASM_DIALECT@_SOURCE_FILE_EXTENSIONS s;S;asm)
|
||||
ENDIF(NOT CMAKE_ASM@ASM_DIALECT@_SOURCE_FILE_EXTENSIONS)
|
||||
|
||||
IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> -o <OBJECT> <SOURCE>")
|
||||
ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT)
|
||||
|
||||
IF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY
|
||||
"<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS> "
|
||||
"<CMAKE_RANLIB> <TARGET> ")
|
||||
ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY)
|
||||
|
||||
IF(NOT CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE
|
||||
"<CMAKE_LINKER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE)
|
||||
|
||||
# to be done
|
||||
IF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY)
|
||||
ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY)
|
||||
|
||||
IF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_MODULE)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_MODULE)
|
||||
ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_MODULE)
|
||||
|
||||
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_INFOMATION_LOADED 1)
|
||||
|
6
Modules/CMakeDetermineASM-ATTCompiler.cmake
Normal file
6
Modules/CMakeDetermineASM-ATTCompiler.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
# determine the compiler to use for ASM using AT&T syntax
|
||||
|
||||
SET(ASM_DIALECT "-ATT")
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ${_CMAKE_TOOLCHAIN_PREFIX}gas ${_CMAKE_TOOLCHAIN_PREFIX}as)
|
||||
INCLUDE(CMakeDetermineASMCompiler)
|
||||
SET(ASM_DIALECT)
|
78
Modules/CMakeDetermineASMCompiler.cmake
Normal file
78
Modules/CMakeDetermineASMCompiler.cmake
Normal file
@ -0,0 +1,78 @@
|
||||
# determine the compiler to use for ASM programs
|
||||
|
||||
IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
# prefer the environment variable ASM
|
||||
IF($ENV{ASM${ASM_DIALECT}} MATCHES ".+")
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT "$ENV{ASM${ASM_DIALECT}}")
|
||||
ENDIF($ENV{ASM${ASM_DIALECT}} MATCHES ".+")
|
||||
|
||||
# finally list compilers to try
|
||||
IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT})
|
||||
ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}as ${_CMAKE_TOOLCHAIN_PREFIX}gas)
|
||||
ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
|
||||
|
||||
# Find the compiler.
|
||||
IF (_CMAKE_USER_CXX_COMPILER_PATH OR _CMAKE_USER_C_COMPILER_PATH)
|
||||
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)
|
||||
ENDIF (_CMAKE_USER_CXX_COMPILER_PATH OR _CMAKE_USER_C_COMPILER_PATH)
|
||||
FIND_PROGRAM(CMAKE_ASM${ASM_DIALECT}_COMPILER NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST} DOC "Assembler")
|
||||
|
||||
ELSE(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
|
||||
# we only get here if CMAKE_C_COMPILER was specified using -D or a pre-made CMakeCache.txt
|
||||
# (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
|
||||
#
|
||||
# if a compiler was specified by the user but without path,
|
||||
# now try to find it with the full path
|
||||
# if it is found, force it into the cache,
|
||||
# if not, don't overwrite the setting (which was given by the user) with "NOTFOUND"
|
||||
# if the C compiler already had a path, reuse it for searching the CXX compiler
|
||||
GET_FILENAME_COMPONENT(_CMAKE_USER_ASM_COMPILER_PATH "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH)
|
||||
IF(NOT _CMAKE_USER_ASM_COMPILER_PATH)
|
||||
FIND_PROGRAM(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER})
|
||||
MARK_AS_ADVANCED(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH)
|
||||
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)
|
||||
ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH)
|
||||
ENDIF(NOT _CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH)
|
||||
ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
MARK_AS_ADVANCED(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
|
||||
IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
|
||||
GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH)
|
||||
ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION)
|
||||
|
||||
# if we have a gcc cross compiler, they have usually some prefix, like
|
||||
# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc
|
||||
# the other tools of the toolchain usually have the same prefix
|
||||
IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
|
||||
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME_WE)
|
||||
IF (COMPILER_BASENAME MATCHES "^(.+-)g?as")
|
||||
STRING(REGEX REPLACE "^(.+-)g?as" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
|
||||
ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as")
|
||||
ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
|
||||
|
||||
INCLUDE(CMakeFindBinUtils)
|
||||
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR "ASM")
|
||||
|
||||
IF(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
MESSAGE(STATUS "Found assembler: ${CMAKE_ASM${ASM_DIALECT}_COMPILER}")
|
||||
ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
MESSAGE(STATUS "Didn't find assembler")
|
||||
ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
|
||||
|
||||
SET(_CMAKE_ASM_COMPILER "${CMAKE_ASM${ASM_DIALECT}_COMPILER}")
|
||||
SET(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}")
|
||||
SET(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}")
|
||||
|
||||
# configure variables set in this file for fast reload later on
|
||||
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeASM${ASM_DIALECT}Compiler.cmake IMMEDIATE @ONLY)
|
||||
|
||||
SET(_CMAKE_ASM_COMPILER)
|
||||
SET(_CMAKE_ASM_COMPILER_ARG1)
|
||||
SET(_CMAKE_ASM_COMPILER_ENV_VAR)
|
9
Modules/CMakeTestASM-ATTCompiler.cmake
Normal file
9
Modules/CMakeTestASM-ATTCompiler.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
# This file is used by EnableLanguage in cmGlobalGenerator to
|
||||
# determine that that selected ASM-ATT compiler can actually compile
|
||||
# and link the most basic of programs. If not, a fatal error
|
||||
# is set and cmake stops processing commands and will not generate
|
||||
# any makefiles or projects.
|
||||
SET(ASM_DIALECT "-ATT")
|
||||
INCLUDE(CMakeTestASMCompiler)
|
||||
SET(ASM_DIALECT)
|
11
Modules/CMakeTestASMCompiler.cmake
Normal file
11
Modules/CMakeTestASMCompiler.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
# This file is used by EnableLanguage in cmGlobalGenerator to
|
||||
# determine that that selected ASM compiler can actually compile
|
||||
# and link the most basic of programs. If not, a fatal error
|
||||
# is set and cmake stops processing commands and will not generate
|
||||
# any makefiles or projects.
|
||||
IF(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS 1 CACHE INTERNAL "")
|
||||
ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS 0 CACHE INTERNAL "")
|
||||
ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER)
|
19
Modules/Platform/gas.cmake
Normal file
19
Modules/Platform/gas.cmake
Normal file
@ -0,0 +1,19 @@
|
||||
IF(UNIX)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_OUTPUT_EXTENSION .o)
|
||||
ELSE(UNIX)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_OUTPUT_EXTENSION .obj)
|
||||
ENDIF(UNIX)
|
||||
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> -o <OBJECT> <SOURCE>")
|
||||
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY
|
||||
"<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS> "
|
||||
"<CMAKE_RANLIB> <TARGET> ")
|
||||
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE
|
||||
"<CMAKE_LINKER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
|
||||
# to be done
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY)
|
||||
SET(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_MODULE)
|
||||
|
Loading…
Reference in New Issue
Block a user