1
0
Fork 0

Make packaged build working

This commit is contained in:
Ilya Fedin 2020-01-03 08:33:52 +04:00
parent 652bbaf002
commit 1db22f3663
15 changed files with 547 additions and 422 deletions

View file

@ -7,16 +7,18 @@
add_library(external_crash_reports INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_crash_reports ALIAS external_crash_reports)
if (WIN32 OR LINUX OR build_macstore)
if (NOT DESKTOP_APP_DISABLE_CRASH_REPORTS)
if (WIN32 OR LINUX OR build_macstore)
add_subdirectory(breakpad)
target_link_libraries(external_crash_reports
INTERFACE
desktop-app::external_breakpad
)
else()
else()
add_subdirectory(crashpad)
target_link_libraries(external_crash_reports
INTERFACE
desktop-app::external_crashpad
)
endif()
endif()

View file

@ -7,22 +7,47 @@
add_library(external_ffmpeg INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_ffmpeg ALIAS external_ffmpeg)
target_include_directories(external_ffmpeg SYSTEM
INTERFACE
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVCODEC REQUIRED libavcodec)
pkg_check_modules(AVFORMAT REQUIRED libavformat)
pkg_check_modules(AVUTIL REQUIRED libavutil)
pkg_check_modules(SWSCALE REQUIRED libswscale)
pkg_check_modules(SWRESAMPLE REQUIRED libswresample)
target_include_directories(external_ffmpeg
INTERFACE
${AVCODEC_INCLUDE_DIRS}
${AVFORMAT_INCLUDE_DIRS}
${AVUTIL_INCLUDE_DIRS}
${SWSCALE_INCLUDE_DIRS}
${SWRESAMPLE_INCLUDE_DIRS})
target_link_libraries(external_ffmpeg
INTERFACE
${AVCODEC_LIBRARIES}
${AVFORMAT_LIBRARIES}
${AVUTIL_LIBRARIES}
${SWSCALE_LIBRARIES}
${SWRESAMPLE_LIBRARIES})
else()
target_include_directories(external_ffmpeg SYSTEM
INTERFACE
${libs_loc}/ffmpeg
)
)
set(ffmpeg_lib_loc ${libs_loc}/ffmpeg)
set(ffmpeg_lib_loc ${libs_loc}/ffmpeg)
target_link_libraries(external_ffmpeg
INTERFACE
target_link_libraries(external_ffmpeg
INTERFACE
${ffmpeg_lib_loc}/libavformat/libavformat.a
${ffmpeg_lib_loc}/libavcodec/libavcodec.a
${ffmpeg_lib_loc}/libswresample/libswresample.a
${ffmpeg_lib_loc}/libswscale/libswscale.a
${ffmpeg_lib_loc}/libavutil/libavutil.a
)
if (LINUX)
)
if (LINUX)
target_link_static_libraries(external_ffmpeg
INTERFACE
va-x11
@ -35,4 +60,5 @@ if (LINUX)
Xfixes
Xrender
)
endif()
endif()

View file

@ -4,14 +4,24 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(external_lz4 OBJECT)
add_library(desktop-app::external_lz4 ALIAS external_lz4)
init_target(external_lz4 "(external)")
if (DESKTOP_APP_USE_PACKAGED)
add_library(external_lz4 INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_lz4 ALIAS external_lz4)
set(lz4_loc ${third_party_loc}/lz4/lib)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LZ4 REQUIRED liblz4)
target_sources(external_lz4
PRIVATE
target_include_directories(external_lz4 INTERFACE ${LZ4_INCLUDE_DIRS})
target_link_libraries(external_lz4 INTERFACE ${LZ4_LIBRARIES})
else()
add_library(external_lz4 OBJECT)
add_library(desktop-app::external_lz4 ALIAS external_lz4)
init_target(external_lz4 "(external)")
set(lz4_loc ${third_party_loc}/lz4/lib)
target_sources(external_lz4
PRIVATE
${lz4_loc}/lz4.c
${lz4_loc}/lz4.h
${lz4_loc}/lz4frame.c
@ -21,9 +31,10 @@ PRIVATE
${lz4_loc}/lz4hc.h
${lz4_loc}/xxhash.c
${lz4_loc}/xxhash.h
)
)
target_include_directories(external_lz4
PUBLIC
target_include_directories(external_lz4
PUBLIC
${lz4_loc}
)
)
endif()

View file

@ -7,7 +7,11 @@
add_library(external_openal INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_openal ALIAS external_openal)
if (WIN32)
if (DESKTOP_APP_USE_PACKAGED)
find_package(OpenAL REQUIRED)
target_include_directories(external_openal INTERFACE ${OPENAL_INCLUDE_DIR})
target_link_libraries(external_openal INTERFACE ${OPENAL_LIBRARY})
elseif (WIN32)
target_include_directories(external_openal SYSTEM
INTERFACE
${libs_loc}/openal-soft/include
@ -36,8 +40,14 @@ else()
)
endif()
if (NOT DESKTOP_APP_USE_PACKAGED)
target_compile_definitions(external_openal
INTERFACE
AL_LIBTYPE_STATIC
)
endif()
target_compile_definitions(external_openal
INTERFACE
AL_LIBTYPE_STATIC
AL_ALEXT_PROTOTYPES
)

View file

@ -7,27 +7,31 @@
add_library(external_openssl INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_openssl ALIAS external_openssl)
if (LINUX)
if (DESKTOP_APP_USE_PACKAGED)
find_package(OpenSSL REQUIRED)
target_link_libraries(external_openssl INTERFACE OpenSSL::SSL)
else()
if (LINUX)
target_include_directories(external_openssl SYSTEM
INTERFACE
/usr/local/desktop-app/openssl-1.1.1/include
)
elseif (NOT APPLE OR NOT build_osx)
elseif (NOT APPLE OR NOT build_osx)
target_include_directories(external_openssl SYSTEM
INTERFACE
${libs_loc}/openssl_1_1_1/include
)
else()
else()
target_include_directories(external_openssl SYSTEM
INTERFACE
${libs_loc}/openssl/include
)
endif()
endif()
if (WIN32)
if (WIN32)
set(openssl_lib_ext lib)
set(openssl_lib_loc ${libs_loc}/openssl_1_1_1/out32$<$<CONFIG:Debug>:.dbg>)
else()
else()
set(openssl_lib_ext a)
if (APPLE)
if (NOT build_osx)
@ -38,15 +42,15 @@ else()
else()
set(openssl_lib_loc /usr/local/desktop-app/openssl-1.1.1/lib)
endif()
endif()
endif()
target_link_libraries(external_openssl
INTERFACE
target_link_libraries(external_openssl
INTERFACE
${openssl_lib_loc}/libssl.${openssl_lib_ext}
${openssl_lib_loc}/libcrypto.${openssl_lib_ext}
)
)
if (LINUX)
if (LINUX)
if (DESKTOP_APP_USE_GLIBC_WRAPS)
target_link_libraries(external_openssl
INTERFACE
@ -55,4 +59,5 @@ if (LINUX)
)
endif()
target_link_libraries(external_openssl INTERFACE pthread)
endif()
endif()

View file

@ -7,12 +7,21 @@
add_library(external_opus INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_opus ALIAS external_opus)
target_include_directories(external_opus SYSTEM
INTERFACE
${libs_loc}/opus/include
)
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(OPUS opus)
if (WIN32)
target_include_directories(external_opus INTERFACE ${OPUS_INCLUDE_DIRS})
else()
target_include_directories(external_opus SYSTEM
INTERFACE
${libs_loc}/opus/include
)
endif()
if (DESKTOP_APP_USE_PACKAGED)
target_link_libraries(external_opus INTERFACE ${OPUS_LIBRARIES})
elseif (WIN32)
set(opus_lib_loc ${libs_loc}/opus/win32/VS2015/Win32/$<IF:$<CONFIG:Debug>,Debug,Release>)
target_link_libraries(external_opus

View file

@ -15,8 +15,22 @@ if (LINUX)
endif()
endif()
target_include_directories(external_qt SYSTEM
INTERFACE
if (DESKTOP_APP_USE_PACKAGED)
target_link_libraries(external_qt
INTERFACE
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
Qt5::DBus)
target_include_directories(external_qt
INTERFACE
${Qt5Core_PRIVATE_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS})
else()
target_include_directories(external_qt SYSTEM
INTERFACE
${qt_loc}/include
${qt_loc}/include/QtCore
${qt_loc}/include/QtGui
@ -25,10 +39,10 @@ INTERFACE
${qt_loc}/include/QtGui/${qt_version}
${qt_loc}/include/QtCore/${qt_version}/QtCore
${qt_loc}/include/QtGui/${qt_version}/QtGui
)
)
target_compile_definitions(external_qt
INTERFACE
target_compile_definitions(external_qt
INTERFACE
_REENTRANT
QT_STATICPLUGIN
QT_PLUGIN
@ -36,21 +50,21 @@ INTERFACE
QT_NETWORK_LIB
QT_GUI_LIB
QT_CORE_LIB
)
)
if (WIN32)
if (WIN32)
set(qt_lib_prefix "")
set(qt_lib_suffix $<$<CONFIG:Debug>:d>.lib)
else()
else()
set(qt_lib_prefix lib)
if (APPLE)
set(qt_lib_suffix $<$<CONFIG:Debug>:_debug>.a)
else()
set(qt_lib_suffix .a)
endif()
endif()
endif()
set(common_qt_libs
set(common_qt_libs
plugins/imageformats/${qt_lib_prefix}qwebp
plugins/imageformats/${qt_lib_prefix}qgif
plugins/imageformats/${qt_lib_prefix}qjpeg
@ -64,10 +78,10 @@ set(common_qt_libs
lib/${qt_lib_prefix}Qt5Gui
lib/${qt_lib_prefix}qtharfbuzz
lib/${qt_lib_prefix}qtlibpng
)
)
set(qt_libs_list "")
if (WIN32)
set(qt_libs_list "")
if (WIN32)
set(qt_libs
${common_qt_libs}
lib/${qt_lib_prefix}Qt5Core
@ -80,7 +94,7 @@ if (WIN32)
foreach (lib ${qt_libs})
list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}")
endforeach()
elseif (APPLE)
elseif (APPLE)
if (NOT build_osx)
set(qt_libs
${common_qt_libs}
@ -116,7 +130,7 @@ elseif (APPLE)
desktop-app::external_zlib
cups
)
else()
else()
set(qt_libs
plugins/platforminputcontexts/${qt_lib_prefix}composeplatforminputcontextplugin
plugins/platforminputcontexts/${qt_lib_prefix}ibusplatforminputcontextplugin
@ -140,14 +154,14 @@ else()
foreach (lib ${qt_libs})
list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}")
endforeach()
endif()
endif()
target_link_libraries(external_qt
INTERFACE
target_link_libraries(external_qt
INTERFACE
${qt_libs_list}
)
)
if (LINUX)
if (LINUX)
target_include_directories(external_qt SYSTEM
INTERFACE
${qt_loc}/mkspecs/linux-g++
@ -214,4 +228,5 @@ if (LINUX)
glib-2.0
pthread
)
endif()
endif()

View file

@ -4,19 +4,21 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (NOT APPLE OR NOT build_osx)
if (NOT DESKTOP_APP_USE_PACKAGED)
if (NOT APPLE OR NOT build_osx)
set(qt_version 5.12.5)
else()
else()
set(qt_version 5.6.2)
endif()
endif()
if (WIN32)
if (WIN32)
set(qt_loc ${libs_loc}/Qt-${qt_version})
else()
else()
set(qt_loc /usr/local/desktop-app/Qt-${qt_version})
endif()
endif()
set(Qt5_DIR ${qt_loc}/lib/cmake/Qt5)
set(Qt5_DIR ${qt_loc}/lib/cmake/Qt5)
endif()
find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED)

View file

@ -7,10 +7,14 @@
add_library(external_ranges INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_ranges ALIAS external_ranges)
target_include_directories(external_ranges SYSTEM
INTERFACE
if (DESKTOP_APP_USE_PACKAGED)
find_package(range-v3 REQUIRED)
else()
target_include_directories(external_ranges SYSTEM
INTERFACE
${libs_loc}/range-v3/include
)
)
endif()
if (WIN32)
target_compile_options(external_ranges

View file

@ -4,16 +4,23 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(external_rlottie OBJECT)
add_library(desktop-app::external_rlottie ALIAS external_rlottie)
init_target(external_rlottie "(external)")
if (DESKTOP_APP_USE_PACKAGED_RLOTTIE)
add_library(external_rlottie INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_rlottie ALIAS external_rlottie)
get_filename_component(src_loc . REALPATH)
set(rlottie_loc ${third_party_loc}/rlottie)
find_package(rlottie REQUIRED)
target_link_libraries(external_rlottie INTERFACE rlottie::rlottie)
else()
add_library(external_rlottie OBJECT)
add_library(desktop-app::external_rlottie ALIAS external_rlottie)
init_target(external_rlottie "(external)")
target_sources(external_rlottie PRIVATE ${src_loc}/config/config.h)
nice_target_sources(external_rlottie ${rlottie_loc}
PRIVATE
get_filename_component(src_loc . REALPATH)
set(rlottie_loc ${third_party_loc}/rlottie)
target_sources(external_rlottie PRIVATE ${src_loc}/config/config.h)
nice_target_sources(external_rlottie ${rlottie_loc}
PRIVATE
inc/rlottie.h
inc/rlottie_capi.h
inc/rlottiecommon.h
@ -88,31 +95,32 @@ PRIVATE
src/vector/vrle.h
src/vector/vstackallocator.h
src/vector/vtaskqueue.h
)
)
target_compile_definitions(external_rlottie
PUBLIC
target_compile_definitions(external_rlottie
PUBLIC
LOT_BUILD
PRIVATE
PRIVATE
_USE_MATH_DEFINES
"RAPIDJSON_ASSERT=(void)"
)
)
target_include_directories(external_rlottie
PUBLIC
target_include_directories(external_rlottie
PUBLIC
${rlottie_loc}/inc
PRIVATE
PRIVATE
${src_loc}/config
${rlottie_loc}/src/lottie
${rlottie_loc}/src/vector
${rlottie_loc}/src/vector/pixman
${rlottie_loc}/src/vector/freetype
)
)
if (WIN32)
if (WIN32)
target_compile_options(external_rlottie
PRIVATE
/w44244 # 'initializing': conversion from 'double' to 'float'
/w44251 # needs to have dll-interface to be used by clients of class
)
endif()
endif()

View file

@ -7,12 +7,20 @@
add_library(external_xxhash INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_xxhash ALIAS external_xxhash)
target_include_directories(external_xxhash SYSTEM
INTERFACE
${third_party_loc}/xxHash
)
if (DESKTOP_APP_USE_PACKAGED)
find_library(XXHASH_LIBRARY xxhash)
find_path(XXHASH_INCLUDE_DIRS xxhash.h)
target_compile_definitions(external_xxhash
INTERFACE
target_include_directories(external_xxhash INTERFACE ${XXHASH_INCLUDE_DIRS})
target_link_libraries(external_xxhash INTERFACE ${XXHASH_LIBRARY})
else()
target_include_directories(external_xxhash SYSTEM
INTERFACE
${third_party_loc}/xxHash
)
target_compile_definitions(external_xxhash
INTERFACE
XXH_INLINE_ALL
)
)
endif()

View file

@ -7,7 +7,16 @@
add_library(external_zlib INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_zlib ALIAS external_zlib)
if (NOT WIN32)
if (DESKTOP_APP_USE_PACKAGED)
add_library(external_minizip INTERFACE IMPORTED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(MINIZIP REQUIRED minizip)
target_include_directories(external_minizip INTERFACE ${MINIZIP_INCLUDE_DIRS})
target_link_libraries(external_minizip INTERFACE ${MINIZIP_LIBRARIES})
target_link_libraries(external_zlib INTERFACE external_minizip)
elseif (NOT WIN32)
add_library(external_minizip STATIC)
init_target(external_minizip "(external)")
@ -32,13 +41,18 @@ if (NOT WIN32)
target_link_libraries(external_zlib INTERFACE external_minizip)
endif()
target_include_directories(external_zlib SYSTEM
INTERFACE
if (NOT DESKTOP_APP_USE_PACKAGED)
target_include_directories(external_zlib SYSTEM
INTERFACE
${libs_loc}/zlib
${libs_loc}/zlib/contrib/minizip
)
)
endif()
if (WIN32)
if (DESKTOP_APP_USE_PACKAGED)
find_package(ZLIB REQUIRED)
target_link_libraries(external_zlib INTERFACE ZLIB::ZLIB)
elseif (WIN32)
target_compile_definitions(external_zlib INTERFACE ZLIB_WINAPI)
set(zlib_lib_loc ${libs_loc}/zlib/contrib/vstudio/vc14/x86/ZlibStat$<IF:$<CONFIG:Debug>,Debug,ReleaseWithoutAsm>)

View file

@ -26,8 +26,10 @@ function(init_target target_name) # init_target(my_target folder_name)
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
target_link_libraries(${target_name} PUBLIC desktop-app::common_options)
if (NOT DESKTOP_APP_USE_PACKAGED)
set_target_properties(${target_name} PROPERTIES LINK_SEARCH_START_STATIC 1)
endif()
set_target_properties(${target_name} PROPERTIES
LINK_SEARCH_START_STATIC 1
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES
XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES
XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES

View file

@ -6,10 +6,9 @@
target_compile_options(common_options
INTERFACE
$<IF:$<CONFIG:Debug>,,-Ofast -fno-strict-aliasing>
$<IF:$<CONFIG:Debug>,,-fno-strict-aliasing>
-pipe
-Wall
-Werror
-W
-fPIC
-Wno-unused-variable
@ -26,14 +25,21 @@ INTERFACE
-Wno-maybe-uninitialized
-Wno-error=class-memaccess
)
target_link_options(common_options
INTERFACE
if (NOT DESKTOP_APP_USE_PACKAGED)
target_compile_options(common_options
INTERFACE
$<IF:$<CONFIG:Debug>,,-Ofast>
)
-Werror
)
target_link_options(common_options
INTERFACE
$<IF:$<CONFIG:Debug>,,-Ofast>
)
endif()
if (build_linux32)
target_compile_options(common_options INTERFACE -g0)
target_link_options(common_options INTERFACE -g0)
else()
elseif (NOT DESKTOP_APP_USE_PACKAGED)
target_compile_options(common_options INTERFACE $<IF:$<CONFIG:Debug>,,-g -flto>)
target_link_options(common_options INTERFACE $<IF:$<CONFIG:Debug>,,-g -flto -fuse-linker-plugin>)
endif()

View file

@ -10,6 +10,7 @@ option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." OFF)
option(DESKTOP_APP_LOTTIE_USE_CACHE "Use caching in lottie animations." ON)
option(DESKTOP_APP_USE_GLIBC_WRAPS "Use wraps for new GLIBC features." OFF)
option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." ON)
option(DESKTOP_APP_USE_PACKAGED_RLOTTIE "Find rlottie using CMake instead of bundled one." ${DESKTOP_APP_USE_PACKAGED})
function(report_bad_special_target)
message(FATAL_ERROR "Bad special target '${DESKTOP_APP_SPECIAL_TARGET}'")
@ -74,9 +75,11 @@ else()
elseif (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "")
report_bad_special_target()
endif()
if (NOT DESKTOP_APP_USE_PACKAGED)
set(CMAKE_AR /usr/bin/gcc-ar)
set(CMAKE_RANLIB /usr/bin/gcc-ranlib)
set(CMAKE_NM /usr/bin/gcc-nm)
endif()
endif()
if (NOT APPLE OR build_osx)