parent
e8e03cdc72
commit
ee240b60b8
5 changed files with 84 additions and 0 deletions
@ -0,0 +1,18 @@ |
||||
#include <stdint.h> |
||||
#include <stdio.h> |
||||
|
||||
int32_t cmTestFunc(); |
||||
|
||||
int main(int argc, char* argv[]) |
||||
{ |
||||
if (cmTestFunc() > 4200) |
||||
{ |
||||
printf("Test success.\n"); |
||||
return 0; |
||||
} |
||||
else |
||||
{ |
||||
printf("Test failure.\n"); |
||||
return 1; |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
project('assembler test', ['c']) |
||||
|
||||
cm = import('cmake') |
||||
|
||||
sub_pro = cm.subproject('cmTest') |
||||
sub_dep = sub_pro.dependency('cmTest') |
||||
|
||||
exe1 = executable('exe1', ['main.c'], dependencies: [sub_dep]) |
||||
test('test1', exe1) |
@ -0,0 +1,45 @@ |
||||
cmake_minimum_required(VERSION 3.5) |
||||
|
||||
project(cmTest) |
||||
|
||||
#Detect processor |
||||
if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "amd64") |
||||
SET(TEST_PROCESSOR "x86_64") |
||||
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") |
||||
SET(TEST_PROCESSOR "x86_64") |
||||
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "i386") |
||||
SET(TEST_PROCESSOR "x86") |
||||
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "i686") |
||||
SET(TEST_PROCESSOR "x86") |
||||
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm") |
||||
SET(TEST_PROCESSOR "arm") |
||||
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64") |
||||
SET(TEST_PROCESSOR "arm") |
||||
else () |
||||
message(FATAL_ERROR, 'MESON_SKIP_TEST: Unsupported Assembler Platform') |
||||
endif () |
||||
|
||||
#Detect ABI |
||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") |
||||
SET(TEST_ABI "sysv") |
||||
elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") |
||||
SET(TEST_ABI "sysv") |
||||
elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "NetBSD") |
||||
SET(TEST_ABI "sysv") |
||||
elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD") |
||||
SET(TEST_ABI "sysv") |
||||
else () |
||||
message(FATAL_ERROR, 'MESON_SKIP_TEST: Unsupported Assembler Platform') |
||||
endif () |
||||
|
||||
SET(TEST_PLATFORM "${TEST_PROCESSOR}-${TEST_ABI}") |
||||
|
||||
if ( ("${TEST_PLATFORM}" MATCHES "x86_64-sysv") |
||||
OR ("${TEST_PLATFORM}" MATCHES "x86-sysv") |
||||
OR ("${TEST_PLATFORM}" MATCHES "arm-sysv")) |
||||
SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) |
||||
enable_language(ASM) |
||||
SET(TEST_SOURCE "cmTestAsm.s") |
||||
endif () |
||||
|
||||
add_library(cmTest STATIC cmTest.c ${TEST_SOURCE}) |
@ -0,0 +1,8 @@ |
||||
#include <stdint.h> |
||||
|
||||
extern const int32_t cmTestArea; |
||||
|
||||
int32_t cmTestFunc() |
||||
{ |
||||
return cmTestArea; |
||||
} |
@ -0,0 +1,4 @@ |
||||
.text |
||||
.globl cmTestArea
|
||||
cmTestArea: |
||||
.long 4242
|
Loading…
Reference in new issue