[CMAKE] Support WITH_DBG and NO_DBG overrides in spec2def

This is to be able to build ucrtbase without debug and later ucrtbased with debug.
This commit is contained in:
Timo Kreuzer 2025-01-27 13:51:05 +02:00
parent 01cd8472c7
commit 6a4dbedd1e
2 changed files with 19 additions and 20 deletions

View file

@ -431,16 +431,11 @@ function(fixup_load_config _target)
DEPENDS native-pefixup)
endfunction()
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(__spec2def_dbg_arg "--dbg")
endif()
function(generate_import_lib _libname _dllname _spec_file __version_arg)
function(generate_import_lib _libname _dllname _spec_file __version_arg __dbg_arg)
# Generate the def for the import lib
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def
COMMAND native-spec2def ${__version_arg} ${__spec2def_dbg_arg} -n=${_dllname} -a=${ARCH2} ${ARGN} --implib -d=${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
COMMAND native-spec2def ${__version_arg} ${__dbg_arg} -n=${_dllname} -a=${ARCH2} ${ARGN} --implib -d=${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
# With this, we let DLLTOOL create an import library
@ -490,7 +485,7 @@ endfunction()
function(spec2def _dllname _spec_file)
cmake_parse_arguments(__spec2def "ADD_IMPORTLIB;NO_PRIVATE_WARNINGS;WITH_RELAY" "VERSION" "" ${ARGN})
cmake_parse_arguments(__spec2def "ADD_IMPORTLIB;NO_PRIVATE_WARNINGS;WITH_RELAY;WITH_DBG;NO_DBG" "VERSION" "" ${ARGN})
# Get library basename
get_filename_component(_file ${_dllname} NAME_WE)
@ -510,10 +505,14 @@ function(spec2def _dllname _spec_file)
set(__version_arg "--version=${DLL_EXPORT_VERSION}")
endif()
if(__spec2def_WITH_DBG OR (DBG AND NOT __spec2def_NO_DBG))
set(__dbg_arg "--dbg")
endif()
# Generate exports def and C stubs file for the DLL
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c
COMMAND native-spec2def -n=${_dllname} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${__with_relay_arg} ${__version_arg} ${__spec2def_dbg_arg} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
COMMAND native-spec2def -n=${_dllname} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${__with_relay_arg} ${__version_arg} ${__dbg_arg} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
# Do not use precompiled headers for the stub file
@ -525,7 +524,7 @@ function(spec2def _dllname _spec_file)
set(_extraflags --no-private-warnings)
endif()
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} ${_extraflags} "${__version_arg}")
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} ${_extraflags} "${__version_arg}" "${__dbg_arg}")
endif()
endfunction()