2016-08-10 03:29:49 +08:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# :: Dependencies
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# This should go into subdirectories later.
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2017-11-23 00:59:24 +08:00
|
|
|
find_package(Qt5Concurrent REQUIRED)
|
2016-08-10 03:29:49 +08:00
|
|
|
find_package(Qt5Core REQUIRED)
|
|
|
|
find_package(Qt5Gui REQUIRED)
|
|
|
|
find_package(Qt5LinguistTools REQUIRED)
|
|
|
|
find_package(Qt5Network REQUIRED)
|
|
|
|
find_package(Qt5OpenGL REQUIRED)
|
|
|
|
find_package(Qt5Svg REQUIRED)
|
|
|
|
find_package(Qt5Test REQUIRED)
|
|
|
|
find_package(Qt5Widgets REQUIRED)
|
|
|
|
find_package(Qt5Xml REQUIRED)
|
|
|
|
|
|
|
|
function(add_dependency)
|
|
|
|
set(ALL_LIBRARIES ${ALL_LIBRARIES} ${ARGN} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Everything links to these Qt libraries.
|
|
|
|
add_dependency(
|
|
|
|
Qt5::Core
|
|
|
|
Qt5::Gui
|
|
|
|
Qt5::Network
|
|
|
|
Qt5::OpenGL
|
|
|
|
Qt5::Svg
|
|
|
|
Qt5::Widgets
|
|
|
|
Qt5::Xml)
|
|
|
|
|
|
|
|
include(CMakeParseArguments)
|
|
|
|
include(Qt5CorePatches)
|
|
|
|
|
|
|
|
function(search_dependency pkg)
|
2018-02-02 12:32:13 +08:00
|
|
|
set(options OPTIONAL STATIC_PACKAGE)
|
2017-09-20 14:28:40 +08:00
|
|
|
set(oneValueArgs PACKAGE LIBRARY FRAMEWORK HEADER)
|
2016-08-10 03:29:49 +08:00
|
|
|
set(multiValueArgs)
|
|
|
|
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
|
|
|
# Try pkg-config first.
|
|
|
|
if(NOT ${pkg}_FOUND AND arg_PACKAGE)
|
|
|
|
pkg_search_module(${pkg} ${arg_PACKAGE})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Then, try OSX frameworks.
|
|
|
|
if(NOT ${pkg}_FOUND AND arg_FRAMEWORK)
|
2017-07-03 05:08:22 +08:00
|
|
|
find_library(${pkg}_LIBRARIES
|
|
|
|
NAMES ${arg_FRAMEWORK}
|
|
|
|
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
|
|
|
|
PATH_SUFFIXES Frameworks
|
2016-12-04 06:44:03 +08:00
|
|
|
NO_DEFAULT_PATH
|
|
|
|
)
|
2016-08-10 03:29:49 +08:00
|
|
|
if(${pkg}_LIBRARIES)
|
|
|
|
set(${pkg}_FOUND TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Last, search for the library itself globally.
|
|
|
|
if(NOT ${pkg}_FOUND AND arg_LIBRARY)
|
|
|
|
find_library(${pkg}_LIBRARIES NAMES ${arg_LIBRARY})
|
2017-09-25 17:15:51 +08:00
|
|
|
if(arg_HEADER)
|
|
|
|
find_path(${pkg}_INCLUDE_DIRS NAMES ${arg_HEADER})
|
|
|
|
endif()
|
|
|
|
if(${pkg}_LIBRARIES AND (${pkg}_INCLUDE_DIRS OR NOT arg_HEADER))
|
2016-08-10 03:29:49 +08:00
|
|
|
set(${pkg}_FOUND TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ${pkg}_FOUND)
|
|
|
|
if(NOT arg_OPTIONAL)
|
|
|
|
message(FATAL_ERROR "${pkg} package, library or framework not found")
|
2017-07-09 02:11:31 +08:00
|
|
|
else()
|
|
|
|
message(STATUS "${pkg} not found")
|
2016-08-10 03:29:49 +08:00
|
|
|
endif()
|
|
|
|
else()
|
2018-02-02 12:32:13 +08:00
|
|
|
if(arg_STATIC_PACKAGE)
|
|
|
|
set(maybe_static _STATIC)
|
|
|
|
else()
|
|
|
|
set(maybe_static "")
|
|
|
|
endif()
|
2017-07-03 05:08:22 +08:00
|
|
|
|
2018-02-02 12:32:13 +08:00
|
|
|
message(STATUS ${pkg} " LIBRARY_DIRS: " "${${pkg}${maybe_static}_LIBRARY_DIRS}" )
|
|
|
|
message(STATUS ${pkg} " INCLUDE_DIRS: " "${${pkg}${maybe_static}_INCLUDE_DIRS}" )
|
|
|
|
message(STATUS ${pkg} " CFLAGS_OTHER: " "${${pkg}${maybe_static}_CFLAGS_OTHER}" )
|
|
|
|
message(STATUS ${pkg} " LIBRARIES: " "${${pkg}${maybe_static}_LIBRARIES}" )
|
2017-07-03 05:08:22 +08:00
|
|
|
|
2018-02-02 12:32:13 +08:00
|
|
|
link_directories(${${pkg}${maybe_static}_LIBRARY_DIRS})
|
|
|
|
include_directories(${${pkg}${maybe_static}_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
foreach(flag ${${pkg}${maybe_static}_CFLAGS_OTHER})
|
2017-06-11 17:52:35 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
|
|
|
|
endforeach()
|
2017-07-03 05:08:22 +08:00
|
|
|
|
2018-02-02 12:32:13 +08:00
|
|
|
set(ALL_LIBRARIES ${ALL_LIBRARIES} ${${pkg}${maybe_static}_LIBRARIES} PARENT_SCOPE)
|
2017-07-09 02:11:31 +08:00
|
|
|
message(STATUS "${pkg} found")
|
2016-08-10 03:29:49 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(${pkg}_FOUND ${${pkg}_FOUND} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
search_dependency(LIBAVCODEC PACKAGE libavcodec)
|
|
|
|
search_dependency(LIBAVDEVICE PACKAGE libavdevice)
|
|
|
|
search_dependency(LIBAVFORMAT PACKAGE libavformat)
|
|
|
|
search_dependency(LIBAVUTIL PACKAGE libavutil)
|
2017-09-12 07:55:13 +08:00
|
|
|
search_dependency(LIBEXIF PACKAGE libexif)
|
2016-08-10 03:29:49 +08:00
|
|
|
search_dependency(LIBQRENCODE PACKAGE libqrencode)
|
|
|
|
search_dependency(LIBSODIUM PACKAGE libsodium)
|
|
|
|
search_dependency(LIBSWSCALE PACKAGE libswscale)
|
|
|
|
search_dependency(SQLCIPHER PACKAGE sqlcipher)
|
|
|
|
search_dependency(VPX PACKAGE vpx)
|
|
|
|
|
2017-11-16 04:41:08 +08:00
|
|
|
if(${SPELL_CHECK})
|
|
|
|
find_package(KF5Sonnet)
|
|
|
|
if(KF5Sonnet_FOUND)
|
|
|
|
add_definitions(-DSPELL_CHECKING)
|
|
|
|
add_dependency(KF5::SonnetUi)
|
|
|
|
else()
|
|
|
|
message(WARNING "Sonnet not found. Spell checking will be disabled.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-01-07 16:00:36 +08:00
|
|
|
# Try to find cmake toxcore libraries
|
2018-02-02 12:32:13 +08:00
|
|
|
if(WIN32)
|
|
|
|
search_dependency(TOXCORE PACKAGE toxcore OPTIONAL STATIC_PACKAGE)
|
|
|
|
search_dependency(TOXAV PACKAGE toxav OPTIONAL STATIC_PACKAGE)
|
|
|
|
search_dependency(TOXENCRYPTSAVE PACKAGE toxencryptsave OPTIONAL STATIC_PACKAGE)
|
|
|
|
else()
|
|
|
|
search_dependency(TOXCORE PACKAGE toxcore OPTIONAL)
|
|
|
|
search_dependency(TOXAV PACKAGE toxav OPTIONAL)
|
|
|
|
search_dependency(TOXENCRYPTSAVE PACKAGE toxencryptsave OPTIONAL)
|
|
|
|
endif()
|
2017-01-07 16:00:36 +08:00
|
|
|
|
|
|
|
# If not found, use automake toxcore libraries
|
2018-01-06 23:21:04 +08:00
|
|
|
# We only check for TOXCORE, because the other two are gone in 0.2.0.
|
|
|
|
if (NOT TOXCORE_FOUND)
|
|
|
|
search_dependency(TOXCORE PACKAGE libtoxcore)
|
|
|
|
search_dependency(TOXAV PACKAGE libtoxav)
|
2017-01-07 16:00:36 +08:00
|
|
|
endif()
|
|
|
|
|
2017-05-16 04:42:15 +08:00
|
|
|
search_dependency(OPENAL PACKAGE openal)
|
2016-08-10 03:29:49 +08:00
|
|
|
|
2017-07-09 02:11:31 +08:00
|
|
|
if (PLATFORM_EXTENSIONS AND UNIX AND NOT APPLE)
|
|
|
|
# Automatic auto-away support. (X11 also using for capslock detection)
|
2017-09-25 17:31:38 +08:00
|
|
|
search_dependency(X11 PACKAGE x11 OPTIONAL)
|
|
|
|
search_dependency(XSS PACKAGE xscrnsaver OPTIONAL)
|
2017-07-09 02:11:31 +08:00
|
|
|
endif()
|
2016-08-10 03:29:49 +08:00
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
search_dependency(AVFOUNDATION FRAMEWORK AVFoundation)
|
|
|
|
search_dependency(COREMEDIA FRAMEWORK CoreMedia )
|
|
|
|
search_dependency(COREGRAPHICS FRAMEWORK CoreGraphics)
|
2016-12-04 06:44:03 +08:00
|
|
|
|
|
|
|
search_dependency(FOUNDATION FRAMEWORK Foundation OPTIONAL)
|
|
|
|
search_dependency(IOKIT FRAMEWORK IOKit OPTIONAL)
|
2016-08-10 03:29:49 +08:00
|
|
|
endif()
|
|
|
|
|
2017-03-23 16:35:13 +08:00
|
|
|
if(WIN32)
|
|
|
|
set(ALL_LIBRARIES ${ALL_LIBRARIES} strmiids)
|
2017-07-03 05:08:22 +08:00
|
|
|
# Qt doesn't provide openssl on windows
|
|
|
|
search_dependency(OPENSSL PACKAGE openssl)
|
2017-03-23 16:35:13 +08:00
|
|
|
endif()
|
|
|
|
|
2016-11-30 14:45:15 +08:00
|
|
|
if (NOT GIT_DESCRIBE)
|
2016-12-04 06:44:03 +08:00
|
|
|
execute_process(
|
|
|
|
COMMAND git describe --tags
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_DESCRIBE
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT GIT_DESCRIBE)
|
|
|
|
set(GIT_DESCRIBE "Nightly")
|
|
|
|
endif()
|
2016-11-23 05:33:00 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(
|
|
|
|
-DGIT_DESCRIBE="${GIT_DESCRIBE}"
|
|
|
|
)
|
|
|
|
|
2016-11-30 14:45:15 +08:00
|
|
|
if (NOT GIT_VERSION)
|
2016-12-04 06:44:03 +08:00
|
|
|
execute_process(
|
|
|
|
COMMAND git rev-parse HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_VERSION
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT GIT_VERSION)
|
|
|
|
set(GIT_VERSION "build without git")
|
|
|
|
endif()
|
2016-11-23 05:33:00 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(
|
|
|
|
-DGIT_VERSION="${GIT_VERSION}"
|
|
|
|
)
|
|
|
|
|
2016-12-01 14:20:02 +08:00
|
|
|
set(APPLE_EXT False)
|
2016-12-04 06:44:03 +08:00
|
|
|
if (FOUNDATION_FOUND AND IOKIT_FOUND)
|
|
|
|
set(APPLE_EXT True)
|
2016-12-01 14:20:02 +08:00
|
|
|
endif()
|
|
|
|
|
2016-12-04 06:44:03 +08:00
|
|
|
set(X11_EXT False)
|
|
|
|
if (X11_FOUND AND XSS_FOUND)
|
|
|
|
set(X11_EXT True)
|
2016-12-01 14:20:02 +08:00
|
|
|
endif()
|
|
|
|
|
2017-07-09 02:11:31 +08:00
|
|
|
if (PLATFORM_EXTENSIONS)
|
2017-12-12 20:42:45 +08:00
|
|
|
if (${APPLE_EXT} OR ${X11_EXT} OR WIN32)
|
2017-07-09 02:11:31 +08:00
|
|
|
add_definitions(
|
|
|
|
-DQTOX_PLATFORM_EXT
|
|
|
|
)
|
|
|
|
message(STATUS "Using platform extensions")
|
|
|
|
else()
|
|
|
|
message(WARNING "Not using platform extensions, dependencies not found")
|
|
|
|
set(PLATFORM_EXTENSIONS OFF)
|
|
|
|
endif()
|
2016-12-01 14:20:02 +08:00
|
|
|
endif()
|
|
|
|
|
2018-07-12 02:55:16 +08:00
|
|
|
if (${DESKTOP_NOTIFICATIONS})
|
|
|
|
# snorenotify does only provide a cmake find module
|
|
|
|
find_package(LibsnoreQt5 0.7.0 REQUIRED)
|
|
|
|
set(ALL_LIBRARIES ${ALL_LIBRARIES} Snore::Libsnore)
|
|
|
|
endif()
|
|
|
|
|
2016-08-10 03:29:49 +08:00
|
|
|
add_definitions(
|
2016-11-23 05:33:00 +08:00
|
|
|
-DLOG_TO_FILE=1
|
|
|
|
)
|