[CMAKE] Add DLL_EXPORT_VERSION config option

Set this to e.g. 0x600 to build with Vista exports
This commit is contained in:
Timo Kreuzer 2023-08-05 14:56:11 +03:00
parent a970c50a83
commit 3c2bfb570f
4 changed files with 15 additions and 7 deletions

View file

@ -232,7 +232,8 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
-D_WIN32_WINNT=0x502
-D_WIN32_WINDOWS=0x502
-D_SETUPAPI_VER=0x502
-DMINGW_HAS_SECURE_API=1)
-DMINGW_HAS_SECURE_API=1
-DDLL_EXPORT_VERSION=${DLL_EXPORT_VERSION})
# Arch Options
if(ARCH STREQUAL "i386")

View file

@ -114,3 +114,6 @@ endif()
set(USE_DUMMY_PSEH FALSE CACHE BOOL
"Whether to disable PSEH support.")
set(DLL_EXPORT_VERSION "0x502" CACHE STRING
"The NT version the user mode DLLs target.")

View file

@ -345,11 +345,11 @@ function(fixup_load_config _target)
DEPENDS native-pefixup)
endfunction()
function(generate_import_lib _libname _dllname _spec_file)
function(generate_import_lib _libname _dllname _spec_file __version_arg)
# Generate the def for the import lib
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def
COMMAND native-spec2def -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} -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
@ -415,6 +415,8 @@ function(spec2def _dllname _spec_file)
if(__spec2def_VERSION)
set(__version_arg "--version=0x${__spec2def_VERSION}")
else()
set(__version_arg "--version=${DLL_EXPORT_VERSION}")
endif()
# Generate exports def and C stubs file for the DLL
@ -429,7 +431,7 @@ function(spec2def _dllname _spec_file)
set(_extraflags --no-private-warnings)
endif()
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} ${_extraflags})
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} ${_extraflags} "${__version_arg}")
endif()
endfunction()

View file

@ -312,7 +312,7 @@ function(fixup_load_config _target)
# msvc knows how to generate a load_config so no hacks here
endfunction()
function(generate_import_lib _libname _dllname _spec_file)
function(generate_import_lib _libname _dllname _spec_file __version_arg)
set(_def_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def)
set(_asm_stubs_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_stubs.asm)
@ -320,7 +320,7 @@ function(generate_import_lib _libname _dllname _spec_file)
# Generate the def and asm stub files
add_custom_command(
OUTPUT ${_asm_stubs_file} ${_def_file}
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} --implib -n=${_dllname} -d=${_def_file} -l=${_asm_stubs_file} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
COMMAND native-spec2def --ms ${__version_arg} -a=${SPEC2DEF_ARCH} --implib -n=${_dllname} -d=${_def_file} -l=${_asm_stubs_file} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
# Compile the generated asm stub file
@ -386,6 +386,8 @@ function(spec2def _dllname _spec_file)
if(__spec2def_VERSION)
set(__version_arg "--version=0x${__spec2def_VERSION}")
else()
set(__version_arg "--version=${DLL_EXPORT_VERSION}")
endif()
# Generate exports def and C stubs file for the DLL
@ -395,7 +397,7 @@ function(spec2def _dllname _spec_file)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
if(__spec2def_ADD_IMPORTLIB)
generate_import_lib(lib${_file} ${_dllname} ${_spec_file})
generate_import_lib(lib${_file} ${_dllname} ${_spec_file} "${__version_arg}")
if(__spec2def_NO_PRIVATE_WARNINGS)
set_property(TARGET lib${_file} APPEND PROPERTY STATIC_LIBRARY_OPTIONS /ignore:4104)
endif()