diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py index d9ff559971f7..0df9cfcbca44 100644 --- a/mesonbuild/cmake/common.py +++ b/mesonbuild/cmake/common.py @@ -17,6 +17,7 @@ 'c': 'C', 'cpp': 'CXX', 'cuda': 'CUDA', + 'nasm': 'ASM_NASM', 'objc': 'OBJC', 'objcpp': 'OBJCXX', 'cs': 'CSharp', diff --git a/test cases/cmake/28 cmake nasm dependency/main.c b/test cases/cmake/28 cmake nasm dependency/main.c new file mode 100644 index 000000000000..5aef9670e4bc --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/main.c @@ -0,0 +1,18 @@ +#include +#include + +int32_t cmTestFunc(void); + +int main(void) +{ + if (cmTestFunc() > 4200) + { + printf("Test success.\n"); + return 0; + } + else + { + printf("Test failure.\n"); + return 1; + } +} diff --git a/test cases/cmake/28 cmake nasm dependency/meson.build b/test cases/cmake/28 cmake nasm dependency/meson.build new file mode 100644 index 000000000000..56780c711be1 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/meson.build @@ -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) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest.wrap b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest.wrap new file mode 100644 index 000000000000..1ea202e45ca1 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest.wrap @@ -0,0 +1,5 @@ +[wrap-file] +method = cmake + +[provide] +cmTest = cmTest_dep diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt new file mode 100644 index 000000000000..d7677828b7b2 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt @@ -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) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTest.c b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTest.c new file mode 100644 index 000000000000..e32415c94c9f --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTest.c @@ -0,0 +1,8 @@ +#include + +extern const int32_t cmTestArea; + +int32_t cmTestFunc(void) +{ + return cmTestArea; +} diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTestAsm.asm b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTestAsm.asm new file mode 100644 index 000000000000..ef386e181bfc --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTestAsm.asm @@ -0,0 +1,4 @@ +SECTION .rdata +GLOBAL cmTestArea +cmTestArea: + dd 4242 diff --git a/test cases/cmake/28 cmake nasm dependency/test.json b/test cases/cmake/28 cmake nasm dependency/test.json new file mode 100644 index 000000000000..791697089f4c --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/test.json @@ -0,0 +1,9 @@ +{ + "stdout": [ + { + "line": ".*CMake Toolchain: Failed to determine CMake compilers state.*", + "match": "re", + "count": 0 + } + ] + }