2026-06-14 21:47:56 +03:00
|
|
|
cmake_minimum_required(VERSION 3.18) # find_program(... REQUIRED)
|
|
|
|
|
project(w32ms C)
|
|
|
|
|
|
|
|
|
|
set(CMAKE_C_STANDARD 17) # generation B uses no C23 feature
|
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
|
set(CMAKE_C_EXTENSIONS ON) # deliberate: strnlen (POSIX) + void* arithmetic (GNU)
|
|
|
|
|
|
2026-06-15 00:58:27 +03:00
|
|
|
option(W32MS_LTO "Enable LTO" OFF) # build-only; shipped default is -O2, no LTO
|
|
|
|
|
|
2026-06-14 21:47:56 +03:00
|
|
|
# ---- host: VMI core as a static library ---------------------------------
|
|
|
|
|
add_library(w32ms STATIC
|
|
|
|
|
src/gpa.c
|
|
|
|
|
src/gva.c
|
|
|
|
|
src/host.c
|
|
|
|
|
src/proc.c
|
|
|
|
|
src/profile.c
|
|
|
|
|
src/text.c
|
|
|
|
|
src/scan.c
|
|
|
|
|
src/sigscan.c)
|
|
|
|
|
target_include_directories(w32ms
|
|
|
|
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include # public API: include/*.h
|
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) # private: src/include/*.h via "include/..."
|
|
|
|
|
target_compile_options(w32ms PRIVATE -O2 -Wall -Wextra)
|
2026-06-15 00:58:27 +03:00
|
|
|
if(W32MS_LTO)
|
|
|
|
|
target_compile_options(w32ms PRIVATE -flto)
|
|
|
|
|
target_link_options(w32ms PRIVATE -flto)
|
|
|
|
|
endif()
|
2026-06-14 21:47:56 +03:00
|
|
|
|
|
|
|
|
# ---- host: CLI demonstrator over the library ----------------------------
|
|
|
|
|
add_executable(w32ms_cli src/cli.c)
|
|
|
|
|
target_link_libraries(w32ms_cli PRIVATE w32ms)
|
|
|
|
|
target_compile_options(w32ms_cli PRIVATE -Wall -Wextra)
|
|
|
|
|
|
|
|
|
|
# ---- guest: cross-compile to Windows x86-64 via mingw-w64 ---------------
|
|
|
|
|
find_program(MINGW_CC NAMES x86_64-w64-mingw32-gcc REQUIRED)
|
|
|
|
|
set(W32MS_GUEST ${CMAKE_CURRENT_BINARY_DIR}/w32ms_guest.exe)
|
|
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT ${W32MS_GUEST}
|
|
|
|
|
COMMAND ${MINGW_CC} -O2 -Wall -Wextra -static -s
|
|
|
|
|
-I${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
|
|
|
-o ${W32MS_GUEST} ${CMAKE_CURRENT_SOURCE_DIR}/src/guest.c
|
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/guest.c
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/include/contract.h
|
|
|
|
|
COMMENT "Cross-compiling w32ms_guest.exe (mingw-w64, x86-64)"
|
|
|
|
|
VERBATIM)
|
|
|
|
|
add_custom_target(w32ms_guest ALL DEPENDS ${W32MS_GUEST})
|