1
0
Fork 0

Updated cmake helpers to latest patches-track-wip (TD 5.0.6)

This commit is contained in:
Eric Kotato 2024-08-31 01:34:12 +03:00
commit b5d7cc3063
27 changed files with 193 additions and 120 deletions

View file

@ -5,6 +5,9 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL # https://github.com/desktop-app/legal/blob/master/LEGAL
add_subdirectory(external) add_subdirectory(external)
if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
add_subdirectory(linux_jemalloc_helper)
endif()
if (DESKTOP_APP_USE_ALLOCATION_TRACER) if (DESKTOP_APP_USE_ALLOCATION_TRACER)
add_subdirectory(linux_allocation_tracer) add_subdirectory(linux_allocation_tracer)
endif() endif()

View file

@ -38,6 +38,9 @@ if (add_hunspell_library)
add_checked_subdirectory(hunspell) add_checked_subdirectory(hunspell)
endif() endif()
add_checked_subdirectory(iconv) add_checked_subdirectory(iconv)
if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
add_checked_subdirectory(jemalloc)
endif()
add_checked_subdirectory(jpeg) add_checked_subdirectory(jpeg)
add_checked_subdirectory(kcoreaddons) add_checked_subdirectory(kcoreaddons)
add_checked_subdirectory(kimageformats) add_checked_subdirectory(kimageformats)
@ -54,15 +57,9 @@ add_checked_subdirectory(qr_code_generator)
add_checked_subdirectory(ranges) add_checked_subdirectory(ranges)
add_checked_subdirectory(rlottie) add_checked_subdirectory(rlottie)
add_checked_subdirectory(rnnoise) add_checked_subdirectory(rnnoise)
if (LINUX AND NOT DESKTOP_APP_DISABLE_SCUDO)
add_checked_subdirectory(scudo)
endif()
add_checked_subdirectory(ton) add_checked_subdirectory(ton)
add_checked_subdirectory(variant) add_checked_subdirectory(variant)
add_checked_subdirectory(vpx) add_checked_subdirectory(vpx)
if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
add_checked_subdirectory(wayland_client)
endif()
add_checked_subdirectory(webrtc) add_checked_subdirectory(webrtc)
if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
add_checked_subdirectory(xcb) add_checked_subdirectory(xcb)

View file

@ -13,10 +13,10 @@ init_target(external_cld3_bundled "(external)")
set(cld3_loc ${third_party_loc}/cld3) set(cld3_loc ${third_party_loc}/cld3)
set(cld3_src ${cld3_loc}/src) set(cld3_src ${cld3_loc}/src)
set(gen_loc ${cld3_loc}/build/gen) set(gen_loc ${CMAKE_CURRENT_BINARY_DIR}/gen)
set(gen_dst ${gen_loc}/cld_3/protos) set(gen_dst ${gen_loc}/cld_3/protos)
if (DESKTOP_APP_USE_PACKAGED) if (DESKTOP_APP_USE_PACKAGED OR LINUX)
find_package(Protobuf) find_package(Protobuf)
if (NOT Protobuf_FOUND) if (NOT Protobuf_FOUND)
find_package(protobuf REQUIRED CONFIG) find_package(protobuf REQUIRED CONFIG)
@ -30,9 +30,6 @@ elseif (WIN32)
else() else()
set(protoc_executable ${libs_loc}/protobuf/build/protoc) set(protoc_executable ${libs_loc}/protobuf/build/protoc)
set(protobuf_lib ${libs_loc}/protobuf/build/libprotobuf-lite.a) set(protobuf_lib ${libs_loc}/protobuf/build/libprotobuf-lite.a)
if (LINUX)
target_compile_options(external_cld3_bundled PRIVATE -Wno-implicit-fallthrough)
endif()
endif() endif()
if (PROTOBUF_PROTOC_EXECUTABLE) if (PROTOBUF_PROTOC_EXECUTABLE)
set(protoc_executable ${PROTOBUF_PROTOC_EXECUTABLE}) set(protoc_executable ${PROTOBUF_PROTOC_EXECUTABLE})
@ -87,13 +84,18 @@ PRIVATE
script_span/fixunicodevalue.cc script_span/fixunicodevalue.cc
) )
target_compile_options_if_exists(external_cld3_bundled
PRIVATE
-Wno-implicit-fallthrough
)
target_include_directories(external_cld3_bundled target_include_directories(external_cld3_bundled
PUBLIC PUBLIC
${cld3_src} ${cld3_src}
${gen_loc} ${gen_loc}
) )
if (NOT DESKTOP_APP_USE_PACKAGED) if (NOT DESKTOP_APP_USE_PACKAGED AND NOT LINUX)
target_include_directories(external_cld3_bundled target_include_directories(external_cld3_bundled
PUBLIC PUBLIC
${libs_loc}/protobuf/src ${libs_loc}/protobuf/src

@ -1 +1 @@
Subproject commit 83d94749d94fdb9b9e97a3e942f73a587a6ef253 Subproject commit 9c4f5820d94d62ab451501f016bfea97156518f4

View file

@ -19,6 +19,8 @@ function(generate_gir target_name namespace deps src_target_name)
BYPRODUCTS BYPRODUCTS
${gen_file} ${gen_file}
COMMAND COMMAND
env
$<$<BOOL:${DESKTOP_APP_ASAN}>:LDFLAGS=-fsanitize=address>
${DESKTOP_APP_GIRSCANNER} ${DESKTOP_APP_GIRSCANNER}
--quiet --quiet
-n -n

63
external/jemalloc/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,63 @@
# 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_jemalloc INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_jemalloc ALIAS external_jemalloc)
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
return()
endif()
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(JEMALLOC jemalloc)
if (JEMALLOC_FOUND)
target_include_directories(external_jemalloc SYSTEM
INTERFACE
${JEMALLOC_INCLUDE_DIRS}
)
target_link_libraries(external_jemalloc
INTERFACE
-Wl,--push-state,--no-as-needed,${JEMALLOC_LINK_LIBRARIES},--pop-state
)
return()
endif()
endif()
include(ProcessorCount)
ProcessorCount(N)
include(ExternalProject)
ExternalProject_Add(jemalloc
URL ${third_party_loc}/jemalloc
CONFIGURE_COMMAND env
"$<IF:$<OR:$<NOT:$<BOOL:${DESKTOP_APP_USE_PACKAGED}>>,$<BOOL:${DESKTOP_APP_SPECIAL_TARGET}>>,EXTRA_CFLAGS=-fno-omit-frame-pointer -fstack-protector-all -fstack-clash-protection -fcf-protection -DNDEBUG -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS,=>"
"$<IF:$<OR:$<NOT:$<BOOL:${DESKTOP_APP_USE_PACKAGED}>>,$<BOOL:${DESKTOP_APP_SPECIAL_TARGET}>>,EXTRA_CXXFLAGS=-fno-omit-frame-pointer -fstack-protector-all -fstack-clash-protection -fcf-protection -DNDEBUG -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS,=>"
./autogen.sh --disable-shared
BUILD_COMMAND make $<$<NOT:$<EQUAL:${N},0>>:-j${N}>
BUILD_IN_SOURCE 1
STEP_TARGETS build
EXCLUDE_FROM_ALL TRUE
BUILD_BYPRODUCTS <SOURCE_DIR>/lib/libjemalloc_pic.a
)
ExternalProject_Get_property(jemalloc SOURCE_DIR)
file(MAKE_DIRECTORY "${SOURCE_DIR}/include")
target_include_directories(external_jemalloc SYSTEM
INTERFACE
${SOURCE_DIR}/include
)
target_link_libraries(external_jemalloc
INTERFACE
-Wl,--push-state,--whole-archive,${SOURCE_DIR}/lib/libjemalloc_pic.a,--pop-state
)
add_dependencies(external_jemalloc jemalloc-build)

View file

@ -32,4 +32,5 @@ else()
set_target_properties(external_jpeg PROPERTIES set_target_properties(external_jpeg PROPERTIES
IMPORTED_LOCATION "${DESKTOP_APP_JPEG_LIBRARIES}" IMPORTED_LOCATION "${DESKTOP_APP_JPEG_LIBRARIES}"
) )
target_link_static_libraries(external_jpeg INTERFACE hwy)
endif() endif()

View file

@ -25,6 +25,7 @@ PRIVATE
heif.cpp heif.cpp
jxl.cpp jxl.cpp
qoi.cpp qoi.cpp
scanlineconverter.cpp
) )
target_compile_definitions(external_kimageformats target_compile_definitions(external_kimageformats
@ -101,6 +102,7 @@ elseif (APPLE)
${libs_loc}/local/lib/libbrotlidec-static.a ${libs_loc}/local/lib/libbrotlidec-static.a
${libs_loc}/local/lib/libbrotlienc-static.a ${libs_loc}/local/lib/libbrotlienc-static.a
${libs_loc}/local/lib/libbrotlicommon-static.a ${libs_loc}/local/lib/libbrotlicommon-static.a
${libs_loc}/local/lib/liblcms2.a
) )
else() else()
target_link_static_libraries(external_kimageformats target_link_static_libraries(external_kimageformats
@ -108,6 +110,7 @@ else()
avif avif
heif heif
jxl jxl
jxl_cms
jxl_threads jxl_threads
dav1d dav1d
de265 de265

View file

@ -10,3 +10,4 @@ https://github.com/desktop-app/legal/blob/master/LEGAL
Q_IMPORT_PLUGIN(QAVIFPlugin) Q_IMPORT_PLUGIN(QAVIFPlugin)
Q_IMPORT_PLUGIN(HEIFPlugin) Q_IMPORT_PLUGIN(HEIFPlugin)
Q_IMPORT_PLUGIN(QJpegXLPlugin) Q_IMPORT_PLUGIN(QJpegXLPlugin)
Q_IMPORT_PLUGIN(QOIPlugin)

View file

@ -41,7 +41,6 @@ elseif (APPLE)
else() else()
target_include_directories(external_openal SYSTEM target_include_directories(external_openal SYSTEM
INTERFACE INTERFACE
/usr/local/include
/usr/local/include/AL /usr/local/include/AL
) )
target_link_static_libraries(external_openal target_link_static_libraries(external_openal

View file

@ -8,15 +8,9 @@ add_library(external_openssl INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_openssl ALIAS external_openssl) add_library(desktop-app::external_openssl ALIAS external_openssl)
if (WIN32) if (WIN32)
set(openssl_lib_ext lib) set(openssl_lib_loc ${libs_loc}/openssl3/out)
set(openssl_lib_loc ${libs_loc}/openssl/out) elseif (APPLE)
else() set(openssl_lib_loc ${libs_loc}/openssl3)
set(openssl_lib_ext a)
if (APPLE)
set(openssl_lib_loc ${libs_loc}/openssl)
else()
set(openssl_lib_loc /usr/local/desktop-app/openssl-1.1.1/lib)
endif()
endif() endif()
add_subdirectory(openssl_common) add_subdirectory(openssl_common)

View file

@ -8,15 +8,16 @@ add_library(external_openssl_common INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_openssl_common ALIAS external_openssl_common) add_library(desktop-app::external_openssl_common ALIAS external_openssl_common)
if (NOT DESKTOP_APP_USE_PACKAGED) if (NOT DESKTOP_APP_USE_PACKAGED)
if (LINUX) if (NOT LINUX)
target_include_directories(external_openssl_common SYSTEM target_include_directories(external_openssl_common SYSTEM
INTERFACE INTERFACE
/usr/local/desktop-app/openssl-1.1.1/include ${libs_loc}/openssl3/include
) )
else() endif()
target_include_directories(external_openssl_common SYSTEM
# OpenSSL 3 deprecated AES_set_encrypt_key/decrypt_key/ige_encrypt/cbc_encrypt
target_compile_options_if_exists(external_openssl_common
INTERFACE INTERFACE
${libs_loc}/openssl/include -Wno-deprecated-declarations
) )
endif() endif()
endif()

View file

@ -16,13 +16,19 @@ endif()
add_library(external_openssl_crypto STATIC IMPORTED GLOBAL) add_library(external_openssl_crypto STATIC IMPORTED GLOBAL)
add_library(desktop-app::external_openssl_crypto ALIAS external_openssl_crypto) add_library(desktop-app::external_openssl_crypto ALIAS external_openssl_crypto)
set_target_properties(external_openssl_crypto PROPERTIES
IMPORTED_LOCATION "${openssl_lib_loc}/libcrypto.${openssl_lib_ext}"
)
if (WIN32) if (WIN32)
set_target_properties(external_openssl_crypto PROPERTIES set_target_properties(external_openssl_crypto PROPERTIES
IMPORTED_LOCATION_DEBUG "${openssl_lib_loc}.dbg/libcrypto.${openssl_lib_ext}" IMPORTED_LOCATION "${openssl_lib_loc}/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}"
IMPORTED_LOCATION_DEBUG "${openssl_lib_loc}.dbg/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
elseif (APPLE)
set_target_properties(external_openssl_crypto PROPERTIES
IMPORTED_LOCATION "${openssl_lib_loc}/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
else()
find_library(DESKTOP_APP_CRYPTO_LIBRARIES libcrypto.a REQUIRED)
set_target_properties(external_openssl_crypto PROPERTIES
IMPORTED_LOCATION "${DESKTOP_APP_CRYPTO_LIBRARIES}"
) )
endif() endif()

View file

@ -16,13 +16,19 @@ endif()
add_library(external_openssl_ssl STATIC IMPORTED GLOBAL) add_library(external_openssl_ssl STATIC IMPORTED GLOBAL)
add_library(desktop-app::external_openssl_ssl ALIAS external_openssl_ssl) add_library(desktop-app::external_openssl_ssl ALIAS external_openssl_ssl)
set_target_properties(external_openssl_ssl PROPERTIES
IMPORTED_LOCATION "${openssl_lib_loc}/libssl.${openssl_lib_ext}"
)
if (WIN32) if (WIN32)
set_target_properties(external_openssl_ssl PROPERTIES set_target_properties(external_openssl_ssl PROPERTIES
IMPORTED_LOCATION_DEBUG "${openssl_lib_loc}.dbg/libssl.${openssl_lib_ext}" IMPORTED_LOCATION "${openssl_lib_loc}/libssl${CMAKE_STATIC_LIBRARY_SUFFIX}"
IMPORTED_LOCATION_DEBUG "${openssl_lib_loc}.dbg/libssl${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
elseif (APPLE)
set_target_properties(external_openssl_ssl PROPERTIES
IMPORTED_LOCATION "${openssl_lib_loc}/libssl${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
else()
find_library(DESKTOP_APP_SSL_LIBRARIES libssl.a REQUIRED)
set_target_properties(external_openssl_ssl PROPERTIES
IMPORTED_LOCATION "${DESKTOP_APP_SSL_LIBRARIES}"
) )
endif() endif()

View file

@ -311,6 +311,7 @@ if (WIN32)
elseif (APPLE) elseif (APPLE)
target_link_libraries(external_qt target_link_libraries(external_qt
INTERFACE INTERFACE
${libs_loc}/local/lib/liblcms2.a
${libs_loc}/local/lib/libwebp.a ${libs_loc}/local/lib/libwebp.a
${libs_loc}/local/lib/libwebpdemux.a ${libs_loc}/local/lib/libwebpdemux.a
${libs_loc}/local/lib/libwebpmux.a ${libs_loc}/local/lib/libwebpmux.a

View file

@ -18,7 +18,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED)
elseif (APPLE) elseif (APPLE)
set(qt_loc ${libs_loc}/local/Qt-${qt_version}) set(qt_loc ${libs_loc}/local/Qt-${qt_version})
else() else()
set(qt_loc /usr/local/desktop-app/Qt-${qt_version}) set(qt_loc /usr/local/Qt-${qt_version})
endif() endif()
set(CMAKE_PREFIX_PATH ${qt_loc} ${libs_loc}/local) set(CMAKE_PREFIX_PATH ${qt_loc} ${libs_loc}/local)
@ -39,23 +39,12 @@ endif()
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Network Svg REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Network Svg REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Quick QuickWidgets QUIET) find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Quick QuickWidgets QUIET)
set(qt_version_6_5_or_greater 0)
if (QT_VERSION_MAJOR GREATER_EQUAL 6) if (QT_VERSION_MAJOR GREATER_EQUAL 6)
if (QT_VERSION_MAJOR GREATER 6 OR Qt6_VERSION_MINOR GREATER_EQUAL 5)
set(qt_version_6_5_or_greater 1)
endif()
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGL OpenGLWidgets REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGL OpenGLWidgets REQUIRED)
endif() endif()
# QtWaylandScanner cmake integration from Qt 6 is used
cmake_dependent_option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all code for Wayland integration." OFF "LINUX; qt_version_6_5_or_greater" ON)
if (LINUX) if (LINUX)
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS DBus WaylandClient WaylandCompositor QUIET) find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS DBus WaylandClient WaylandCompositor QUIET)
if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WaylandClient REQUIRED)
endif()
endif() endif()
set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "(gen)") set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "(gen)")

View file

@ -38,10 +38,6 @@ elseif (APPLE)
IMPORTED_LOCATION_DEBUG "${rnnoise_lib_loc}/Debug/librnnoise.a" IMPORTED_LOCATION_DEBUG "${rnnoise_lib_loc}/Debug/librnnoise.a"
) )
else() else()
target_include_directories(external_rnnoise SYSTEM
INTERFACE
/usr/local/include
)
find_library(DESKTOP_APP_RNNOISE_LIBRARIES librnnoise.a REQUIRED) find_library(DESKTOP_APP_RNNOISE_LIBRARIES librnnoise.a REQUIRED)
set_target_properties(external_rnnoise PROPERTIES set_target_properties(external_rnnoise PROPERTIES
IMPORTED_LOCATION "${DESKTOP_APP_RNNOISE_LIBRARIES}" IMPORTED_LOCATION "${DESKTOP_APP_RNNOISE_LIBRARIES}"

View file

@ -1,35 +0,0 @@
# 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_scudo STATIC)
add_library(desktop-app::external_scudo ALIAS external_scudo)
init_target(external_scudo "(external)")
set(scudo_loc ${third_party_loc}/scudo)
# https://llvm.org/docs/ScudoHardenedAllocator.html#library
file(GLOB scudo_srcs ${scudo_loc}/*.cpp)
target_sources(external_scudo
PRIVATE
${scudo_srcs}
)
target_include_directories(external_scudo SYSTEM
PRIVATE
${scudo_loc}/include
)
add_library(external_scudo_options INTERFACE)
target_compile_options(external_scudo_options
INTERFACE
-fno-lto
-Wno-unused-result
)
target_link_libraries(external_scudo
PRIVATE
external_scudo_options
)

View file

@ -42,10 +42,6 @@ elseif (APPLE)
IMPORTED_LOCATION ${libs_loc}/local/lib/libvpx.a IMPORTED_LOCATION ${libs_loc}/local/lib/libvpx.a
) )
else() else()
target_include_directories(external_vpx SYSTEM
INTERFACE
/usr/local/include
)
find_library(DESKTOP_APP_VPX_LIBRARIES libvpx.a REQUIRED) find_library(DESKTOP_APP_VPX_LIBRARIES libvpx.a REQUIRED)
set_target_properties(external_vpx PROPERTIES set_target_properties(external_vpx PROPERTIES
IMPORTED_LOCATION "${DESKTOP_APP_VPX_LIBRARIES}" IMPORTED_LOCATION "${DESKTOP_APP_VPX_LIBRARIES}"

View file

@ -1,16 +0,0 @@
# 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_wayland_client INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_wayland_client ALIAS external_wayland_client)
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client)
target_link_libraries(external_wayland_client INTERFACE PkgConfig::WAYLAND_CLIENT)
else()
target_link_optional_libraries(external_wayland_client INTERFACE wayland-client)
endif()

View file

@ -27,14 +27,6 @@ function(init_target target_name) # init_target(my_target [cxx_std_..] folder_na
set_property(TARGET ${target_name} APPEND_STRING PROPERTY STATIC_LIBRARY_OPTIONS "$<IF:$<CONFIG:Debug>,,/LTCG>") set_property(TARGET ${target_name} APPEND_STRING PROPERTY STATIC_LIBRARY_OPTIONS "$<IF:$<CONFIG:Debug>,,/LTCG>")
endif() endif()
if (LINUX AND NOT DESKTOP_APP_DISABLE_SCUDO AND NOT target_name STREQUAL external_scudo)
add_dependencies(${target_name} desktop-app::external_scudo)
target_link_options(${target_name}
PRIVATE
-Wl,--push-state,--whole-archive,$<TARGET_FILE:desktop-app::external_scudo>,--pop-state
)
endif()
target_link_libraries(${target_name} PRIVATE desktop-app::common_options) target_link_libraries(${target_name} PRIVATE desktop-app::common_options)
set_target_properties(${target_name} PROPERTIES set_target_properties(${target_name} PROPERTIES
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES

View file

@ -0,0 +1,19 @@
# 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(linux_jemalloc_helper OBJECT)
init_target(linux_jemalloc_helper "(external)")
add_library(desktop-app::linux_jemalloc_helper ALIAS linux_jemalloc_helper)
nice_target_sources(linux_jemalloc_helper ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
linux_jemalloc_helper.cpp
)
target_link_libraries(linux_jemalloc_helper
PRIVATE
desktop-app::external_jemalloc
)

View file

@ -0,0 +1,25 @@
// 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
//
#ifdef __FreeBSD__
#include <malloc_np.h>
#else // __FreeBSD__
#include <jemalloc/jemalloc.h>
#endif // !__FreeBSD__
namespace {
class JemallocInitializer {
public:
JemallocInitializer() {
auto backgroundThread = true;
mallctl("background_thread", nullptr, nullptr, &backgroundThread, sizeof(bool));
}
};
static const JemallocInitializer initializer;
} // namespace

View file

@ -52,6 +52,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED)
target_link_options(common_options target_link_options(common_options
INTERFACE INTERFACE
-static-libstdc++ -static-libstdc++
-static-libgcc
) )
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_link_static_libraries(common_options target_link_static_libraries(common_options
@ -98,6 +99,14 @@ if (NOT DESKTOP_APP_USE_PACKAGED OR DESKTOP_APP_SPECIAL_TARGET)
) )
endif() endif()
if (NOT DESKTOP_APP_DISABLE_JEMALLOC)
target_link_libraries(common_options
INTERFACE
$<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
$<LINK_ONLY:desktop-app::external_jemalloc>
)
endif()
if (DESKTOP_APP_USE_ALLOCATION_TRACER) if (DESKTOP_APP_USE_ALLOCATION_TRACER)
target_link_options(common_options target_link_options(common_options
INTERFACE INTERFACE
@ -121,6 +130,19 @@ if (DESKTOP_APP_USE_ALLOCATION_TRACER)
) )
endif() endif()
if (DESKTOP_APP_ASAN)
target_compile_options(common_options INTERFACE -fsanitize=address)
target_link_options(common_options INTERFACE -fsanitize=address)
if (NOT DESKTOP_APP_USE_PACKAGED)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(common_options INTERFACE -static-libasan)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_link_options(common_options INTERFACE -static-libsan)
endif()
endif()
endif()
target_link_libraries(common_options target_link_libraries(common_options
INTERFACE INTERFACE
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}

View file

@ -47,6 +47,11 @@ if (DESKTOP_APP_SPECIAL_TARGET)
) )
endif() endif()
target_link_options_if_exists(common_options
INTERFACE
-Wl,-ld_classic
)
target_link_frameworks(common_options target_link_frameworks(common_options
INTERFACE INTERFACE
Cocoa Cocoa

View file

@ -141,6 +141,7 @@ INTERFACE
Wtsapi32 Wtsapi32
Crypt32 Crypt32
Propsys Propsys
Bcrypt
) )
if (build_winstore) if (build_winstore)

View file

@ -32,7 +32,7 @@ option(DESKTOP_APP_ASAN "Enable address sanitizer" OFF)
cmake_dependent_option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell." OFF LINUX OFF) cmake_dependent_option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell." OFF LINUX OFF)
cmake_dependent_option(DESKTOP_APP_USE_CLD3 "Disable system text language recognition and use bundled cld3 only." OFF APPLE ON) cmake_dependent_option(DESKTOP_APP_USE_CLD3 "Disable system text language recognition and use bundled cld3 only." OFF APPLE ON)
cmake_dependent_option(DESKTOP_APP_NO_PDB "Disable PDB file generation." OFF WIN32 OFF) cmake_dependent_option(DESKTOP_APP_NO_PDB "Disable PDB file generation." OFF WIN32 OFF)
cmake_dependent_option(DESKTOP_APP_DISABLE_SCUDO "Disable scudo, use system malloc." OFF LINUX OFF) cmake_dependent_option(DESKTOP_APP_DISABLE_JEMALLOC "Disable jemalloc, use system malloc." OFF "LINUX; NOT DESKTOP_APP_ASAN" ON)
if (APPLE AND NOT DEFINED DESKTOP_APP_MAC_ARCH) if (APPLE AND NOT DEFINED DESKTOP_APP_MAC_ARCH)
if (DEFINED CMAKE_OSX_ARCHITECTURES) if (DEFINED CMAKE_OSX_ARCHITECTURES)