mirror of https://github.com/procxx/kepka.git
Improve cmake
This commit is contained in:
parent
9cf55590c0
commit
ac62bc1469
|
@ -1,13 +1,32 @@
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(kepka-desktop)
|
project(Kepka
|
||||||
|
LANGUAGES C CXX
|
||||||
|
VERSION 2.0.0
|
||||||
|
DESCRIPTION "Unofficial Telegram Desktop fork"
|
||||||
|
# HOMEPAGE_URL "https://github.com/procxx/kepka"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(PROJECT_VERSION_RC 1)
|
||||||
|
|
||||||
|
if(PROJECT_VERSION_RC)
|
||||||
|
set(PROJECT_VERSION "${PROJECT_VERSION}-rc${PROJECT_VERSION_RC}")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules/")
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules/")
|
||||||
include(CTest)
|
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.10)
|
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.10)
|
||||||
cmake_policy(SET CMP0071 NEW)
|
cmake_policy(SET CMP0071 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# includes block
|
||||||
|
include(CTest)
|
||||||
|
# clang-format
|
||||||
|
include(modules/clang-cxx-dev-tools.cmake)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
set(LINUX 1)
|
set(LINUX 1)
|
||||||
endif()
|
endif()
|
||||||
|
@ -31,28 +50,20 @@ else()
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
|
|
||||||
if (LINUX)
|
if (LINUX)
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
find_package(ALSA)
|
find_package(ALSA)
|
||||||
find_package(PulseAudio)
|
find_package(PulseAudio)
|
||||||
find_package(Qt5 COMPONENTS DBus)
|
find_package(Qt5 COMPONENTS DBus)
|
||||||
else(LINUX)
|
else()
|
||||||
# Needs OpenAL-SOFT
|
# Needs OpenAL-SOFT
|
||||||
# Install via `brew install openal-soft` and configure with cmake call from README.md
|
# Install via `brew install openal-soft` and configure with cmake call from README.md
|
||||||
find_package(OpenAL REQUIRED NO_MODULE)
|
find_package(OpenAL REQUIRED NO_MODULE)
|
||||||
set(OPENAL_LIBRARY OpenAL::OpenAL)
|
set(OPENAL_LIBRARY OpenAL::OpenAL)
|
||||||
endif(LINUX)
|
endif()
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(FFmpeg REQUIRED)
|
find_package(FFmpeg REQUIRED)
|
||||||
find_package(Opus REQUIRED)
|
find_package(Opus REQUIRED)
|
||||||
|
@ -74,6 +85,7 @@ endif()
|
||||||
|
|
||||||
|
|
||||||
option(BUILD_DOC "Build documentation" OFF)
|
option(BUILD_DOC "Build documentation" OFF)
|
||||||
|
mark_as_advanced(BUILD_DOC)
|
||||||
|
|
||||||
if(BUILD_DOC)
|
if(BUILD_DOC)
|
||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
|
@ -89,6 +101,3 @@ endif()
|
||||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1 -fno-omit-frame-pointer -g")
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1 -fno-omit-frame-pointer -g")
|
||||||
add_subdirectory(Telegram)
|
add_subdirectory(Telegram)
|
||||||
|
|
||||||
# clang-format
|
|
||||||
include(modules/clang-cxx-dev-tools.cmake)
|
|
||||||
|
|
|
@ -7,24 +7,16 @@ if (LINUX)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (PACKAGED_BUILD)
|
|
||||||
add_definitions(-DTDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME)
|
|
||||||
add_definitions(-DTDESKTOP_DISABLE_DESKTOP_FILE_GENERATION)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -H")
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -H")
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
##================================================
|
##================================================
|
||||||
## Codegen Tools
|
## Codegen Tools
|
||||||
##================================================
|
##================================================
|
||||||
|
|
||||||
include_directories(SourceFiles)
|
include_directories(SourceFiles)
|
||||||
add_subdirectory(SourceFiles/codegen)
|
add_subdirectory(SourceFiles/codegen)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/styles)
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/styles)
|
||||||
|
|
||||||
#-w<(PRODUCT_DIR)/../.. -- wtf is that
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
COMMENT "Generating palette"
|
COMMENT "Generating palette"
|
||||||
OUTPUT
|
OUTPUT
|
||||||
|
@ -144,7 +136,6 @@ list(APPEND style_files
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach (src ${style_files})
|
foreach (src ${style_files})
|
||||||
# '-w<(PRODUCT_DIR)/../..',
|
|
||||||
get_filename_component(src_file ${src} NAME)
|
get_filename_component(src_file ${src} NAME)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
COMMENT "Generating ${src_file}"
|
COMMENT "Generating ${src_file}"
|
||||||
|
@ -176,21 +167,14 @@ endforeach()
|
||||||
##================================================
|
##================================================
|
||||||
## Branding
|
## Branding
|
||||||
##================================================
|
##================================================
|
||||||
|
|
||||||
set(KEPKA_APPNAME "Kepka"
|
set(KEPKA_APPNAME "Kepka"
|
||||||
CACHE STRING "Application name")
|
CACHE STRING "Application name")
|
||||||
|
|
||||||
configure_file(SourceFiles/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
configure_file(SourceFiles/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
|
|
||||||
##================================================
|
##================================================
|
||||||
## Kepka app
|
## Kepka app
|
||||||
##================================================
|
##================================================
|
||||||
|
|
||||||
#add_subdirectory(SourceFiles/boxes)
|
|
||||||
# ^ Unused: cotire PCH needs more rigid structure with targets defined from the same
|
|
||||||
# cmakelists file. To do: get rid of the PCH requirement for more flexible build structure.
|
|
||||||
|
|
||||||
add_executable(Kepka WIN32 MACOSX_BUNDLE
|
add_executable(Kepka WIN32 MACOSX_BUNDLE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/styles/palette.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/styles/palette.cpp
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/numbers.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/numbers.cpp
|
||||||
|
@ -543,7 +527,6 @@ list(APPEND tg_RESOURCES
|
||||||
qt5_add_resources(tg_RESOURCES_RCC ${tg_RESOURCES})
|
qt5_add_resources(tg_RESOURCES_RCC ${tg_RESOURCES})
|
||||||
|
|
||||||
target_sources(Kepka PRIVATE
|
target_sources(Kepka PRIVATE
|
||||||
${tg_RESOURCES}
|
|
||||||
${tg_RESOURCES_RCC}
|
${tg_RESOURCES_RCC}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -552,7 +535,7 @@ if (APPLE)
|
||||||
ThirdParty/SPMediaKeyTap/SPMediaKeyTap.m
|
ThirdParty/SPMediaKeyTap/SPMediaKeyTap.m
|
||||||
ThirdParty/SPMediaKeyTap/SPInvocationGrabbing/NSObject+SPInvocationGrabbing.m
|
ThirdParty/SPMediaKeyTap/SPInvocationGrabbing/NSObject+SPInvocationGrabbing.m
|
||||||
)
|
)
|
||||||
include_directories(ThirdParty/SPMediaKeyTap)
|
target_include_directories(Kepka PRIVATE ThirdParty/SPMediaKeyTap)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_sources(Kepka PRIVATE
|
target_sources(Kepka PRIVATE
|
||||||
|
@ -563,16 +546,12 @@ target_sources(Kepka PRIVATE
|
||||||
ThirdParty/emoji_suggestions/emoji_suggestions.cpp
|
ThirdParty/emoji_suggestions/emoji_suggestions.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(ThirdParty) # For minizip/ but we use fully-qualified
|
include_directories(ThirdParty/GSL/include
|
||||||
# include path to avoid ambiguity.
|
ThirdParty/variant/include
|
||||||
|
ThirdParty/emoji_suggestions
|
||||||
include_directories(ThirdParty/GSL/include ThirdParty/variant/include
|
ThirdParty/libtgvoip
|
||||||
ThirdParty/emoji_suggestions ThirdParty/libtgvoip)
|
ThirdParty
|
||||||
|
)
|
||||||
include_directories(SourceFiles)
|
|
||||||
|
|
||||||
include_directories(${OPENAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}
|
|
||||||
${OPUS_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS} ${ALSA_INCLUDE_DIRS} ${PULSEAUDIO_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_subdirectory(ThirdParty/libtgvoip)
|
add_subdirectory(ThirdParty/libtgvoip)
|
||||||
|
|
||||||
|
@ -581,7 +560,7 @@ if(NOT WIN32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_USING_V110_SDK71_
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
|
||||||
-DWIN32 -D_WINDOWS -D_UNICODE -DUNICODE
|
-DWIN32 -D_WINDOWS -D_UNICODE -DUNICODE
|
||||||
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP
|
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP
|
||||||
-DHAVE_STDINT_H -DNOMINMAX)
|
-DHAVE_STDINT_H -DNOMINMAX)
|
||||||
|
@ -589,9 +568,6 @@ endif()
|
||||||
|
|
||||||
add_definitions(-DAL_LIBTYPE_STATIC)
|
add_definitions(-DAL_LIBTYPE_STATIC)
|
||||||
add_definitions(-DAL_ALEXT_PROTOTYPES)
|
add_definitions(-DAL_ALEXT_PROTOTYPES)
|
||||||
add_definitions(-DTGVOIP_USE_CXX11_LIB)
|
|
||||||
|
|
||||||
add_definitions(-DTDESKTOP_DISABLE_CRASH_REPORTS)
|
|
||||||
|
|
||||||
if (LINUX)
|
if (LINUX)
|
||||||
add_definitions(-D_REENTRANT)
|
add_definitions(-D_REENTRANT)
|
||||||
|
@ -640,17 +616,29 @@ if(NOT WIN32)
|
||||||
set_flag_if_supported(Kepka WNCE -Wno-c++1z-extensions)
|
set_flag_if_supported(Kepka WNCE -Wno-c++1z-extensions)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(Kepka PRIVATE ${FFMPEG_DEFINITIONS})
|
target_compile_definitions(Kepka PRIVATE
|
||||||
|
TDESKTOP_DISABLE_CRASH_REPORTS
|
||||||
|
${FFMPEG_DEFINITIONS})
|
||||||
|
|
||||||
|
if (PACKAGED_BUILD)
|
||||||
|
target_compile_definitions(Kepka PRIVATE
|
||||||
|
TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME
|
||||||
|
TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MSVC AND MSVC_VERSION GREATER_EQUAL 1912)
|
if(MSVC AND MSVC_VERSION GREATER_EQUAL 1912)
|
||||||
target_compile_options(Kepka PRIVATE /permissive-)
|
target_compile_options(Kepka PRIVATE /permissive-)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(Kepka PRIVATE ${OPENAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}
|
||||||
|
${OPUS_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS} ${ALSA_INCLUDE_DIRS} ${PULSEAUDIO_INCLUDE_DIR} )
|
||||||
|
|
||||||
target_link_libraries(Kepka
|
target_link_libraries(Kepka
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
Qt5::Network
|
Qt5::Network
|
||||||
Qt5::GuiPrivate
|
Qt5::GuiPrivate
|
||||||
|
Threads::Threads
|
||||||
tgvoip
|
tgvoip
|
||||||
${OPENAL_LIBRARY}
|
${OPENAL_LIBRARY}
|
||||||
${FFMPEG_LIBRARIES}
|
${FFMPEG_LIBRARIES}
|
||||||
|
@ -709,15 +697,17 @@ if (LINUX)
|
||||||
target_link_libraries(Kepka Qt5::DBus dl ${ALSA_LIBRARIES} ${PULSEAUDIO_LIBRARIES})
|
target_link_libraries(Kepka Qt5::DBus dl ${ALSA_LIBRARIES} ${PULSEAUDIO_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(Kepka Threads::Threads)
|
|
||||||
|
|
||||||
##================================================
|
##================================================
|
||||||
## Installlation
|
## Installlation
|
||||||
##================================================
|
##================================================
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set_target_properties(Kepka PROPERTIES OUTPUT_NAME "kepka")
|
set_target_properties(Kepka PROPERTIES
|
||||||
|
OUTPUT_NAME "kepka"
|
||||||
|
AUTOMOC ON
|
||||||
|
)
|
||||||
|
|
||||||
install(TARGETS Kepka
|
install(TARGETS Kepka
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR})
|
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
@ -743,8 +733,7 @@ endforeach(icon_size)
|
||||||
## Tests
|
## Tests
|
||||||
##================================================
|
##================================================
|
||||||
|
|
||||||
if (BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
include_directories(ThirdParty/Catch/single_include)
|
include_directories(ThirdParty/Catch/single_include)
|
||||||
|
|
||||||
add_subdirectory(SourceFiles/base/tests)
|
add_subdirectory(SourceFiles/base/tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -116,9 +116,6 @@ if (APPLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LINUX)
|
if (LINUX)
|
||||||
find_package(ALSA)
|
|
||||||
find_package(PulseAudio)
|
|
||||||
|
|
||||||
if (ALSA_FOUND)
|
if (ALSA_FOUND)
|
||||||
target_sources(tgvoip PRIVATE
|
target_sources(tgvoip PRIVATE
|
||||||
os/linux/AudioInputALSA.cpp
|
os/linux/AudioInputALSA.cpp
|
||||||
|
|
Loading…
Reference in New Issue