Skip to content

Commit

Permalink
Introduce DESKTOP_APP_USE_PACKAGED.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Dec 6, 2019
1 parent 3182d2d commit 632ed31
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 23 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL

add_subdirectory(external)
add_subdirectory(linux_glibc_wraps)
if (DESKTOP_APP_USE_GLIBC_WRAPS)
add_subdirectory(linux_glibc_wraps)
endif()
5 changes: 4 additions & 1 deletion external/auto_updates/xz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
add_library(external_xz INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_xz ALIAS external_xz)

if (APPLE AND NOT build_osx)
if (DESKTOP_APP_USE_PACKAGED)
find_package(LibLZMA REQUIRED)
target_link_libraries(external_xz LibLZMA::LibLZMA)
elseif (APPLE AND NOT build_osx)
target_link_libraries(external_xz
INTERFACE
/usr/local/macos/lib/liblzma.a
Expand Down
9 changes: 4 additions & 5 deletions external/openssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ INTERFACE
)

if (LINUX)
target_link_libraries(external_openssl
INTERFACE
desktop-app::linux_glibc_wraps
pthread
)
if (DESKTOP_APP_USE_GLIBC_WRAPS)
target_link_libraries(external_openssl INTERFACE desktop-app::linux_glibc_wraps)
endif()
target_link_libraries(external_openssl INTERFACE pthread)
endif()
4 changes: 3 additions & 1 deletion external/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ if (LINUX)
icuuc
icudata
)
if (DESKTOP_APP_USE_GLIBC_WRAPS)
target_link_libraries(external_qt INTERFACE desktop-app::linux_glibc_wraps)
endif()
target_link_libraries(external_qt
INTERFACE
desktop-app::linux_glibc_wraps
xcb
X11
X11-xcb
Expand Down
28 changes: 13 additions & 15 deletions linux_glibc_wraps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL

if (LINUX)
add_library(linux_glibc_wraps STATIC)
add_library(desktop-app::linux_glibc_wraps ALIAS linux_glibc_wraps)
add_library(linux_glibc_wraps STATIC)
add_library(desktop-app::linux_glibc_wraps ALIAS linux_glibc_wraps)

get_filename_component(src_loc . REALPATH)
get_filename_component(src_loc . REALPATH)

nice_target_sources(linux_glibc_wraps ${src_loc}
PRIVATE
platform/linux/linux_glibc_wraps.c
platform/linux/linux_glibc_wraps_32.c
platform/linux/linux_glibc_wraps_64.c
)
if (NOT build_linux32)
set_source_files_properties(${src_loc}/platform/linux/linux_glibc_wraps_32.c PROPERTIES HEADER_FILE_ONLY TRUE)
else()
set_source_files_properties(${src_loc}/platform/linux/linux_glibc_wraps_64.c PROPERTIES HEADER_FILE_ONLY TRUE)
endif()
nice_target_sources(linux_glibc_wraps ${src_loc}
PRIVATE
platform/linux/linux_glibc_wraps.c
platform/linux/linux_glibc_wraps_32.c
platform/linux/linux_glibc_wraps_64.c
)
if (NOT build_linux32)
set_source_files_properties(${src_loc}/platform/linux/linux_glibc_wraps_32.c PROPERTIES HEADER_FILE_ONLY TRUE)
else()
set_source_files_properties(${src_loc}/platform/linux/linux_glibc_wraps_64.c PROPERTIES HEADER_FILE_ONLY TRUE)
endif()
54 changes: 54 additions & 0 deletions run_cmake.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'''
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
'''
import sys, os, shutil, subprocess

def run(project, arguments):
scriptPath = os.path.dirname(os.path.realpath(__file__))
basePath = scriptPath + '/../out'

cmake = ['cmake']
for arg in arguments:
if arg == 'debug':
cmake.append('-DCMAKE_BUILD_TYPE=Debug')
elif arg != 'fresh':
cmake.append(arg)

if sys.platform == 'win32':
cmake.append('-AWin32')
elif sys.platform != 'darwin':
if not '-DCMAKE_BUILD_TYPE=Debug' in cmake:
cmake.append('-DCMAKE_BUILD_TYPE=Release')

specialTarget = ''
specialTargetFile = scriptPath + '/../' + project + '/build/target'
if os.path.isfile(specialTargetFile):
with open(specialTargetFile, 'r') as f:
for line in f:
target = line.strip()
if len(target) > 0:
cmake.append('-DDESKTOP_APP_SPECIAL_TARGET=' + target)

cmake.extend(['-Werror=dev', '-Werror=deprecated', '--warn-uninitialized', '..'])
command = ' '.join(cmake)

if not os.path.exists(basePath):
os.mkdir(basePath)
elif 'fresh' in arguments:
paths = os.listdir(basePath)
for path in paths:
if path.lower().startswith('cmake'):
full = basePath + '/' + path
if os.path.isdir(full):
shutil.rmtree(full, ignore_errors=False)
else:
os.remove(full)
print('Cleared previous.')
os.chdir(basePath)
subprocess.call(command, shell=True)

return 0
9 changes: 9 additions & 0 deletions variables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set(DESKTOP_APP_SPECIAL_TARGET "" CACHE STRING "Use special platform target, lik
option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." OFF)
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)

function(report_bad_special_target)
message(FATAL_ERROR "Bad special target '${DESKTOP_APP_SPECIAL_TARGET}'")
Expand All @@ -19,6 +21,11 @@ if (DESKTOP_APP_SPECIAL_TARGET STREQUAL ""
set(disable_autoupdate 1)
endif()

if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "")
set(DESKTOP_APP_USE_GLIBC_WRAPS ON)
set(DESKTOP_APP_USE_PACKAGED OFF)
endif()

if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "osx")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum OS X deployment version" FORCE)
else()
Expand All @@ -38,6 +45,7 @@ if (WIN32)
AND NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "win")
report_bad_special_target()
endif()
set(DESKTOP_APP_USE_GLIBC_WRAPS OFF)
elseif (APPLE)
if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "osx")
set(build_osx 1)
Expand All @@ -48,6 +56,7 @@ elseif (APPLE)
AND NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "mac")
report_bad_special_target()
endif()
set(DESKTOP_APP_USE_GLIBC_WRAPS OFF)
else()
set(LINUX 1)
execute_process(COMMAND uname -m OUTPUT_VARIABLE machine_uname)
Expand Down

0 comments on commit 632ed31

Please sign in to comment.