CMake: Avoid dsmyutil warnings on shared libraries using libjpeg

We link object files with the same names into the BundledLibjpeg
static archive.

This caused warnings when running dsymutil on shared libraries using
that archive:
 skipping debug map object with duplicate name and timestamp
 could not find object file symbol for symbol _jpeg_start_compress

Avoid that by creating copies of the source files with different
names, so that all object files are unique.

Pick-to: 6.2 6.5 6.6 6.7
Fixes: QTBUG-123324
Change-Id: I1d4ebdd111b4172cde793671fbe059957f102871
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
bb10
Alexandru Croitor 2024-03-15 13:07:26 +01:00
parent ed66cf8a04
commit b72158daf5
1 changed files with 28 additions and 8 deletions

View File

@ -1,4 +1,4 @@
set(JPEG16_SOURCES
set(jpeg16_original_sources
src/jcapistd.c
src/jccolor.c
src/jcdiffct.c
@ -15,8 +15,8 @@ set(JPEG16_SOURCES
src/jdsample.c
src/jutils.c)
set(JPEG12_SOURCES
${JPEG16_SOURCES}
set(jpeg12_original_sources
${jpeg16_original_sources}
src/jccoefct.c
src/jcdctmgr.c
src/jdcoefct.c
@ -31,8 +31,8 @@ set(JPEG12_SOURCES
src/jquant1.c
src/jquant2.c)
set(JPEG_SOURCES
${JPEG12_SOURCES}
set(jpeg_original_sources
${jpeg12_original_sources}
src/jaricom.c
src/jcapimin.c
src/jcarith.c
@ -64,11 +64,31 @@ set(JPEG_SOURCES
src/jmemnobs.c
src/jpeg_nbits.c)
# Make copies of the source files for the different bit counts, so that all the object file names
# are unique in the static archive. This avoids duplicate warnings for certain linkers and debug
# info extractors (like Apple's ld and dsymutil).
function(qt_internal_copy_jpeg_sources in_sources infix out_var)
set(jpeg_sources "")
foreach(src_file ${in_sources})
get_filename_component(src_file_name "${src_file}" NAME_WLE)
get_filename_component(src_file_extension "${src_file}" LAST_EXT)
set(dest_path "${CMAKE_CURRENT_BINARY_DIR}/${src_file_name}${infix}${src_file_extension}")
configure_file(${src_file} "${dest_path}" COPYONLY)
message(DEBUG "Copying jpeg source file ${src_file} to ${dest_path}.")
list(APPEND jpeg_sources "${dest_path}")
endforeach()
set(${out_var} "${jpeg_sources}" PARENT_SCOPE)
endfunction()
qt_internal_copy_jpeg_sources("${jpeg16_original_sources}" "_16" jpeg16_sources)
qt_internal_copy_jpeg_sources("${jpeg12_original_sources}" "_12" jpeg12_sources)
qt_internal_copy_jpeg_sources("${jpeg_original_sources}" "" jpeg_sources)
qt_internal_add_3rdparty_library(BundledLibjpeg16bits
STATIC
SKIP_AUTOMOC
SOURCES
${JPEG16_SOURCES}
${jpeg16_sources}
DEFINES
BITS_IN_JSAMPLE=16
INCLUDE_DIRECTORIES
@ -81,7 +101,7 @@ qt_internal_add_3rdparty_library(BundledLibjpeg12bits
STATIC
SKIP_AUTOMOC
SOURCES
${JPEG12_SOURCES}
${jpeg12_sources}
DEFINES
BITS_IN_JSAMPLE=12
INCLUDE_DIRECTORIES
@ -96,7 +116,7 @@ qt_internal_add_3rdparty_library(BundledLibjpeg
SKIP_AUTOMOC
INSTALL
SOURCES
${JPEG_SOURCES}
${jpeg_sources}
$<TARGET_OBJECTS:BundledLibjpeg12bits>
$<TARGET_OBJECTS:BundledLibjpeg16bits>
INCLUDE_DIRECTORIES