Merge pull request #570 from petitlapin/dll_info

CMake/Windows: store Expat version in the dll
This commit is contained in:
Sebastian Pipping 2022-02-24 23:09:09 +01:00 committed by GitHub
commit 6aa6a82d24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 8 deletions

View File

@ -381,7 +381,7 @@ endforeach()
#
# C library
#
set(expat_SRCS
set(_EXPAT_C_SOURCES
lib/xmlparse.c
lib/xmlrole.c
lib/xmltok.c
@ -393,13 +393,18 @@ set(expat_SRCS
if(EXPAT_SHARED_LIBS)
set(_SHARED SHARED)
if(MSVC)
set(expat_SRCS ${expat_SRCS} lib/libexpat.def)
set(_EXPAT_EXTRA_SOURCES ${_EXPAT_EXTRA_SOURCES} lib/libexpat.def)
endif()
if(WIN32)
# Add DLL version
string(REPLACE "." "," _EXPAT_DLL_VERSION ${PROJECT_VERSION}.0)
set(_EXPAT_EXTRA_SOURCES ${_EXPAT_EXTRA_SOURCES} win32/version.rc)
endif()
else()
set(_SHARED STATIC)
endif()
add_library(expat ${_SHARED} ${expat_SRCS})
add_library(expat ${_SHARED} ${_EXPAT_C_SOURCES} ${_EXPAT_EXTRA_SOURCES})
if(_EXPAT_LIBM_FOUND)
target_link_libraries(expat m)
endif()
@ -434,9 +439,13 @@ target_include_directories(expat
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(NOT EXPAT_SHARED_LIBS AND WIN32)
if(WIN32)
if(EXPAT_SHARED_LIBS)
target_compile_definitions(expat PRIVATE VER_FILEVERSION=${_EXPAT_DLL_VERSION})
else()
target_compile_definitions(expat PUBLIC -DXML_STATIC)
endif()
endif()
expat_install(TARGETS expat EXPORT expat
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@ -550,7 +559,7 @@ if(EXPAT_BUILD_TESTS)
tests/memcheck.c
tests/minicheck.c
tests/structdata.c
${expat_SRCS}
${_EXPAT_C_SOURCES}
)
if(NOT MSVC)
@ -619,7 +628,7 @@ if(EXPAT_BUILD_FUZZERS)
set(encoding_types UTF-16 UTF-8 ISO-8859-1 US-ASCII UTF-16BE UTF-16LE)
set(fuzz_targets xml_parse_fuzzer xml_parsebuffer_fuzzer)
add_library(fuzzpat STATIC ${expat_SRCS})
add_library(fuzzpat STATIC ${_EXPAT_C_SOURCES})
if(NOT EXPAT_OSSFUZZ_BUILD)
target_compile_options(fuzzpat PRIVATE -fsanitize=fuzzer-no-link)
endif()

View File

@ -82,7 +82,8 @@ _EXTRA_DIST_WINDOWS = \
win32/build_expat_iss.bat \
win32/expat.iss \
win32/MANIFEST.txt \
win32/README.txt
win32/README.txt \
win32/version.rc
EXTRA_DIST = \
$(_EXTRA_DIST_CMAKE) \

View File

@ -76,6 +76,7 @@ Flags: ignoreversion; Source: doc\*.css; DestDir: "{app}\Doc"
Flags: ignoreversion; Source: doc\*.xml; DestDir: "{app}\Doc"
Flags: ignoreversion; Source: win32\bin\Release\*.dll; DestDir: "{app}\Bin"
Flags: ignoreversion; Source: win32\bin\Release\*.lib; DestDir: "{app}\Bin"
Flags: ignoreversion; Source: win32\version.rc; DestDir: "{app}\Bin"
Flags: ignoreversion; Source: win32\README.txt; DestDir: "{app}\Source"
Flags: ignoreversion; Source: AUTHORS; DestDir: "{app}\Source"
Flags: ignoreversion; Source: Changes; DestDir: "{app}\Source"

17
expat/win32/version.rc Normal file
View File

@ -0,0 +1,17 @@
1 VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_FILEVERSION
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileVersion", "VER_FILEVERSION"
VALUE "ProductVersion", "VER_FILEVERSION"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1252
END
END