Skip to content

Commit

Permalink
Add a test case triggering warning after adding nasm language
Browse files Browse the repository at this point in the history
  • Loading branch information
res2k committed Nov 9, 2024
1 parent e42efc2 commit 2833865
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 0 deletions.
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;
}
}
21 changes: 21 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,21 @@
project('cmake nasm dependency', ['c', 'cpp'])

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

# This test aims to trigger CMakeToolchain.update_cmake_compiler_state() _twice_,
# as the 2nd CMake compilers state update resulted in a warning
# "Failed to determine CMake compilers state" after nasm was added as a language.

# First dependency triggers initial compilers state update
sub_dep_1 = dependency('cmTest1')
# Add nasm as a language..
add_languages('nasm', required: true, native: false)
# ...and check for 2nd dependency. Together with cmake_skip_compiler_test = 'always',
# this triggers another CMake compilers state update, this time with nasm
# in the mix
sub_dep_2 = dependency('cmTest2')

exe1 = executable('exe1', ['main.c'], dependencies: [sub_dep_1, sub_dep_2])
test('test1', exe1)
2 changes: 2 additions & 0 deletions test cases/cmake/28 cmake nasm dependency/nativefile.ini.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[properties]
cmake_skip_compiler_test = 'always'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[wrap-file]
method = cmake

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

project(cmTest1)

add_library(cmTest1 STATIC cmTest.c)
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 cmTestArea;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[wrap-file]
method = cmake

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

project(cmTest2)

#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(cmTest2 STATIC cmTestAsm.asm)
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
}
]
}

0 comments on commit 2833865

Please sign in to comment.