summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2011-01-30 20:03:37 (GMT)
committerAlex Neundorf <neundorf@kde.org>2011-01-30 20:03:37 (GMT)
commit4b40d4297aa7b984e9b5fa905cdee21960ec4f8a (patch)
treee880f1e36a8245ac9e6c82a0f96258f5c8a3cca2 /Modules
parent9c30d3d230229dbd791bcaf1b57e5bc23350cb30 (diff)
downloadCMake-4b40d4297aa7b984e9b5fa905cdee21960ec4f8a.zip
CMake-4b40d4297aa7b984e9b5fa905cdee21960ec4f8a.tar.gz
CMake-4b40d4297aa7b984e9b5fa905cdee21960ec4f8a.tar.bz2
Rework the way assembler is handled, use the C/CXX compiler by default
This commit changes the way how the assembler support works in cmake. The language "ASM" now always uses the C/Cxx compiler instead of the assembler directly. This fixes #8392, assembler files are not preprocessed. If one wants to use the assembler directly, the specific assembler "dialect" has to be enabled. I.e. to get as/gas, you have to use now ASM-ATT, the same way for ASM_MASM and ASM_NASM. Implemented this now for gcc. SunStudio, IBM, HP and Intel still todo. Alex
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeASMCompiler.cmake.in1
-rw-r--r--Modules/CMakeASMInformation.cmake3
-rw-r--r--Modules/CMakeDetermineASMCompiler.cmake57
-rw-r--r--Modules/Compiler/GNU-ASM.cmake8
4 files changed, 62 insertions, 7 deletions
diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in
index 230805b..2dc24b0 100644
--- a/Modules/CMakeASMCompiler.cmake.in
+++ b/Modules/CMakeASMCompiler.cmake.in
@@ -4,6 +4,7 @@ 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_ID "@_CMAKE_ASM_COMPILER_ID@")
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)
diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake
index b94303e..f86595c 100644
--- a/Modules/CMakeASMInformation.cmake
+++ b/Modules/CMakeASMInformation.cmake
@@ -34,6 +34,9 @@ IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
INCLUDE(Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
IF(NOT _INCLUDED_FILE)
+ IF("ASM${ASM_DIALECT}" STREQUAL "ASM")
+ MESSAGE(FATAL_ERROR "Did not find file Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}")
+ ENDIF("ASM${ASM_DIALECT}" STREQUAL "ASM")
INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL)
ENDIF(NOT _INCLUDED_FILE)
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake
index d6350bf..3346358 100644
--- a/Modules/CMakeDetermineASMCompiler.cmake
+++ b/Modules/CMakeDetermineASMCompiler.cmake
@@ -21,11 +21,37 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
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)
+ IF("ASM${ASM_DIALECT}" STREQUAL "ASM") # the generic assembler support
+
+ IF(CMAKE_ASM_COMPILER_INIT)
+ SET(CMAKE_ASM_COMPILER_LIST ${CMAKE_ASM_COMPILER_INIT})
+ ELSE(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}")
+ ELSIF("${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("${CMAKE_CXX_COMPILER}")
+ # List all default C and CXX compilers
+ SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl bcc xlc
+ ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ CC aCC cl bcc xlC)
+ ENDIF("${CMAKE_C_COMPILER}")
+
+ ENDIF(CMAKE_ASM_COMPILER_INIT)
+
+
+ ELSE("ASM${ASM_DIALECT}" STREQUAL "ASM") # some specific assembler "dialect"
+
+ 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)
+ MESSAGE(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT must be preset !")
+ ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
+
+ ENDIF("ASM${ASM_DIALECT}" STREQUAL "ASM")
+
# Find the compiler.
IF (_CMAKE_USER_CXX_COMPILER_PATH OR _CMAKE_USER_C_COMPILER_PATH)
@@ -63,7 +89,8 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
# Table of per-vendor compiler id flags with expected output.
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")
+ SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "(GNU assembler)|(GCC)")
+
LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI_DSP )
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI_DSP "-h")
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI_DSP "Texas Instruments")
@@ -90,10 +117,25 @@ ENDIF()
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)?$")
- STRING(REGEX REPLACE "^(.+-)g?as(\\.exe)?$" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
+ SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
+# Now try the C compiler regexp:
+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})
+ ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
+ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
+
+# Finally try the CXX compiler regexp:
+IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
+ IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
+ SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
+ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
+
+
INCLUDE(CMakeFindBinUtils)
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR "ASM${ASM_DIALECT}")
@@ -106,6 +148,7 @@ ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER)
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}")
diff --git a/Modules/Compiler/GNU-ASM.cmake b/Modules/Compiler/GNU-ASM.cmake
new file mode 100644
index 0000000..93ef724
--- /dev/null
+++ b/Modules/Compiler/GNU-ASM.cmake
@@ -0,0 +1,8 @@
+# This file is loaded when gcc/g++ is used for assembler files (the "ASM" cmake language)
+include(Compiler/GNU)
+
+set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm)
+
+set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+
+__compiler_gnu(ASM)