summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tests/Assembler/CMakeLists.txt22
-rw-r--r--Tests/Assembler/main-linux-x86-gas.s29
-rw-r--r--Tests/Assembler/main.c7
-rw-r--r--Tests/CMakeLists.txt1
4 files changed, 59 insertions, 0 deletions
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt
new file mode 100644
index 0000000000..e68393e1b3
--- /dev/null
+++ b/Tests/Assembler/CMakeLists.txt
@@ -0,0 +1,22 @@
+project(Assembler)
+
+set(SRCS)
+
+# if no file has been set as source and we are on linux with an x86 processor try to use the gas/as assembler
+if(NOT SRCS AND CMAKE_SYSTEM_NAME MATCHES Linux AND CMAKE_SYSTEM_PROCESSOR MATCHES "[ix].?86$")
+ message(STATUS "Trying to enable ASM-ATT for Linux/x86")
+ enable_language(ASM-ATT)
+ if(CMAKE_ASM-ATT_COMPILER_WORKS)
+ message(STATUS "Trying to enable ASM-ATT for Linux/x86 - succeeded")
+ # this assembler file was created using gcc -S main.c
+ set(SRCS main-linux-x86-gas.s)
+ endif(CMAKE_ASM-ATT_COMPILER_WORKS)
+endif(NOT SRCS AND CMAKE_SYSTEM_NAME MATCHES Linux AND CMAKE_SYSTEM_PROCESSOR MATCHES "[ix].?86$")
+
+if(NOT SRCS)
+ message(STATUS "No assembler enabled, using C")
+ set(SRCS main.c)
+endif(NOT SRCS)
+
+add_executable(HelloAsm ${SRCS})
+set_target_properties(HelloAsm PROPERTIES LINKER_LANGUAGE C)
diff --git a/Tests/Assembler/main-linux-x86-gas.s b/Tests/Assembler/main-linux-x86-gas.s
new file mode 100644
index 0000000000..9e260a306c
--- /dev/null
+++ b/Tests/Assembler/main-linux-x86-gas.s
@@ -0,0 +1,29 @@
+ .file "main.c"
+ .section .rodata
+ .align 4
+.LC0:
+ .string "hello assembler world, %d arguments given\n"
+ .text
+.globl main
+ .type main, @function
+main:
+ leal 4(%esp), %ecx
+ andl $-16, %esp
+ pushl -4(%ecx)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %ecx
+ subl $20, %esp
+ movl (%ecx), %eax
+ movl %eax, 4(%esp)
+ movl $.LC0, (%esp)
+ call printf
+ movl $0, %eax
+ addl $20, %esp
+ popl %ecx
+ popl %ebp
+ leal -4(%ecx), %esp
+ ret
+ .size main, .-main
+ .ident "GCC: (GNU) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/Tests/Assembler/main.c b/Tests/Assembler/main.c
new file mode 100644
index 0000000000..3704ad0576
--- /dev/null
+++ b/Tests/Assembler/main.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ printf("hello assembler world, %d arguments given\n", argc);
+ return 0;
+}
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 96ee5a9f11..dd39fdbedc 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -47,6 +47,7 @@ IF(BUILD_TESTING)
ADD_TEST_MACRO(MacroTest miniMacroTest)
ADD_TEST_MACRO(Framework bar)
ADD_TEST_MACRO(Properties Properties)
+ ADD_TEST_MACRO(Assembler HelloAsm)
# add tests with more complex invocations
ADD_TEST(TargetName ${CMAKE_CTEST_COMMAND}