Skip to content

Commit

Permalink
Initial Linux build.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Dec 3, 2019
1 parent 382380d commit af968dc
Show file tree
Hide file tree
Showing 22 changed files with 461 additions and 20 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -5,3 +5,4 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL

add_subdirectory(external)
add_subdirectory(linux_glibc_wraps)
1 change: 1 addition & 0 deletions external/CMakeLists.txt
Expand Up @@ -6,6 +6,7 @@

add_subdirectory(auto_updates)
add_subdirectory(crash_reports)
add_subdirectory(ffmpeg)
add_subdirectory(gsl)
add_subdirectory(iconv)
add_subdirectory(lz4)
Expand Down
9 changes: 7 additions & 2 deletions external/auto_updates/xz/CMakeLists.txt
Expand Up @@ -12,9 +12,14 @@ if (APPLE AND NOT build_osx)
INTERFACE
/usr/local/macos/lib/liblzma.a
)
else()
elseif (APPLE)
target_link_libraries(external_xz
INTERFACE
/usr/local/lib/liblzma.a
/usr/local/liblzma.a
)
else()
target_link_static_libraries(external_xz
INTERFACE
lzma
)
endif()
5 changes: 5 additions & 0 deletions external/crash_reports/breakpad/CMakeLists.txt
Expand Up @@ -21,4 +21,9 @@ if (WIN32)
${breakpad_lib_loc}/windows/handler/exception_handler.lib
${breakpad_lib_loc}/windows/crash_generation/crash_generation_client.lib
)
elseif (LINUX)
target_link_static_libraries(external_breakpad
INTERFACE
breakpad_client
)
endif()
38 changes: 38 additions & 0 deletions external/ffmpeg/CMakeLists.txt
@@ -0,0 +1,38 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL

add_library(external_ffmpeg INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_ffmpeg ALIAS external_ffmpeg)

target_include_directories(external_ffmpeg SYSTEM
INTERFACE
${libs_loc}/ffmpeg
)

set(ffmpeg_lib_loc ${libs_loc}/ffmpeg)

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)
target_link_static_libraries(external_ffmpeg
INTERFACE
va-x11
va-drm
va
vdpau
drm
Xi
Xext
Xfixes
Xrender
)
endif()
8 changes: 4 additions & 4 deletions external/iconv/CMakeLists.txt
Expand Up @@ -7,14 +7,14 @@
add_library(external_iconv INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_iconv ALIAS external_iconv)

if (build_osx)
if (APPLE AND NOT build_osx)
target_link_libraries(external_iconv
INTERFACE
/usr/local/lib/libiconv.a
/usr/local/macos/lib/libiconv.a
)
else()
elseif (APPLE)
target_link_libraries(external_iconv
INTERFACE
/usr/local/macos/lib/libiconv.a
/usr/local/lib/libiconv.a
)
endif()
11 changes: 10 additions & 1 deletion external/openal/CMakeLists.txt
Expand Up @@ -16,7 +16,7 @@ if (WIN32)
INTERFACE
${libs_loc}/openal-soft/build/$<IF:$<CONFIG:Debug>,Debug,Release>/OpenAL32.lib
)
else()
elseif(APPLE AND NOT build_osx)
target_include_directories(external_openal SYSTEM
INTERFACE
/usr/local/macos/include
Expand All @@ -25,6 +25,15 @@ else()
INTERFACE
/usr/local/macos/lib/libopenal.a
)
else()
target_include_directories(external_openal SYSTEM
INTERFACE
/usr/local/include
)
target_link_static_libraries(external_openal
INTERFACE
openal
)
endif()

target_compile_definitions(external_openal
Expand Down
19 changes: 17 additions & 2 deletions external/openssl/CMakeLists.txt
Expand Up @@ -7,7 +7,12 @@
add_library(external_openssl INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_openssl ALIAS external_openssl)

if (NOT APPLE OR NOT build_osx)
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)
target_include_directories(external_openssl SYSTEM
INTERFACE
${libs_loc}/openssl_1_1_1/include
Expand All @@ -30,11 +35,21 @@ else()
else()
set(openssl_lib_loc ${libs_loc}/openssl)
endif()
else()
set(openssl_lib_loc /usr/local/desktop-app/openssl-1.1.1/lib)
endif()
endif()

target_link_libraries(external_openssl
INTERFACE
${openssl_lib_loc}/libcrypto.${openssl_lib_ext}
${openssl_lib_loc}/libssl.${openssl_lib_ext}
${openssl_lib_loc}/libcrypto.${openssl_lib_ext}
pthread
)

if (LINUX)
target_link_libraries(external_openssl
INTERFACE
desktop-app::linux_glibc_wraps
)
endif()
4 changes: 2 additions & 2 deletions external/opus/CMakeLists.txt
Expand Up @@ -25,8 +25,8 @@ elseif (APPLE AND NOT build_osx)
/usr/local/macos/lib/libopus.a
)
else()
target_link_libraries(external_opus
target_link_static_libraries(external_opus
INTERFACE
/usr/local/lib/libopus.a
opus
)
endif()
89 changes: 87 additions & 2 deletions external/qt/CMakeLists.txt
Expand Up @@ -8,7 +8,7 @@ add_library(external_qt INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_qt ALIAS external_qt)

if (LINUX)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (NOT build_linux32)
target_compile_definitions(external_qt INTERFACE Q_OS_LINUX64)
else()
target_compile_definitions(external_qt INTERFACE Q_OS_LINUX32)
Expand Down Expand Up @@ -43,7 +43,11 @@ if (WIN32)
set(qt_lib_suffix $<$<CONFIG:Debug>:d>.lib)
else()
set(qt_lib_prefix lib)
set(qt_lib_suffix $<$<CONFIG:Debug>:_debug>.a)
if (APPLE)
set(qt_lib_suffix $<$<CONFIG:Debug>:_debug>.a)
else()
set(qt_lib_suffix .a)
endif()
endif()

set(common_qt_libs
Expand Down Expand Up @@ -112,9 +116,90 @@ elseif (APPLE)
desktop-app::external_zlib
cups
)
else()
set(qt_libs
plugins/platforminputcontexts/${qt_lib_prefix}composeplatforminputcontextplugin
plugins/platforminputcontexts/${qt_lib_prefix}ibusplatforminputcontextplugin
plugins/platforminputcontexts/${qt_lib_prefix}fcitxplatforminputcontextplugin
plugins/platforminputcontexts/${qt_lib_prefix}himeplatforminputcontextplugin
plugins/platforminputcontexts/${qt_lib_prefix}nimfplatforminputcontextplugin
plugins/platforms/${qt_lib_prefix}qxcb
lib/${qt_lib_prefix}Qt5XcbQpa
lib/${qt_lib_prefix}Qt5LinuxAccessibilitySupport
lib/${qt_lib_prefix}Qt5ServiceSupport
lib/${qt_lib_prefix}Qt5EdidSupport
plugins/bearer/${qt_lib_prefix}qconnmanbearer
plugins/bearer/${qt_lib_prefix}qgenericbearer
plugins/bearer/${qt_lib_prefix}qnmbearer
${common_qt_libs}
lib/${qt_lib_prefix}Qt5DBus
lib/${qt_lib_prefix}Qt5Core
lib/${qt_lib_prefix}qtpcre2
lib/${qt_lib_prefix}xcb-static
)
foreach (lib ${qt_libs})
list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}")
endforeach()
endif()

target_link_libraries(external_qt
INTERFACE
${qt_libs_list}
)

if (LINUX)
target_include_directories(external_qt SYSTEM
INTERFACE
${qt_loc}/mkspecs/linux-g++
)
target_link_options(external_qt
INTERFACE
-static-libstdc++
-pthread
-rdynamic
-Wl,-wrap,aligned_alloc
-Wl,-wrap,secure_getenv
-Wl,-wrap,clock_gettime
-Wl,--no-as-needed,-lrt
)
if (NOT build_linux32)
target_link_options(external_qt
INTERFACE
-Wl,-wrap,__divmodti4
)
else()
target_link_options(external_qt
INTERFACE
-Wl,-wrap,__divmoddi4
)
endif()
target_link_static_libraries(external_qt
INTERFACE
SM
ICE
fontconfig
freetype
expat
z
xcb-shm
xcb-xfixes
xcb-render
xkbcommon
xkbcommon-x11
icutu
icui18n
icuuc
icudata
)
target_link_libraries(external_qt
INTERFACE
desktop-app::linux_glibc_wraps
xcb
X11
X11-xcb
dbus-1
dl
glib-2.0
pthread
)
endif()
4 changes: 3 additions & 1 deletion external/zlib/CMakeLists.txt
Expand Up @@ -44,6 +44,8 @@ if (WIN32)
set(zlib_lib_loc ${libs_loc}/zlib/contrib/vstudio/vc14/x86/ZlibStat$<IF:$<CONFIG:Debug>,Debug,ReleaseWithoutAsm>)

target_link_libraries(external_zlib INTERFACE ${zlib_lib_loc}/zlibstat.lib)
else()
elseif (APPLE)
target_link_libraries(external_zlib INTERFACE /usr/local/lib/libz.a)
else()
target_link_static_libraries(external_zlib INTERFACE z)
endif()
4 changes: 2 additions & 2 deletions generate_target.cmake
Expand Up @@ -4,8 +4,8 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL

function(generate_target parent_name postfix generated_files gen_dst)
add_custom_target(${parent_name}_${postfix} DEPENDS ${generated_files})
function(generate_target parent_name postfix generated_timestamp generated_files gen_dst)
add_custom_target(${parent_name}_${postfix} DEPENDS ${generated_timestamp})
init_target_folder(${parent_name}_${postfix} "(gen)")
add_dependencies(${parent_name} ${parent_name}_${postfix})
target_sources(${parent_name} PRIVATE ${generated_files})
Expand Down
10 changes: 9 additions & 1 deletion init_target.cmake
Expand Up @@ -34,7 +34,15 @@ function(init_target target_name) # init_target(my_target folder_name)
XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL $<IF:$<CONFIG:Debug>,0,fast>
XCODE_ATTRIBUTE_LLVM_LTO $<IF:$<CONFIG:Debug>,NO,YES>
)
if (NOT APPLE)
if (LINUX)
target_compile_options(${target_name} PUBLIC $<IF:$<CONFIG:Debug>,,-g -Ofast -fno-strict-aliasing>)
target_link_options(${target_name} PUBLIC $<IF:$<CONFIG:Debug>,,-g -Ofast>)
if (NOT build_linux32)
target_compile_options(${target_name} PUBLIC $<IF:$<CONFIG:Debug>,,-flto>)
target_link_options(${target_name} PUBLIC $<IF:$<CONFIG:Debug>,,-flto -fuse-linker-plugin>)
endif()
endif()
if (WIN32)
set_target_properties(${target_name} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE True
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True
Expand Down
24 changes: 24 additions & 0 deletions linux_glibc_wraps/CMakeLists.txt
@@ -0,0 +1,24 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# 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)

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()
endif()
29 changes: 29 additions & 0 deletions linux_glibc_wraps/platform/linux/linux_glibc_wraps.c
@@ -0,0 +1,29 @@
// This file is part of Desktop App Toolkit,
// a set of libraries for developing nice desktop applications.
//
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

void *__wrap_aligned_alloc(size_t alignment, size_t size) {
void *result = NULL;
return (posix_memalign(&result, alignment, size) == 0)
? result
: NULL;
}

int enable_secure_inited = 0;
int enable_secure = 1;

char *__wrap_secure_getenv(const char *name) {
if (enable_secure_inited == 0) {
enable_secure_inited = 1;
enable_secure = (geteuid() != getuid())
|| (getegid() != getgid());
}
return enable_secure ? NULL : getenv(name);
}

0 comments on commit af968dc

Please sign in to comment.