Skip to content

Commit 6a4dbed

Browse files
committed
[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.
1 parent 01cd847 commit 6a4dbed

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

sdk/cmake/gcc.cmake

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,16 +431,11 @@ function(fixup_load_config _target)
431431
DEPENDS native-pefixup)
432432
endfunction()
433433

434-
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
435-
CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
436-
set(__spec2def_dbg_arg "--dbg")
437-
endif()
438-
439-
function(generate_import_lib _libname _dllname _spec_file __version_arg)
434+
function(generate_import_lib _libname _dllname _spec_file __version_arg __dbg_arg)
440435
# Generate the def for the import lib
441436
add_custom_command(
442437
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def
443-
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}
438+
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}
444439
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
445440

446441
# With this, we let DLLTOOL create an import library
@@ -490,7 +485,7 @@ endfunction()
490485

491486
function(spec2def _dllname _spec_file)
492487

493-
cmake_parse_arguments(__spec2def "ADD_IMPORTLIB;NO_PRIVATE_WARNINGS;WITH_RELAY" "VERSION" "" ${ARGN})
488+
cmake_parse_arguments(__spec2def "ADD_IMPORTLIB;NO_PRIVATE_WARNINGS;WITH_RELAY;WITH_DBG;NO_DBG" "VERSION" "" ${ARGN})
494489

495490
# Get library basename
496491
get_filename_component(_file ${_dllname} NAME_WE)
@@ -510,10 +505,14 @@ function(spec2def _dllname _spec_file)
510505
set(__version_arg "--version=${DLL_EXPORT_VERSION}")
511506
endif()
512507

508+
if(__spec2def_WITH_DBG OR (DBG AND NOT __spec2def_NO_DBG))
509+
set(__dbg_arg "--dbg")
510+
endif()
511+
513512
# Generate exports def and C stubs file for the DLL
514513
add_custom_command(
515514
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c
516-
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}
515+
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}
517516
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
518517

519518
# Do not use precompiled headers for the stub file
@@ -525,7 +524,7 @@ function(spec2def _dllname _spec_file)
525524
set(_extraflags --no-private-warnings)
526525
endif()
527526

528-
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} ${_extraflags} "${__version_arg}")
527+
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} ${_extraflags} "${__version_arg}" "${__dbg_arg}")
529528
endif()
530529
endfunction()
531530

sdk/cmake/msvc.cmake

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,7 @@ function(fixup_load_config _target)
332332
# msvc knows how to generate a load_config so no hacks here
333333
endfunction()
334334

335-
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
336-
CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
337-
set(__spec2def_dbg_arg "--dbg")
338-
endif()
339-
340-
function(generate_import_lib _libname _dllname _spec_file __version_arg)
335+
function(generate_import_lib _libname _dllname _spec_file __version_arg __dbg_arg)
341336

342337
set(_def_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def)
343338
set(_asm_stubs_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_stubs.asm)
@@ -346,7 +341,7 @@ function(generate_import_lib _libname _dllname _spec_file __version_arg)
346341
# Generate the def, asm stub and alias files
347342
add_custom_command(
348343
OUTPUT ${_asm_stubs_file} ${_def_file} ${_asm_impalias_file}
349-
COMMAND native-spec2def --ms ${__version_arg} ${__spec2def_dbg_arg} -a=${SPEC2DEF_ARCH} --implib -n=${_dllname} -d=${_def_file} -l=${_asm_stubs_file} -i=${_asm_impalias_file} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
344+
COMMAND native-spec2def --ms ${__version_arg} ${__dbg_arg} -a=${SPEC2DEF_ARCH} --implib -n=${_dllname} -d=${_def_file} -l=${_asm_stubs_file} -i=${_asm_impalias_file} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
350345
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
351346

352347
# Compile the generated asm stub file
@@ -394,9 +389,10 @@ elseif(ARCH STREQUAL "arm64")
394389
else()
395390
set(SPEC2DEF_ARCH i386)
396391
endif()
392+
397393
function(spec2def _dllname _spec_file)
398394

399-
cmake_parse_arguments(__spec2def "ADD_IMPORTLIB;NO_PRIVATE_WARNINGS;WITH_RELAY" "VERSION" "" ${ARGN})
395+
cmake_parse_arguments(__spec2def "ADD_IMPORTLIB;NO_PRIVATE_WARNINGS;WITH_RELAY;WITH_DBG;NO_DBG" "VERSION" "" ${ARGN})
400396

401397
# Get library basename
402398
get_filename_component(_file ${_dllname} NAME_WE)
@@ -416,17 +412,21 @@ function(spec2def _dllname _spec_file)
416412
set(__version_arg "--version=${DLL_EXPORT_VERSION}")
417413
endif()
418414

415+
if(__spec2def_WITH_DBG OR (DBG AND NOT __spec2def_NO_DBG))
416+
set(__dbg_arg "--dbg")
417+
endif()
418+
419419
# Generate exports def and C stubs file for the DLL
420420
add_custom_command(
421421
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c
422-
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} -n=${_dllname} -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}
422+
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} -n=${_dllname} -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}
423423
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
424424

425425
# Do not use precompiled headers for the stub file
426426
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
427427

428428
if(__spec2def_ADD_IMPORTLIB)
429-
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} "${__version_arg}")
429+
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} "${__version_arg}" "${__dbg_arg}")
430430
if(__spec2def_NO_PRIVATE_WARNINGS)
431431
set_property(TARGET lib${_file} APPEND PROPERTY STATIC_LIBRARY_OPTIONS /ignore:4104)
432432
endif()

0 commit comments

Comments
 (0)