Tests/RunCMake/Emscripten: Add tests covering try_compile COPY_FILE

Compiler inspection relies on `try_compile`'s `COPY_FILE` option to copy
the `.wasm` file because the `.js` does not have the `INFO:size` string.

Issue: #27421
This commit is contained in:
Brad King
2025-11-25 11:43:11 -05:00
parent 7287032be2
commit 27cc5d58bf
5 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
-- SIZEOF_INT='[1-9][0-9]*'
-- HAVE_SIZEOF_INT='TRUE'

View File

@@ -0,0 +1,6 @@
enable_language(C)
include(CheckTypeSize)
check_type_size(int SIZEOF_INT)
message(STATUS "SIZEOF_INT='${SIZEOF_INT}'")
message(STATUS "HAVE_SIZEOF_INT='${HAVE_SIZEOF_INT}'")

View File

@@ -0,0 +1,2 @@
-- CMAKE_C_BYTE_ORDER='LITTLE_ENDIAN'
-- CMAKE_C_SIZEOF_DATA_PTR='[1-9][0-9]*'

View File

@@ -0,0 +1,7 @@
enable_language(C)
foreach(var IN ITEMS
CMAKE_C_BYTE_ORDER
CMAKE_C_SIZEOF_DATA_PTR
)
message(STATUS "${var}='${${var}}'")
endforeach()

View File

@@ -40,6 +40,12 @@ foreach(_emscripten_toolchain IN LISTS _emscripten_toolchains)
set(cxx_comp ${BIN_DIR}/em++${EMCC_SUFFIX})
set(comp_ar ${BIN_DIR}/emar${EMCC_SUFFIX})
# Compiler inspection.
run_cmake_with_options(C-enable
-DCMAKE_SYSTEM_NAME=Emscripten
-DCMAKE_C_COMPILER=${c_comp}
)
# Create an executable from .c sources only.
run_toolchain(C-exe
-DCMAKE_SYSTEM_NAME=Emscripten
@@ -76,4 +82,9 @@ foreach(_emscripten_toolchain IN LISTS _emscripten_toolchains)
)
run_cmake_target(C-WHOLE_ARCHIVE link-exe main)
run_cmake_target(C-WHOLE_ARCHIVE circular-exe main_circular)
run_cmake_with_options(C-CheckTypeSize
-DCMAKE_SYSTEM_NAME=Emscripten
-DCMAKE_C_COMPILER=${c_comp}
)
endforeach()