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..f70d3562804c --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/meson.build @@ -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) diff --git a/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in b/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in new file mode 100644 index 000000000000..ca40a3d76ace --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in @@ -0,0 +1,2 @@ +[properties] +cmake_skip_compiler_test = 'always' diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap new file mode 100644 index 000000000000..babfb6c07300 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap @@ -0,0 +1,5 @@ +[wrap-file] +method = cmake + +[provide] +cmTest1 = cmTest1_dep diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt new file mode 100644 index 000000000000..42f16f84e798 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) + +project(cmTest1) + +add_library(cmTest1 STATIC cmTest.c) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/cmTest.c b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/cmTest.c new file mode 100644 index 000000000000..e32415c94c9f --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/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/cmTest2.wrap b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap new file mode 100644 index 000000000000..a0ed381ae7a6 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap @@ -0,0 +1,5 @@ +[wrap-file] +method = cmake + +[provide] +cmTest2 = cmTest2_dep diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt new file mode 100644 index 000000000000..45a56cc5723a --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt @@ -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) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/cmTestAsm.asm b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/cmTestAsm.asm new file mode 100644 index 000000000000..ef386e181bfc --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/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 + } + ] + }