summaryrefslogtreecommitdiff
path: root/Tests/Assembler
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-10-30 15:39:57 -0700
committerAnas Nashif <anas.nashif@intel.com>2012-10-30 15:39:57 -0700
commit035c7fabc3b82cbc9a346c11abe2e9462b4c0379 (patch)
tree7e40f5a790eae329a8c5d3e59f046451767956ff /Tests/Assembler
downloadcmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.tar.gz
cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.tar.bz2
cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.zip
Imported Upstream version 2.8.9upstream/2.8.9
Diffstat (limited to 'Tests/Assembler')
-rw-r--r--Tests/Assembler/CMakeLists.txt33
-rw-r--r--Tests/Assembler/main-linux-x86-gas.s28
-rw-r--r--Tests/Assembler/main.c12
3 files changed, 73 insertions, 0 deletions
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt
new file mode 100644
index 000000000..456e4961f
--- /dev/null
+++ b/Tests/Assembler/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required (VERSION 2.6)
+project(Assembler C)
+message("CTEST_FULL_OUTPUT ")
+set(CMAKE_VERBOSE_MAKEFILE 1)
+
+set(SRCS)
+
+# (at least) the following toolchains can process assembler files directly
+# and also generate assembler files from C:
+if("${CMAKE_GENERATOR}" MATCHES "Makefile")
+ if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX))
+ set(C_FLAGS "${CMAKE_C_FLAGS}")
+ separate_arguments(C_FLAGS)
+ set(SRCS main.s)
+ add_custom_command(
+ OUTPUT main.s
+ COMMAND ${CMAKE_C_COMPILER} ${C_FLAGS} -S ${CMAKE_CURRENT_SOURCE_DIR}/main.c -o main.s
+ DEPENDS main.c
+ VERBATIM
+ )
+ endif(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX))
+endif("${CMAKE_GENERATOR}" MATCHES "Makefile")
+
+
+if(SRCS)
+ set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}")
+ enable_language(ASM OPTIONAL)
+else(SRCS)
+ message(STATUS "No assembler enabled, using C")
+ set(SRCS main.c)
+endif(SRCS)
+
+add_executable(HelloAsm ${SRCS})
diff --git a/Tests/Assembler/main-linux-x86-gas.s b/Tests/Assembler/main-linux-x86-gas.s
new file mode 100644
index 000000000..da8e84591
--- /dev/null
+++ b/Tests/Assembler/main-linux-x86-gas.s
@@ -0,0 +1,28 @@
+ .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 000000000..95de0b5d1
--- /dev/null
+++ b/Tests/Assembler/main.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+#ifdef __CLASSIC_C__
+int main(){
+ int argc;
+ char*argv[];
+#else
+int main(int argc, char*argv[]){
+#endif
+ printf("hello assembler world, %d arguments given\n", argc);
+ return 0;
+}