fix linkage with freetype/icu twice on linux

On linux Qt library depend on icu and freetype,
so OMaps linked with freetype/icu twice:
- static libraries 3rdparty/icu|freetype
- dynamic dependencies from libQtCore/libQtWidgets

this is undefined behavior because of one-definition-rule violation
comment #395

Signed-off-by: Evgeniy A. Dushistov <dushistov@mail.ru>
This commit is contained in:
Viktor Govako 2022-01-18 09:28:38 +03:00
parent b2e4776ebe
commit 04b257be86
10 changed files with 47 additions and 23 deletions

View file

@ -6,3 +6,4 @@ target_include_directories(freetype
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/freetype2>
)
add_library(Freetype::Freetype ALIAS freetype)

View file

@ -1,6 +1,6 @@
project(icu)
set(SRC
add_library(icuuc
uconfig_local.h
icu/icu4c/source/common/appendable.cpp
icu/icu4c/source/common/bmpset.cpp
@ -170,6 +170,20 @@ set(SRC
icu/icu4c/source/common/uvectr32.cpp
icu/icu4c/source/common/uvectr64.h
icu/icu4c/source/common/wintz.h
)
add_library(ICU::uc ALIAS icuuc)
target_include_directories(icuuc
PUBLIC
./
icu/icu4c/source/common
)
target_compile_definitions(icuuc PUBLIC UCONFIG_USE_LOCAL)
set_target_properties(icuuc PROPERTIES UNITY_BUILD OFF)
add_library(icui18n
icu/icu4c/source/i18n/anytrans.cpp
icu/icu4c/source/i18n/anytrans.h
icu/icu4c/source/i18n/astro.h
@ -374,19 +388,18 @@ set(SRC
icu/icu4c/source/i18n/ztrans.h
icu/icu4c/source/stubdata/stubdata.cpp
)
add_library(ICU::i18n ALIAS icui18n)
add_library(${PROJECT_NAME} ${SRC})
target_compile_definitions(icui18n PUBLIC UCONFIG_USE_LOCAL)
target_compile_definitions(${PROJECT_NAME}
PUBLIC
UCONFIG_USE_LOCAL
)
target_include_directories(${PROJECT_NAME}
target_include_directories(icui18n
PUBLIC
./
icu/icu4c/source/common
icu/icu4c/source/i18n
PRIVATE
icu/icu4c/source/common
)
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD OFF)
target_link_libraries(icui18n PRIVATE icuuc)
set_target_properties(icui18n PROPERTIES UNITY_BUILD OFF)

View file

@ -310,9 +310,14 @@ set(EXPAT_SHARED_LIBS OFF)
add_subdirectory(3party/expat/expat)
add_subdirectory(3party/agg)
add_subdirectory(3party/bsdiff-courgette)
add_subdirectory(3party/freetype)
add_subdirectory(3party/gflags)
add_subdirectory(3party/icu)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(ICU COMPONENTS uc i18n data REQUIRED)
find_package(Freetype REQUIRED)
else()
add_subdirectory(3party/freetype)
add_subdirectory(3party/icu)
endif()
add_subdirectory(3party/jansson)
add_subdirectory(3party/liboauthcpp)
add_subdirectory(3party/minizip)

View file

@ -93,11 +93,14 @@ set(SRC
omim_add_library(${PROJECT_NAME} ${SRC})
target_link_libraries(${PROJECT_NAME}
PUBLIC
ICU::uc
ICU::i18n # For transliteration.
PRIVATE
base
expat
jansson
succinct
icu # For transliteration.
oauthcpp # For base64_encode and base64_decode
minizip
${LIBZ}

View file

@ -6,11 +6,11 @@
#include <memory>
#include <mutex>
#include <string>
#include <unicode/uversion.h>
namespace icu
{
U_NAMESPACE_BEGIN
class UnicodeString;
} // namespace icu
U_NAMESPACE_END
class Transliteration
{

View file

@ -164,16 +164,18 @@ if (PLATFORM_LINUX)
endif()
target_link_libraries(${PROJECT_NAME}
PUBLIC
Freetype::Freetype
vulkan_wrapper
PRIVATE
indexer
platform
geometry
coding
base
freetype
vulkan_wrapper
stb_image
sdf_image
icu
ICU::i18n
expat
$<$<BOOL:${PLATFORM_MAC}>:-framework\ OpenGL>
$<$<BOOL:${PLATFORM_LINUX}>:OpenGL::GL>

View file

@ -29,7 +29,7 @@ omim_link_libraries(
opening_hours
freetype
expat
icu
ICU::i18n
jansson
protobuf
bsdiff

View file

@ -19,7 +19,7 @@ omim_link_libraries(
coding
geometry
base
icu
ICU::i18n
jansson
oauthcpp
protobuf

View file

@ -24,7 +24,7 @@ omim_link_libraries(
coding
base
bsdiff
icu
ICU::i18n
jansson
oauthcpp
opening_hours

View file

@ -42,7 +42,7 @@ omim_link_libraries(
pugixml
opening_hours
succinct
icu
ICU::i18n
${Boost_LIBRARIES}
${LIBZ}
)