Devendor some thridparty deps (#7836)
* Link with Qt6::Network on windows * Make find_program(BASH) REQUIRED to prevent build-time errors * Link more targets explicitly to pickup transitive dependencies * Don't add unsupported flags on MSVC Drive-by: use add_compile_options instead of add_definitions to set -fno-omit-frame-pointer * Move find_package(gflags) out of 3party GLOBAL flag for find_package has been added in CMake 3.24 * Don't hardcode paths to 3party/utfcpp * Use system expat explicitly if needed * Use system jansson explicitly if needed * Use find_package(ZLIB) to find zlib * Don't use vendored Freetype, ICU and HarfBuzz when WITH_SYSTEM_PROVIDED_3PARTY is set * Find pugixml explicitly * Fix typo in target name * Update utfcpp include path * Let CMake handle /DEBUG flag for MSVC Signed-off-by: Osyotr <Osyotr@users.noreply.github.com>
This commit is contained in:
parent
edb7fc265c
commit
76dd632ec5
28 changed files with 103 additions and 43 deletions
|
@ -2,10 +2,7 @@
|
|||
# Compatibility with CMake < 3.5 will be removed from a future version of CMake.
|
||||
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)
|
||||
|
||||
if (WITH_SYSTEM_PROVIDED_3PARTY)
|
||||
set(GFLAGS_USE_TARGET_NAMESPACE ON)
|
||||
find_package(gflags REQUIRED GLOBAL)
|
||||
else()
|
||||
if (NOT WITH_SYSTEM_PROVIDED_3PARTY)
|
||||
# Suppress "Policy CMP0077 is not set: option() honors normal variables"
|
||||
# for the freetype, expat and jansson options.
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
|
@ -25,6 +22,7 @@ else()
|
|||
set(EXPAT_DTD OFF)
|
||||
set(EXPAT_NS ON)
|
||||
add_subdirectory(expat/expat)
|
||||
add_library(expat::expat ALIAS expat)
|
||||
|
||||
# Configure Jansson library.
|
||||
set(JANSSON_BUILD_DOCS OFF)
|
||||
|
@ -34,6 +32,7 @@ else()
|
|||
set(JANSSON_WITHOUT_TESTS ON)
|
||||
add_subdirectory(jansson/jansson/)
|
||||
target_include_directories(jansson INTERFACE "${PROJECT_BINARY_DIR}/3party/jansson/jansson/include")
|
||||
add_library(jansson::jansson ALIAS jansson)
|
||||
|
||||
# Add gflags library.
|
||||
add_subdirectory(gflags)
|
||||
|
@ -44,17 +43,20 @@ else()
|
|||
|
||||
# Add protobuf library.
|
||||
add_subdirectory(protobuf)
|
||||
|
||||
if (NOT PLATFORM_LINUX)
|
||||
add_subdirectory(freetype)
|
||||
add_subdirectory(icu)
|
||||
add_subdirectory(harfbuzz)
|
||||
endif()
|
||||
|
||||
add_library(utf8cpp INTERFACE)
|
||||
add_library(utf8cpp::utf8cpp ALIAS utf8cpp)
|
||||
target_include_directories(utf8cpp INTERFACE "${OMIM_ROOT}/3party/utfcpp/source")
|
||||
endif()
|
||||
|
||||
add_subdirectory(agg)
|
||||
add_subdirectory(bsdiff-courgette)
|
||||
|
||||
if (NOT PLATFORM_LINUX)
|
||||
add_subdirectory(freetype)
|
||||
add_subdirectory(icu)
|
||||
add_subdirectory(harfbuzz)
|
||||
endif()
|
||||
|
||||
add_subdirectory(liboauthcpp)
|
||||
add_subdirectory(minizip)
|
||||
add_subdirectory(open-location-code)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../utfcpp/source
|
|
@ -103,7 +103,12 @@ if (NOT CMAKE_BUILD_TYPE)
|
|||
endif()
|
||||
|
||||
# Global compile options for all configurations.
|
||||
add_compile_options(-ffast-math)
|
||||
if (MSVC)
|
||||
add_compile_options(/utf-8)
|
||||
add_link_options(/INCREMENTAL:NO)
|
||||
else()
|
||||
add_compile_options(-ffast-math)
|
||||
endif()
|
||||
|
||||
if (PLATFORM_WIN)
|
||||
add_definitions(
|
||||
|
@ -114,10 +119,15 @@ endif()
|
|||
|
||||
# Built-in CMake configurations: Debug, Release, RelWithDebInfo, MinSizeRel
|
||||
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||
add_definitions(-DDEBUG -fno-omit-frame-pointer)
|
||||
add_definitions(-DDEBUG)
|
||||
if (NOT MSVC)
|
||||
add_compile_options(-fno-omit-frame-pointer)
|
||||
endif()
|
||||
elseif (${CMAKE_BUILD_TYPE} MATCHES "Rel")
|
||||
add_definitions(-DRELEASE)
|
||||
add_compile_options(-Ofast) # Also enables -ffast-math
|
||||
if (NOT MSVC)
|
||||
add_compile_options(-Ofast) # Also enables -ffast-math
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown build type: " ${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
|
@ -262,11 +272,6 @@ if (NOT PLATFORM_IPHONE AND NOT PLATFORM_ANDROID)
|
|||
find_package(Qt6 COMPONENTS REQUIRED ${qt_components} PATHS $ENV{QT_PATH} /opt/homebrew/opt/qt@6 /usr/local/opt/qt@6 /usr/lib/x86_64-linux-gnu/qt6)
|
||||
endif()
|
||||
|
||||
find_library(LIBZ NAMES z)
|
||||
if (LIBZ STREQUAL "LIBZ-NOTFOUND")
|
||||
message(FATAL_ERROR "Failed to find libz library.")
|
||||
endif()
|
||||
|
||||
# To allow #include "base/file_name.hpp" in all sources.
|
||||
include_directories(${CMAKE_HOME_DIRECTORY})
|
||||
|
||||
|
@ -302,12 +307,24 @@ if (USE_PCH)
|
|||
endif()
|
||||
|
||||
# Should be on the root level, not in 3party, so tests can get these dependencies.
|
||||
if (PLATFORM_LINUX)
|
||||
if (PLATFORM_LINUX OR PLATFORM_WIN)
|
||||
find_package(ICU COMPONENTS uc i18n data REQUIRED)
|
||||
find_package(Freetype REQUIRED)
|
||||
find_package(harfbuzz REQUIRED)
|
||||
endif()
|
||||
|
||||
if (WITH_SYSTEM_PROVIDED_3PARTY)
|
||||
set(GFLAGS_USE_TARGET_NAMESPACE ON)
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
find_package(expat CONFIG REQUIRED)
|
||||
find_package(jansson CONFIG REQUIRED)
|
||||
find_package(pugixml REQUIRED)
|
||||
find_package(utf8cpp REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
# Include 3party dependencies.
|
||||
add_subdirectory(3party)
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ omim_add_library(${PROJECT_NAME} ${SRC})
|
|||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} INTERFACE Threads::Threads)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC utf8cpp::utf8cpp)
|
||||
|
||||
if (NOT WITH_SYSTEM_PROVIDED_3PARTY)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE "${OMIM_ROOT}/3party/fast_double_parser/include")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "std/target_os.hpp"
|
||||
|
||||
#include <utf8cpp/utf8/unchecked.h>
|
||||
#include <utf8/unchecked.h>
|
||||
|
||||
std::string DebugPrint(std::string const & t)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
#include <utf8cpp/utf8/unchecked.h>
|
||||
#include <utf8/unchecked.h>
|
||||
|
||||
/// All methods work with strings in utf-8 format
|
||||
namespace strings
|
||||
|
|
|
@ -3,6 +3,6 @@ set(OMIM_WARNING_FLAGS
|
|||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-unused-parameter> # We have a lot of functions with unused parameters
|
||||
)
|
||||
set(3PARTY_INCLUDE_DIRS "${OMIM_ROOT}/3party/boost" "${OMIM_ROOT}/3party/utf8cpp/include")
|
||||
set(3PARTY_INCLUDE_DIRS "${OMIM_ROOT}/3party/boost")
|
||||
set(OMIM_DATA_DIR "${OMIM_ROOT}/data")
|
||||
set(OMIM_USER_RESOURCES_DIR "${OMIM_ROOT}/data")
|
||||
|
|
|
@ -95,14 +95,14 @@ omim_add_library(${PROJECT_NAME} ${SRC})
|
|||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
base
|
||||
expat
|
||||
expat::expat
|
||||
cppjansson
|
||||
succinct
|
||||
ICU::uc
|
||||
ICU::i18n # For transliteration.
|
||||
oauthcpp # For base64_encode and base64_decode
|
||||
minizip
|
||||
${LIBZ}
|
||||
ZLIB::ZLIB
|
||||
)
|
||||
|
||||
omim_add_test_subdirectory(coding_tests)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "base/control_flow.hpp"
|
||||
|
||||
#include <utf8cpp/utf8.h>
|
||||
#include <utf8.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#ifndef XML_STATIC
|
||||
#define XML_STATIC
|
||||
#endif
|
||||
#include <expat.h>
|
||||
|
||||
#if defined(__clang__)
|
||||
|
|
|
@ -7,5 +7,7 @@ set(SRC
|
|||
)
|
||||
omim_add_library(${PROJECT_NAME} ${SRC})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
jansson
|
||||
PUBLIC
|
||||
base
|
||||
jansson::jansson
|
||||
)
|
||||
|
|
|
@ -175,7 +175,7 @@ target_link_libraries(${PROJECT_NAME}
|
|||
sdf_image
|
||||
harfbuzz
|
||||
ICU::i18n
|
||||
expat
|
||||
expat::expat
|
||||
$<$<BOOL:${PLATFORM_MAC}>:-framework\ OpenGL>
|
||||
$<$<BOOL:${PLATFORM_LINUX}>:OpenGL::GL>
|
||||
)
|
||||
|
|
|
@ -10,5 +10,13 @@ set(SRC
|
|||
)
|
||||
|
||||
omim_add_library(${PROJECT_NAME} ${SRC})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
coding
|
||||
|
||||
PRIVATE
|
||||
base
|
||||
geometry
|
||||
)
|
||||
|
||||
omim_add_test_subdirectory(ge0_tests)
|
||||
|
|
|
@ -248,7 +248,7 @@ target_link_libraries(${PROJECT_NAME}
|
|||
descriptions
|
||||
indexer
|
||||
cppjansson
|
||||
expat
|
||||
expat::expat
|
||||
tess2
|
||||
$<$<BOOL:CMAKE_DL_LIBS>:${CMAKE_DL_LIBS}> # dladdr from boost::stacktrace
|
||||
)
|
||||
|
|
|
@ -28,7 +28,7 @@ omim_link_libraries(
|
|||
base
|
||||
opening_hours
|
||||
freetype
|
||||
expat
|
||||
expat::expat
|
||||
ICU::i18n
|
||||
cppjansson
|
||||
protobuf
|
||||
|
@ -40,7 +40,7 @@ omim_link_libraries(
|
|||
oauthcpp
|
||||
sqlite3
|
||||
${CMAKE_DL_LIBS}
|
||||
${LIBZ}
|
||||
ZLIB::ZLIB
|
||||
${Boost_LIBRARIES}
|
||||
)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
#include <utf8cpp/utf8/unchecked.h>
|
||||
#include <utf8/unchecked.h>
|
||||
|
||||
namespace search
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ omim_link_libraries(
|
|||
oauthcpp
|
||||
protobuf
|
||||
pugixml
|
||||
expat
|
||||
expat::expat
|
||||
succinct
|
||||
)
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ elseif(${PLATFORM_ANDROID})
|
|||
)
|
||||
else() # neither iPhone nor Android
|
||||
# Find bash first, on Windows it can be either in Git or in WSL
|
||||
find_program(BASH bash)
|
||||
find_program(BASH bash REQUIRED)
|
||||
# Generate version header file.
|
||||
execute_process(COMMAND "${BASH}" tools/unix/version.sh qt_version
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
|
@ -183,7 +183,7 @@ if (APPLE)
|
|||
target_compile_options(${PROJECT_NAME} PRIVATE "-fobjc-arc")
|
||||
endif()
|
||||
|
||||
if (PLATFORM_LINUX)
|
||||
if (PLATFORM_LINUX OR PLATFORM_WIN)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES AUTOMOC ON)
|
||||
endif()
|
||||
|
||||
|
@ -192,6 +192,7 @@ target_link_libraries(${PROJECT_NAME}
|
|||
coding
|
||||
$<$<BOOL:${PLATFORM_DESKTOP}>:Qt6::Core>
|
||||
$<$<BOOL:${PLATFORM_LINUX}>:Qt6::Network>
|
||||
$<$<BOOL:${PLATFORM_WIN}>:Qt6::Network>
|
||||
$<$<BOOL:${QT_POSITIONING}>:Qt6::Positioning>
|
||||
$<$<BOOL:${PLATFORM_MAC}>:
|
||||
-framework\ Foundation
|
||||
|
|
|
@ -185,6 +185,7 @@ set(SRC
|
|||
omim_add_library(${PROJECT_NAME} ${SRC})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
base
|
||||
routing_common
|
||||
platform
|
||||
traffic
|
||||
|
|
|
@ -15,5 +15,8 @@ set(SRC
|
|||
omim_add_library(${PROJECT_NAME} ${SRC})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
jansson # serdes_json.hpp is in coding
|
||||
PUBLIC
|
||||
coding
|
||||
geometry
|
||||
routing
|
||||
)
|
||||
|
|
|
@ -16,5 +16,11 @@ set(SRC
|
|||
)
|
||||
|
||||
omim_add_library(${PROJECT_NAME} ${SRC})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
base
|
||||
indexer
|
||||
platform
|
||||
)
|
||||
|
||||
omim_add_test_subdirectory(routing_common_tests)
|
||||
|
|
|
@ -32,7 +32,7 @@ omim_link_libraries(
|
|||
pugixml
|
||||
succinct
|
||||
${Boost_LIBRARIES}
|
||||
${LIBZ}
|
||||
ZLIB::ZLIB
|
||||
)
|
||||
|
||||
link_qt5_core(${PROJECT_NAME})
|
||||
|
|
|
@ -143,7 +143,7 @@ if (PLATFORM_IPHONE)
|
|||
endif()
|
||||
|
||||
# Do not include glm's CMakeLists.txt, because it's outdated and not necessary.
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${OMIM_ROOT}/3party/glm ${OMIM_ROOT}/3party/utf8cpp/include)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC "${OMIM_ROOT}/3party/glm")
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} drape)
|
||||
|
||||
|
|
|
@ -13,6 +13,6 @@ target_link_libraries(${PROJECT_NAME}
|
|||
routing
|
||||
kml
|
||||
coding
|
||||
expat
|
||||
expat::expat
|
||||
gflags::gflags
|
||||
)
|
||||
|
|
|
@ -19,6 +19,17 @@ set(
|
|||
)
|
||||
|
||||
omim_add_library(${PROJECT_NAME} ${SRC})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
routing
|
||||
traffic
|
||||
|
||||
PRIVATE
|
||||
base
|
||||
coding
|
||||
geometry
|
||||
platform
|
||||
)
|
||||
|
||||
omim_add_test_subdirectory(tracking_tests)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ omim_link_libraries(
|
|||
succinct
|
||||
ICU::i18n
|
||||
${Boost_LIBRARIES}
|
||||
${LIBZ}
|
||||
ZLIB::ZLIB
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
|
||||
|
|
|
@ -20,7 +20,14 @@ set(SRC
|
|||
|
||||
omim_add_library(${PROJECT_NAME} ${SRC})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC jansson)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
base
|
||||
coding
|
||||
cppjansson
|
||||
geometry
|
||||
indexer
|
||||
)
|
||||
|
||||
if (PLATFORM_DESKTOP)
|
||||
add_subdirectory(world_feed)
|
||||
|
|
|
@ -5,7 +5,7 @@ QT_PATH[arch=arm64] = /opt/homebrew/opt/qt@6
|
|||
BOOST_ROOT = $(OMIM_ROOT)/3party/boost
|
||||
|
||||
// jansson is included in many libs, and is also used in headers (leaks to other libs)
|
||||
HEADER_SEARCH_PATHS = $(inherited) $(OMIM_ROOT) $(BOOST_ROOT) $(OMIM_ROOT)/3party/jansson $(OMIM_ROOT)/3party/jansson/jansson/src $(OMIM_ROOT)/3party/utf8cpp/include
|
||||
HEADER_SEARCH_PATHS = $(inherited) $(OMIM_ROOT) $(BOOST_ROOT) $(OMIM_ROOT)/3party/jansson $(OMIM_ROOT)/3party/jansson/jansson/src $(OMIM_ROOT)/3party/utfcpp/source
|
||||
FRAMEWORK_SEARCH_PATHS[sdk=macosx*] = $(QT_PATH)/lib
|
||||
|
||||
// Deployment target
|
||||
|
|
Reference in a new issue