Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake/common: Add language map entry for nasm #13864

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mesonbuild/cmake/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'c': 'C',
'cpp': 'CXX',
'cuda': 'CUDA',
'nasm': 'ASM_NASM',
'objc': 'OBJC',
'objcpp': 'OBJCXX',
'cs': 'CSharp',
Expand Down
18 changes: 18 additions & 0 deletions test cases/cmake/28 cmake nasm dependency/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdint.h>
#include <stdio.h>

int32_t cmTestFunc(void);

int main(void)
{
if (cmTestFunc() > 4200)
{
printf("Test success.\n");
return 0;
}
else
{
printf("Test failure.\n");
return 1;
}
}
17 changes: 17 additions & 0 deletions test cases/cmake/28 cmake nasm dependency/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
project('cmake nasm dependency', ['c', 'cpp'])

if get_option('backend').startswith('vs')
error('MESON_SKIP_TEST: nasm is not supported by vs backend')
endif

if not add_languages('nasm', required: false, native: false)
error('MESON_SKIP_TEST: nasm not found')
endif

# Using this dependency triggers CMakeToolchain.update_cmake_compiler_state(),
# and with nasm as a language, resulted in a warning
# "Failed to determine CMake compilers state" after nasm was added as a language.
sub_dep = dependency('cmTest')

exe1 = executable('exe1', ['main.c'], dependencies: [sub_dep])
test('test1', exe1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[wrap-file]
method = cmake

[provide]
cmTest = cmTest_dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION ${CMAKE_VERSION})

project(cmTest)

#Detect processor
if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Mm][Dd]64")
SET(TEST_PROCESSOR "x86_64")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Xx]86_64")
SET(TEST_PROCESSOR "x86_64")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Ii]386")
SET(TEST_PROCESSOR "x86")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Ii]686")
SET(TEST_PROCESSOR "x86")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Rr][Mm]")
SET(TEST_PROCESSOR "arm")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Aa][Rr][Cc][Hh]64")
SET(TEST_PROCESSOR "arm")
else ()
message(FATAL_ERROR "MESON_SKIP_TEST: Unsupported Assembler Platform ${CMAKE_SYSTEM_PROCESSOR}")
endif ()

enable_language(ASM_NASM)

add_library(cmTest STATIC cmTest.c cmTestAsm.asm)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdint.h>

extern const int32_t cmTestArea;

int32_t cmTestFunc(void)
{
return 4242/*cmTestArea*/;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SECTION .rdata
GLOBAL cmTestArea
cmTestArea:
dd 4242
9 changes: 9 additions & 0 deletions test cases/cmake/28 cmake nasm dependency/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"stdout": [
{
"line": ".*CMake Toolchain: Failed to determine CMake compilers state.*",
"match": "re",
"count": 0
}
]
}
Loading