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,6 +7,7 @@
add_library(external_crash_reports INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_crash_reports ALIAS external_crash_reports)
if (NOT DESKTOP_APP_DISABLE_CRASH_REPORTS)
if (WIN32 OR LINUX OR build_macstore)
add_subdirectory(breakpad)
target_link_libraries(external_crash_reports
@ -20,3 +21,4 @@ else()
desktop-app::external_crashpad
)
endif()
endif()

View file

@ -7,6 +7,31 @@
add_library(external_ffmpeg INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_ffmpeg ALIAS external_ffmpeg)
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
@ -36,3 +61,4 @@ if (LINUX)
Xrender
)
endif()
endif()

View file

@ -4,6 +4,16 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED)
add_library(external_lz4 INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_lz4 ALIAS external_lz4)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LZ4 REQUIRED liblz4)
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)")
@ -27,3 +37,4 @@ 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_ALEXT_PROTOTYPES
)

View file

@ -7,6 +7,10 @@
add_library(external_openssl INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_openssl ALIAS external_openssl)
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
@ -56,3 +60,4 @@ 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)
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(OPUS opus)
target_include_directories(external_opus INTERFACE ${OPUS_INCLUDE_DIRS})
else()
target_include_directories(external_opus SYSTEM
INTERFACE
${libs_loc}/opus/include
)
endif()
if (WIN32)
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,6 +15,20 @@ if (LINUX)
endif()
endif()
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
@ -215,3 +229,4 @@ if (LINUX)
pthread
)
endif()
endif()

View file

@ -4,6 +4,7 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (NOT DESKTOP_APP_USE_PACKAGED)
if (NOT APPLE OR NOT build_osx)
set(qt_version 5.12.5)
else()
@ -17,6 +18,7 @@ else()
endif()
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)
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,6 +4,13 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED_RLOTTIE)
add_library(external_rlottie INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_rlottie ALIAS external_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)")
@ -116,3 +123,4 @@ if (WIN32)
/w44251 # needs to have dll-interface to be used by clients of class
)
endif()
endif()

View file

@ -7,6 +7,13 @@
add_library(external_xxhash INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_xxhash ALIAS external_xxhash)
if (DESKTOP_APP_USE_PACKAGED)
find_library(XXHASH_LIBRARY xxhash)
find_path(XXHASH_INCLUDE_DIRS xxhash.h)
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
@ -16,3 +23,4 @@ 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()
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
)
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,10 +75,12 @@ 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)
get_filename_component(libs_loc "../Libraries" REALPATH)