mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-05 12:45:58 -07:00
CMake: overhaul and improve scripts
- Bump minimum required version and make use of more modern language features - Rely more on target_...() commands to establish dependency relationships between targets rather than directory property commands - Improve libtorrent package discovery - Enable and handle application features more explicitly - Improve user-facing output - Fix various compilation issues on Windows (MSVC and MinGW) and macOS - Improve handling of translations - Add explanatory comments where relevant - Make CMake scripts fully independent of qmake files/details - Remove old functions/macros
This commit is contained in:
parent
79bc4f40e8
commit
46123b9989
28 changed files with 474 additions and 1239 deletions
|
@ -1,22 +0,0 @@
|
|||
# Helper function for coupling add_feature_info(), option(), and add_definitions()
|
||||
|
||||
function(optional_compile_definitions _name)
|
||||
set(options FEATURE)
|
||||
set(oneValueArgs DESCRIPTION DEFAULT)
|
||||
set(multiValueArgs ENABLED DISABLED)
|
||||
cmake_parse_arguments(OCD "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
option(${_name} "${OCD_DESCRIPTION}" ${OCD_DEFAULT})
|
||||
if (${${_name}})
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY COMPILE_DEFINITIONS ${OCD_ENABLED})
|
||||
else()
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY COMPILE_DEFINITIONS ${OCD_DISABLED})
|
||||
endif()
|
||||
if(${OCD_FEATURE})
|
||||
add_feature_info(${_name} ${_name} "${OCD_DESCRIPTION}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(feature_option _name _description _default)
|
||||
option(${_name} "${_description}" ${_default})
|
||||
add_feature_info(${_name} ${_name} "${_description}")
|
||||
endmacro()
|
|
@ -1,355 +0,0 @@
|
|||
# Borrowed from Avogadro project (https://github.com/OpenChemistry/avogadroapp)
|
||||
|
||||
#.rst:
|
||||
# DeployQt5
|
||||
# ---------
|
||||
#
|
||||
# Functions to help assemble a standalone Qt5 executable.
|
||||
#
|
||||
# A collection of CMake utility functions useful for deploying Qt5
|
||||
# executables.
|
||||
#
|
||||
# The following functions are provided by this module:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# write_qt5_conf
|
||||
# resolve_qt5_paths
|
||||
# fixup_qt5_executable
|
||||
# install_qt5_plugin_path
|
||||
# install_qt5_plugin
|
||||
# install_qt5_executable
|
||||
#
|
||||
# Requires CMake 2.8.9 or greater because Qt 5 does.
|
||||
# Also depends on BundleUtilities.cmake.
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# WRITE_QT5_CONF(<qt_conf_dir> <qt_conf_contents>)
|
||||
#
|
||||
# Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>.
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# RESOLVE_QT5_PATHS(<paths_var> [<executable_path>])
|
||||
#
|
||||
# Loop through <paths_var> list and if any don't exist resolve them
|
||||
# relative to the <executable_path> (if supplied) or the
|
||||
# CMAKE_INSTALL_PREFIX.
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# FIXUP_QT5_EXECUTABLE(<executable> [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>])
|
||||
#
|
||||
# Copies Qt plugins, writes a Qt configuration file (if needed) and
|
||||
# fixes up a Qt5 executable using BundleUtilities so it is standalone
|
||||
# and can be drag-and-drop copied to another machine as long as all of
|
||||
# the system libraries are compatible.
|
||||
#
|
||||
# <executable> should point to the executable to be fixed-up.
|
||||
#
|
||||
# <qtplugins> should contain a list of the names or paths of any Qt
|
||||
# plugins to be installed.
|
||||
#
|
||||
# <libs> will be passed to BundleUtilities and should be a list of any
|
||||
# already installed plugins, libraries or executables to also be
|
||||
# fixed-up.
|
||||
#
|
||||
# <dirs> will be passed to BundleUtilities and should contain and
|
||||
# directories to be searched to find library dependencies.
|
||||
#
|
||||
# <plugins_dir> allows an custom plugins directory to be used.
|
||||
#
|
||||
# <request_qt_conf> will force a qt.conf file to be written even if not
|
||||
# needed.
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# INSTALL_QT5_PLUGIN_PATH(plugin executable copy installed_plugin_path_var <plugins_dir> <component> <configurations>)
|
||||
#
|
||||
# Install (or copy) a resolved <plugin> to the default plugins directory
|
||||
# (or <plugins_dir>) relative to <executable> and store the result in
|
||||
# <installed_plugin_path_var>.
|
||||
#
|
||||
# If <copy> is set to TRUE then the plugins will be copied rather than
|
||||
# installed. This is to allow this module to be used at CMake time
|
||||
# rather than install time.
|
||||
#
|
||||
# If <component> is set then anything installed will use this COMPONENT.
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# INSTALL_QT5_PLUGIN(plugin executable copy installed_plugin_path_var <plugins_dir> <component>)
|
||||
#
|
||||
# Install (or copy) an unresolved <plugin> to the default plugins
|
||||
# directory (or <plugins_dir>) relative to <executable> and store the
|
||||
# result in <installed_plugin_path_var>. See documentation of
|
||||
# INSTALL_QT5_PLUGIN_PATH.
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# INSTALL_QT5_EXECUTABLE(<executable> [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>])
|
||||
#
|
||||
# Installs Qt plugins, writes a Qt configuration file (if needed) and
|
||||
# fixes up a Qt5 executable using BundleUtilities so it is standalone
|
||||
# and can be drag-and-drop copied to another machine as long as all of
|
||||
# the system libraries are compatible. The executable will be fixed-up
|
||||
# at install time. <component> is the COMPONENT used for bundle fixup
|
||||
# and plugin installation. See documentation of FIXUP_QT5_BUNDLE.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2011 Mike McQuaid <mike@mikemcquaid.com>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# The functions defined in this file depend on the fixup_bundle function
|
||||
# (and others) found in BundleUtilities.cmake
|
||||
|
||||
include(BundleUtilities)
|
||||
set(DeployQt5_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
|
||||
set(DeployQt5_apple_plugins_dir "PlugIns")
|
||||
|
||||
function(write_qt5_conf qt_conf_dir qt_conf_contents)
|
||||
set(qt_conf_path "${qt_conf_dir}/qt.conf")
|
||||
message(STATUS "Writing ${qt_conf_path}")
|
||||
file(WRITE "${qt_conf_path}" "${qt_conf_contents}")
|
||||
endfunction()
|
||||
|
||||
function(resolve_qt5_paths paths_var)
|
||||
set(executable_path ${ARGV1})
|
||||
|
||||
set(paths_resolved)
|
||||
foreach(path ${${paths_var}})
|
||||
if(EXISTS "${path}")
|
||||
list(APPEND paths_resolved "${path}")
|
||||
else()
|
||||
if(${executable_path})
|
||||
list(APPEND paths_resolved "${executable_path}/${path}")
|
||||
else()
|
||||
list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${paths_var} ${paths_resolved} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(fixup_qt5_executable executable)
|
||||
set(qtplugins ${ARGV1})
|
||||
set(libs ${ARGV2})
|
||||
set(dirs ${ARGV3})
|
||||
set(plugins_dir ${ARGV4})
|
||||
set(request_qt_conf ${ARGV5})
|
||||
|
||||
message(STATUS "fixup_qt5_executable")
|
||||
message(STATUS " executable='${executable}'")
|
||||
message(STATUS " qtplugins='${qtplugins}'")
|
||||
message(STATUS " libs='${libs}'")
|
||||
message(STATUS " dirs='${dirs}'")
|
||||
message(STATUS " plugins_dir='${plugins_dir}'")
|
||||
message(STATUS " request_qt_conf='${request_qt_conf}'")
|
||||
|
||||
if(QT_LIBRARY_DIR)
|
||||
list(APPEND dirs "${QT_LIBRARY_DIR}")
|
||||
endif()
|
||||
if(QT_BINARY_DIR)
|
||||
list(APPEND dirs "${QT_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(qt_conf_dir "${executable}/Contents/Resources")
|
||||
set(executable_path "${executable}")
|
||||
set(write_qt_conf TRUE)
|
||||
if(NOT plugins_dir)
|
||||
set(plugins_dir "${DeployQt5_apple_plugins_dir}")
|
||||
endif()
|
||||
else()
|
||||
get_filename_component(executable_path "${executable}" PATH)
|
||||
if(NOT executable_path)
|
||||
set(executable_path ".")
|
||||
endif()
|
||||
set(qt_conf_dir "${executable_path}")
|
||||
set(write_qt_conf ${request_qt_conf})
|
||||
endif()
|
||||
|
||||
foreach(plugin ${qtplugins})
|
||||
set(installed_plugin_path "")
|
||||
install_qt5_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
|
||||
list(APPEND libs ${installed_plugin_path})
|
||||
endforeach()
|
||||
|
||||
foreach(lib ${libs})
|
||||
if(NOT EXISTS "${lib}")
|
||||
message(FATAL_ERROR "Library does not exist: ${lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
resolve_qt5_paths(libs "${executable_path}")
|
||||
|
||||
if(write_qt_conf)
|
||||
set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
|
||||
write_qt5_conf("${qt_conf_dir}" "${qt_conf_contents}")
|
||||
endif()
|
||||
|
||||
fixup_bundle("${executable}" "${libs}" "${dirs}")
|
||||
endfunction()
|
||||
|
||||
function(install_qt5_plugin_path plugin executable copy installed_plugin_path_var)
|
||||
set(plugins_dir ${ARGV4})
|
||||
set(component ${ARGV5})
|
||||
set(configurations ${ARGV6})
|
||||
if(EXISTS "${plugin}")
|
||||
if(APPLE)
|
||||
if(NOT plugins_dir)
|
||||
set(plugins_dir "${DeployQt5_apple_plugins_dir}")
|
||||
endif()
|
||||
set(plugins_path "${executable}/Contents/${plugins_dir}")
|
||||
else()
|
||||
get_filename_component(plugins_path "${executable}" PATH)
|
||||
if(NOT plugins_path)
|
||||
set(plugins_path ".")
|
||||
endif()
|
||||
if(plugins_dir)
|
||||
set(plugins_path "${plugins_path}/${plugins_dir}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(plugin_group "")
|
||||
|
||||
get_filename_component(plugin_path "${plugin}" PATH)
|
||||
get_filename_component(plugin_parent_path "${plugin_path}" PATH)
|
||||
get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME)
|
||||
get_filename_component(plugin_name "${plugin}" NAME)
|
||||
string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name)
|
||||
|
||||
if("${plugin_parent_dir_name}" STREQUAL "plugins")
|
||||
get_filename_component(plugin_group "${plugin_path}" NAME)
|
||||
set(${plugin_group_var} "${plugin_group}")
|
||||
endif()
|
||||
set(plugins_path "${plugins_path}/${plugin_group}")
|
||||
|
||||
if(${copy})
|
||||
file(MAKE_DIRECTORY "${plugins_path}")
|
||||
file(COPY "${plugin}" DESTINATION "${plugins_path}")
|
||||
else()
|
||||
if(configurations AND (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE))
|
||||
set(configurations CONFIGURATIONS ${configurations})
|
||||
else()
|
||||
unset(configurations)
|
||||
endif()
|
||||
install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component})
|
||||
endif()
|
||||
set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(install_qt5_plugin plugin executable copy installed_plugin_path_var)
|
||||
set(plugins_dir ${ARGV4})
|
||||
set(component ${ARGV5})
|
||||
if(EXISTS "${plugin}")
|
||||
install_qt5_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
|
||||
else()
|
||||
string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
|
||||
set(plugin_release_var "${plugin_var}_RELEASE")
|
||||
set(plugin_debug_var "${plugin_var}_DEBUG")
|
||||
set(plugin_release "${${plugin_release_var}}")
|
||||
set(plugin_debug "${${plugin_debug_var}}")
|
||||
if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}")
|
||||
message(WARNING "Qt plugin \"${plugin}\" not recognized or found.")
|
||||
endif()
|
||||
if(NOT EXISTS "${${plugin_debug_var}}")
|
||||
set(plugin_debug "${plugin_release}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
|
||||
install_qt5_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel")
|
||||
install_qt5_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug")
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
|
||||
set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug})
|
||||
else()
|
||||
set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release})
|
||||
endif()
|
||||
else()
|
||||
install_qt5_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
|
||||
endif()
|
||||
endif()
|
||||
set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(install_qt5_executable executable)
|
||||
set(qtplugins ${ARGV1})
|
||||
set(libs ${ARGV2})
|
||||
set(dirs ${ARGV3})
|
||||
set(plugins_dir ${ARGV4})
|
||||
set(request_qt_conf ${ARGV5})
|
||||
set(component ${ARGV6})
|
||||
if(QT_LIBRARY_DIR)
|
||||
list(APPEND dirs "${QT_LIBRARY_DIR}")
|
||||
endif()
|
||||
if(QT_BINARY_DIR)
|
||||
list(APPEND dirs "${QT_BINARY_DIR}")
|
||||
endif()
|
||||
if(TARGET Qt5::Core)
|
||||
get_property(_locCore TARGET Qt5::Core PROPERTY LOCATION_RELEASE)
|
||||
get_filename_component(_loc ${_locCore} DIRECTORY)
|
||||
message(STATUS "Adding Qt 5 directory: ${_loc}")
|
||||
list(APPEND dirs "${_loc}")
|
||||
else()
|
||||
message(FATAL_ERROR "No Qt5::Core target found, ensure it is available")
|
||||
endif()
|
||||
if(component)
|
||||
set(component COMPONENT ${component})
|
||||
else()
|
||||
unset(component)
|
||||
endif()
|
||||
|
||||
get_filename_component(executable_absolute "${executable}" ABSOLUTE)
|
||||
if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}")
|
||||
gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type)
|
||||
elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}")
|
||||
gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type)
|
||||
endif()
|
||||
if(qtcore_type STREQUAL "system")
|
||||
set(qt_plugins_dir "")
|
||||
endif()
|
||||
|
||||
if(QT_IS_STATIC)
|
||||
message(WARNING "Qt built statically: not installing plugins.")
|
||||
else()
|
||||
if(APPLE)
|
||||
get_property(loc TARGET Qt5::QCocoaIntegrationPlugin
|
||||
PROPERTY LOCATION_RELEASE)
|
||||
install_qt5_plugin("${loc}" "${executable}" 0 installed_plugin_paths
|
||||
"PlugIns" "${component}")
|
||||
list(APPEND libs ${installed_plugin_paths})
|
||||
elseif(WIN32)
|
||||
get_property(loc TARGET Qt5::QWindowsIntegrationPlugin
|
||||
PROPERTY LOCATION_RELEASE)
|
||||
install_qt5_plugin("${loc}" "${executable}" 0 installed_plugin_paths
|
||||
"" "${component}")
|
||||
list(APPEND libs ${installed_plugin_paths})
|
||||
endif()
|
||||
foreach(plugin ${qtplugins})
|
||||
set(installed_plugin_paths "")
|
||||
install_qt5_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}")
|
||||
list(APPEND libs ${installed_plugin_paths})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
resolve_qt5_paths(libs "")
|
||||
|
||||
install(CODE
|
||||
"include(\"${DeployQt5_cmake_dir}/DeployQt5.cmake\")
|
||||
set(BU_CHMOD_BUNDLE_ITEMS TRUE)
|
||||
fixup_qt5_executable(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")"
|
||||
${component}
|
||||
)
|
||||
endfunction()
|
14
cmake/Modules/FeatureOptionsSetup.cmake
Normal file
14
cmake/Modules/FeatureOptionsSetup.cmake
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Helper functions for coupling add_feature_info() or CMAKE_DEPENDENT_OPTION() and option()
|
||||
|
||||
function(feature_option _name _description _default)
|
||||
string(CONCAT _desc "${_description} (default: ${_default})")
|
||||
option("${_name}" "${_desc}" "${_default}")
|
||||
add_feature_info("${_name}" "${_name}" "${_desc}")
|
||||
endfunction()
|
||||
|
||||
include(CMakeDependentOption)
|
||||
function(feature_option_dependent _name _description _default_opt _dependency _default_dep_not_sat)
|
||||
string(CONCAT _desc "${_description} (default: ${_default_opt}; depends on condition: ${_dependency})")
|
||||
CMAKE_DEPENDENT_OPTION("${_name}" "${_desc}" "${_default_opt}" "${_dependency}" "${_default_dep_not_sat}")
|
||||
add_feature_info("${_name}" "${_name}" "${_desc}")
|
||||
endfunction()
|
|
@ -1,129 +0,0 @@
|
|||
# - Try to find libtorrent-rasterbar
|
||||
#
|
||||
# If not using pkg-config, you can pre-set LibtorrentRasterbar_CUSTOM_DEFINITIONS
|
||||
# for definitions unrelated to Boost's separate compilation (which are already
|
||||
# decided by the LibtorrentRasterbar_USE_STATIC_LIBS variable).
|
||||
#
|
||||
# Once done this will define
|
||||
# LibtorrentRasterbar_FOUND - System has libtorrent-rasterbar
|
||||
# LibtorrentRasterbar_INCLUDE_DIRS - The libtorrent-rasterbar include directories
|
||||
# LibtorrentRasterbar_LIBRARIES - The libraries needed to use libtorrent-rasterbar
|
||||
# LibtorrentRasterbar_DEFINITIONS - Compiler switches required for using libtorrent-rasterbar
|
||||
# LibtorrentRasterbar_OPENSSL_ENABLED - libtorrent-rasterbar uses and links against OpenSSL
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
macro(_detect_boost_components _outComponets librariesList)
|
||||
string(REGEX MATCHALL "boost_[a-z_]+[-a-z]*" _boost_libraries "${librariesList}")
|
||||
string(REGEX REPLACE "boost_([a-z_]+)[-a-z]*" "\\1" ${_outComponets} "${_boost_libraries}")
|
||||
endmacro()
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_LIBTORRENT_RASTERBAR QUIET libtorrent-rasterbar)
|
||||
endif()
|
||||
|
||||
if(LibtorrentRasterbar_USE_STATIC_LIBS)
|
||||
set(LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
endif()
|
||||
|
||||
if(PC_LIBTORRENT_RASTERBAR_FOUND)
|
||||
set(LibtorrentRasterbar_DEFINITIONS ${PC_LIBTORRENT_RASTERBAR_CFLAGS})
|
||||
else()
|
||||
if(LibtorrentRasterbar_CUSTOM_DEFINITIONS)
|
||||
set(LibtorrentRasterbar_DEFINITIONS ${LibtorrentRasterbar_CUSTOM_DEFINITIONS})
|
||||
else()
|
||||
# Without pkg-config, we can't possibly figure out the correct build flags.
|
||||
# libtorrent is very picky about those. Let's take a set of defaults and
|
||||
# hope that they apply. If not, you the user are on your own.
|
||||
set(LibtorrentRasterbar_DEFINITIONS
|
||||
-DTORRENT_USE_LIBCRYPTO
|
||||
# TODO: remove the following define as it is not used since OpenSSL >= 1.1
|
||||
-DTORRENT_USE_OPENSSL
|
||||
-DBOOST_ASIO_ENABLE_CANCELIO
|
||||
-DUNICODE -D_UNICODE -D_FILE_OFFSET_BITS=64)
|
||||
endif()
|
||||
|
||||
if(NOT LibtorrentRasterbar_USE_STATIC_LIBS)
|
||||
list(APPEND LibtorrentRasterbar_DEFINITIONS
|
||||
-DTORRENT_LINKING_SHARED
|
||||
-DBOOST_SYSTEM_DYN_LINK)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "libtorrent definitions: ${LibtorrentRasterbar_DEFINITIONS}")
|
||||
|
||||
find_path(LibtorrentRasterbar_INCLUDE_DIR libtorrent
|
||||
HINTS ${PC_LIBTORRENT_RASTERBAR_INCLUDEDIR} ${PC_LIBTORRENT_RASTERBAR_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES libtorrent-rasterbar)
|
||||
|
||||
find_library(LibtorrentRasterbar_LIBRARY NAMES torrent-rasterbar libtorrent
|
||||
HINTS ${PC_LIBTORRENT_RASTERBAR_LIBDIR} ${PC_LIBTORRENT_RASTERBAR_LIBRARY_DIRS})
|
||||
|
||||
if(LibtorrentRasterbar_USE_STATIC_LIBS)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
endif()
|
||||
|
||||
set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIR})
|
||||
|
||||
# Without pkg-config, we can't possibly figure out the correct boost dependencies
|
||||
if (LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES)
|
||||
set(_boost_components "${LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES}")
|
||||
else(LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES)
|
||||
if(PC_LIBTORRENT_RASTERBAR_FOUND)
|
||||
_detect_boost_components(_boost_components "${PC_LIBTORRENT_RASTERBAR_LIBRARIES}")
|
||||
else()
|
||||
# all possible boost dependencies
|
||||
set(_boost_components
|
||||
date_time
|
||||
system
|
||||
chrono
|
||||
random
|
||||
thread
|
||||
)
|
||||
endif()
|
||||
endif(LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES)
|
||||
|
||||
list(SORT _boost_components)
|
||||
message(STATUS "Libtorrent Boost dependencies: ${_boost_components}")
|
||||
find_package(Boost REQUIRED COMPONENTS ${_boost_components})
|
||||
set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
foreach(_boost_cmpnt IN LISTS _boost_components)
|
||||
list(APPEND LibtorrentRasterbar_LIBRARIES "Boost::${_boost_cmpnt}")
|
||||
endforeach(_boost_cmpnt)
|
||||
|
||||
set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIRS})
|
||||
|
||||
list(FIND LibtorrentRasterbar_DEFINITIONS -DTORRENT_USE_OPENSSL LibtorrentRasterbar_ENCRYPTION_INDEX)
|
||||
if(LibtorrentRasterbar_ENCRYPTION_INDEX GREATER -1)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
list(APPEND LibtorrentRasterbar_INCLUDE_DIRS "${OPENSSL_INCLUDE_DIR}")
|
||||
set(LibtorrentRasterbar_OPENSSL_ENABLED ON)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LibtorrentRasterbar_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(LibtorrentRasterbar DEFAULT_MSG
|
||||
LibtorrentRasterbar_LIBRARY
|
||||
LibtorrentRasterbar_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_LIBRARY
|
||||
LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
LibtorrentRasterbar_ENCRYPTION_INDEX)
|
||||
|
||||
if (LibtorrentRasterbar_FOUND AND NOT TARGET LibtorrentRasterbar::torrent-rasterbar)
|
||||
add_library(LibtorrentRasterbar::torrent-rasterbar UNKNOWN IMPORTED)
|
||||
|
||||
set_target_properties(LibtorrentRasterbar::torrent-rasterbar PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
||||
IMPORTED_LOCATION "${LibtorrentRasterbar_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LibtorrentRasterbar_INCLUDE_DIRS}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${LibtorrentRasterbar_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${LibtorrentRasterbar_LIBRARIES}"
|
||||
INTERFACE_COMPILE_OPTIONS "${LibtorrentRasterbar_DEFINITIONS}"
|
||||
)
|
||||
endif()
|
|
@ -8,7 +8,7 @@ find_package(PkgConfig QUIET REQUIRED)
|
|||
|
||||
if (NOT SYSTEMD_FOUND)
|
||||
pkg_check_modules(SYSTEMD "systemd")
|
||||
endif(NOT SYSTEMD_FOUND)
|
||||
endif()
|
||||
|
||||
if (SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "")
|
||||
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
||||
|
@ -23,4 +23,4 @@ endif()
|
|||
|
||||
if (SYSTEMD_FOUND)
|
||||
message(STATUS "systemd services install dir: ${SYSTEMD_SERVICES_INSTALL_DIR}")
|
||||
endif(SYSTEMD_FOUND)
|
||||
endif()
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
# Function for ensuring the build does not use a lower than the required minimum C++ mode, _min_std.
|
||||
# It fails the build if:
|
||||
# - the compiler does not fully support _min_std
|
||||
# - the user specified a mode lower than _min_std via the CMAKE_CXX_STANDARD variable
|
||||
# If both checks are successful, it sets the following variables at the PARENT_SCOPE:
|
||||
# - CMAKE_CXX_STANDARD with the value _min_std, if it was not already set to a value >= _min_std
|
||||
# - CMAKE_CXX_STANDARD_REQUIRED with the value ON
|
||||
|
||||
function(qbt_minimum_cxx_mode_check _min_std)
|
||||
# ensure the compiler fully supports the minimum required C++ mode.
|
||||
if(NOT CMAKE_CXX${_min_std}_STANDARD__HAS_FULL_SUPPORT)
|
||||
message(FATAL_ERROR "${PROJECT_NAME} requires a compiler with full C++${_min_std} support")
|
||||
endif()
|
||||
|
||||
# now we know that the compiler fully supports the minimum required C++ mode,
|
||||
# but we must still prevent the user or compiler from forcing/defaulting to an insufficient C++ mode
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD ${_min_std} PARENT_SCOPE)
|
||||
elseif((CMAKE_CXX_STANDARD VERSION_LESS ${_min_std}) OR (CMAKE_CXX_STANDARD VERSION_EQUAL 98))
|
||||
message(FATAL_ERROR "${PROJECT_NAME} has to be built with at least C++${_min_std} mode.")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE)
|
||||
endfunction()
|
|
@ -1,28 +0,0 @@
|
|||
# function for parsing version variables that are set in version.pri file
|
||||
# the version identifiers there are defined as follows:
|
||||
# VER_MAJOR = 3
|
||||
# VER_MINOR = 4
|
||||
# VER_BUGFIX = 0
|
||||
# VER_BUILD = 0
|
||||
# VER_STATUS = alpha
|
||||
|
||||
function(read_version priFile outMajor outMinor outBugfix outBuild outStatus)
|
||||
file(STRINGS ${priFile} _priFileContents REGEX "^VER_.+")
|
||||
# message(STATUS "version.pri version contents: ${_priFileContents}")
|
||||
# the _priFileContents variable contains something like the following:
|
||||
# VER_MAJOR = 3;VER_MINOR = 4;VER_BUGFIX = 0;VER_BUILD = 0;VER_STATUS = alpha # Should be empty for stable releases!
|
||||
set(_regex "VER_MAJOR += +([0-9]+);VER_MINOR += +([0-9]+);VER_BUGFIX += +([0-9]+);VER_BUILD += +([0-9]+);VER_STATUS += +([0-9A-Za-z]+)?")
|
||||
# note quotes around _regex, they are needed because the variable contains semicolons
|
||||
string(REGEX MATCH "${_regex}" _tmp "${_priFileContents}")
|
||||
if (NOT _tmp)
|
||||
message(FATAL_ERROR "Could not detect project version number from ${priFile}")
|
||||
endif()
|
||||
|
||||
# message(STATUS "Matched version string: ${_tmp}")
|
||||
|
||||
set(${outMajor} ${CMAKE_MATCH_1} PARENT_SCOPE)
|
||||
set(${outMinor} ${CMAKE_MATCH_2} PARENT_SCOPE)
|
||||
set(${outBugfix} ${CMAKE_MATCH_3} PARENT_SCOPE)
|
||||
set(${outBuild} ${CMAKE_MATCH_4} PARENT_SCOPE)
|
||||
set(${outStatus} ${CMAKE_MATCH_5} PARENT_SCOPE)
|
||||
endfunction()
|
|
@ -1,36 +0,0 @@
|
|||
macro(configure_msvc_runtime)
|
||||
# Default to statically-linked runtime.
|
||||
if("${MSVC_RUNTIME}" STREQUAL "")
|
||||
set(MSVC_RUNTIME "static")
|
||||
endif()
|
||||
# Set compiler options.
|
||||
set(variables
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
)
|
||||
if(${MSVC_RUNTIME} STREQUAL "static")
|
||||
message(STATUS
|
||||
"MSVC -> forcing use of statically-linked runtime."
|
||||
)
|
||||
foreach(variable ${variables})
|
||||
if(${variable} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
message(STATUS
|
||||
"MSVC -> forcing use of dynamically-linked runtime."
|
||||
)
|
||||
foreach(variable ${variables})
|
||||
if(${variable} MATCHES "/MT")
|
||||
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
|
@ -1,28 +0,0 @@
|
|||
# - macro similar to target_link_libraries, which links Qt components
|
||||
# names of the components are passed in Qt4/Qt5 agnostic way (Core, DBus, Xml...)
|
||||
# and the macro links Qt4 ones if QT4_FOUND is set or Qt5 ones if not
|
||||
|
||||
macro (target_link_qt_components target)
|
||||
if (QT4_FOUND)
|
||||
foreach(_cmp ${ARGN})
|
||||
if ("${_cmp}" STREQUAL "PRIVATE" OR
|
||||
"${_cmp}" STREQUAL "PUBLIC" OR
|
||||
"${_cmp}" STREQUAL "INTERFACE")
|
||||
list(APPEND _QT_CMPNTS "${_cmp}")
|
||||
else()
|
||||
list(APPEND _QT_CMPNTS "Qt4::Qt${_cmp}")
|
||||
endif()
|
||||
endforeach()
|
||||
else (QT4_FOUND)
|
||||
foreach(_cmp ${ARGN})
|
||||
if ("${_cmp}" STREQUAL "PRIVATE" OR
|
||||
"${_cmp}" STREQUAL "PUBLIC" OR
|
||||
"${_cmp}" STREQUAL "INTERFACE")
|
||||
list(APPEND _QT_CMPNTS "${_cmp}")
|
||||
else()
|
||||
list(APPEND _QT_CMPNTS "Qt5::${_cmp}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif (QT4_FOUND)
|
||||
target_link_libraries(${target} ${_QT_CMPNTS})
|
||||
endmacro()
|
102
cmake/Modules/MacroQbtCommonConfig.cmake
Normal file
102
cmake/Modules/MacroQbtCommonConfig.cmake
Normal file
|
@ -0,0 +1,102 @@
|
|||
# Set common variables and create some interface-only library targets
|
||||
# that some or all other targets will link to, either directly or transitively,
|
||||
# to consume common compile options/definitions
|
||||
|
||||
macro(qbt_common_config)
|
||||
|
||||
# treat value specified by the CXX_STANDARD target property as a requirement by default
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# these definitions are only needed for calls to
|
||||
# lt::generate_fingerprint and for the qbittorrent.rc file on Windows
|
||||
add_library(qbt_version_definitions INTERFACE)
|
||||
|
||||
target_compile_definitions(qbt_version_definitions INTERFACE
|
||||
QBT_VERSION_MAJOR=${qBittorrent_VERSION_MAJOR}
|
||||
QBT_VERSION_MINOR=${qBittorrent_VERSION_MINOR}
|
||||
QBT_VERSION_BUGFIX=${qBittorrent_VERSION_PATCH}
|
||||
QBT_VERSION_BUILD=${qBittorrent_VERSION_TWEAK}
|
||||
)
|
||||
|
||||
add_library(qbt_common_cfg INTERFACE)
|
||||
|
||||
# Full C++ 14 support is required
|
||||
# See also https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
|
||||
# for a breakdown of the features that CMake recognizes for each C++ standard
|
||||
target_compile_features(qbt_common_cfg INTERFACE
|
||||
cxx_std_14
|
||||
cxx_aggregate_default_initializers
|
||||
cxx_attribute_deprecated
|
||||
cxx_binary_literals
|
||||
cxx_contextual_conversions
|
||||
cxx_decltype_auto
|
||||
cxx_digit_separators
|
||||
cxx_generic_lambdas
|
||||
cxx_lambda_init_captures
|
||||
cxx_relaxed_constexpr
|
||||
cxx_return_type_deduction
|
||||
cxx_variable_templates
|
||||
)
|
||||
|
||||
set(QBT_FULL_VERSION "${qBittorrent_VERSION}${QBT_VER_STATUS}")
|
||||
|
||||
target_compile_definitions(qbt_common_cfg INTERFACE
|
||||
QBT_VERSION="v${QBT_FULL_VERSION}"
|
||||
QBT_VERSION_2="${QBT_FULL_VERSION}"
|
||||
QT_DEPRECATED_WARNINGS
|
||||
QT_NO_CAST_TO_ASCII
|
||||
QT_NO_CAST_FROM_BYTEARRAY
|
||||
QT_USE_QSTRINGBUILDER
|
||||
QT_STRICT_ITERATORS
|
||||
$<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>
|
||||
)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_compile_definitions(qbt_common_cfg INTERFACE
|
||||
NTDDI_VERSION=0x06010000
|
||||
_WIN32_WINNT=0x0601
|
||||
_WIN32_IE=0x0601
|
||||
WIN32_LEAN_AND_MEAN
|
||||
NOMINMAX
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
endif()
|
||||
|
||||
if ((CXX_COMPILER_ID STREQUAL "GNU") OR (CXX_COMPILER_ID STREQUAL "Clang") OR (CXX_COMPILER_ID STREQUAL "AppleClang"))
|
||||
target_compile_options(qbt_common_cfg INTERFACE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wcast-qual
|
||||
-Wcast-align
|
||||
-Winvalid-pch
|
||||
-Woverloaded-virtual
|
||||
-Wold-style-cast
|
||||
-Wnon-virtual-dtor
|
||||
-pedantic
|
||||
-pedantic-errors
|
||||
)
|
||||
|
||||
# Clang 11 still doesn't support -Wstrict-null-sentinel
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag(-Wstrict-null-sentinel SNS_SUPPORT)
|
||||
if (SNS_SUPPORT)
|
||||
target_compile_options(qbt_common_cfg INTERFACE -Wstrict-null-sentinel)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (MINGW)
|
||||
target_link_options(qbt_common_cfg INTERFACE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:LINKER:--dynamicbase>)
|
||||
endif()
|
||||
|
||||
if (MSVC_RUNTIME_DYNAMIC)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
else()
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
endif()
|
||||
|
||||
if (CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
target_compile_options(qbt_common_cfg INTERFACE /MP)
|
||||
endif()
|
||||
|
||||
endmacro(qbt_common_config)
|
|
@ -1,69 +0,0 @@
|
|||
# Sets cache variable QBT_ADDITIONAL_FLAGS and QBT_ADDITONAL_CXX_FLAGS to list of additional
|
||||
# compiler flags for C and C++ (QBT_ADDITIONAL_FLAGS) and for C++ only (QBT_ADDITONAL_CXX_FLAGS)
|
||||
# and appends them to CMAKE_XXX_FLAGS variables.
|
||||
|
||||
# It could use add_compile_options(), but then it is needed to use generator expressions,
|
||||
# and most interesting of them are not compatible with Visual Studio :(
|
||||
|
||||
macro(qbt_set_compiler_options)
|
||||
# if (NOT QBT_ADDITIONAL_FLAGS)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
#-Wshadow -Wconversion ?
|
||||
set(_GCC_COMMON_C_AND_CXX_FLAGS "-Wall -Wextra"
|
||||
"-Wcast-qual -Wcast-align"
|
||||
"-Winvalid-pch -Wno-long-long"
|
||||
#"-fstack-protector-all"
|
||||
#"-Werror -Wno-error=deprecated-declarations"
|
||||
)
|
||||
set(_GCC_COMMON_CXX_FLAGS "-fexceptions -frtti"
|
||||
"-Woverloaded-virtual -Wold-style-cast"
|
||||
"-Wnon-virtual-dtor"
|
||||
#"-Weffc++"
|
||||
#"-Werror -Wno-error=cpp"
|
||||
# we should modify code to make these ones obsolete
|
||||
#"-Wno-error=sign-conversion -Wno-error=float-equal"
|
||||
)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
# check for -pedantic
|
||||
check_cxx_compiler_flag(-pedantic _PEDANTIC_IS_SUPPORTED)
|
||||
if (_PEDANTIC_IS_SUPPORTED)
|
||||
list(APPEND _GCC_COMMON_CXX_FLAGS "-pedantic -pedantic-errors")
|
||||
else (_PEDANTIC_IS_SUPPORTED)
|
||||
list(APPEND _GCC_COMMON_CXX_FLAGS "-Wpedantic")
|
||||
endif (_PEDANTIC_IS_SUPPORTED)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||
add_definitions(-D_DEFAULT_SOURCE)
|
||||
endif()
|
||||
|
||||
# Clang 5.0 still doesn't support -Wstrict-null-sentinel
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
check_cxx_compiler_flag(-Wstrict-null-sentinel _STRICT_NULL_SENTINEL_IS_SUPPORTED)
|
||||
if (_STRICT_NULL_SENTINEL_IS_SUPPORTED)
|
||||
list(APPEND _GCC_COMMON_CXX_FLAGS "-Wstrict-null-sentinel")
|
||||
endif (_STRICT_NULL_SENTINEL_IS_SUPPORTED)
|
||||
|
||||
# Code should be improved to render this not needed
|
||||
list(APPEND _GCC_COMMON_CXX_FLAGS "-Wno-error=unused-function")
|
||||
else ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
# GCC supports it
|
||||
list(APPEND _GCC_COMMON_CXX_FLAGS "-Wstrict-null-sentinel")
|
||||
endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
|
||||
string(REPLACE ";" " " _GCC_COMMON_C_AND_CXX_FLAGS_STRING "${_GCC_COMMON_C_AND_CXX_FLAGS}")
|
||||
string(REPLACE ";" " " _GCC_COMMON_CXX_FLAGS_STRING "${_GCC_COMMON_CXX_FLAGS}")
|
||||
|
||||
string(APPEND CMAKE_C_FLAGS " ${_GCC_COMMON_C_AND_CXX_FLAGS_STRING}")
|
||||
string(APPEND CMAKE_CXX_FLAGS " ${_GCC_COMMON_C_AND_CXX_FLAGS_STRING} ${_GCC_COMMON_CXX_FLAGS_STRING}")
|
||||
endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
set(QBT_ADDITIONAL_FLAGS "/wd4251 /wd4275 /wd4290" CACHE STRING "Additional qBittorent compile flags")
|
||||
endif ()
|
||||
|
||||
string(APPEND CMAKE_C_FLAGS " ${QBT_ADDITIONAL_FLAGS}")
|
||||
string(APPEND CMAKE_CXX_FLAGS " ${QBT_ADDITIONAL_FLAGS}")
|
||||
|
||||
# endif (NOT QBT_ADDITIONAL_FLAGS)
|
||||
endmacro(qbt_set_compiler_options)
|
|
@ -1,17 +0,0 @@
|
|||
# a helper function which appends source to the target
|
||||
# sources file names are relative to the the target source dir
|
||||
|
||||
function (qbt_target_sources _target _scope)
|
||||
get_target_property(targetSourceDir ${_target} SOURCE_DIR)
|
||||
set(sourcesRelative "")
|
||||
foreach(source IN ITEMS ${ARGN})
|
||||
if(IS_ABSOLUTE "${source}")
|
||||
set(sourceAbsolutePath "${source}")
|
||||
else()
|
||||
get_filename_component(sourceAbsolutePath "${source}" ABSOLUTE)
|
||||
endif()
|
||||
file(RELATIVE_PATH sourceRelativePath "${targetSourceDir}" "${sourceAbsolutePath}")
|
||||
list(APPEND sourcesRelative "${sourceRelativePath}")
|
||||
endforeach()
|
||||
target_sources(${_target} ${_scope} "${sourcesRelative}")
|
||||
endfunction(qbt_target_sources)
|
|
@ -1,48 +0,0 @@
|
|||
# macros to handle translation files
|
||||
|
||||
# qbt_add_translations(<target> QRC_FILE <filename> TS_FILES <filenames>)
|
||||
# handles out of source builds for Qt resource files that include translations
|
||||
# The function generates translations out of the supplied list of .ts files in the build directory,
|
||||
# copies the .qrc file there, calls qt5_add_resources() adds its output to the target sources list.
|
||||
function(qbt_add_translations _target)
|
||||
set(oneValueArgs QRC_FILE)
|
||||
set(multiValueArgs TS_FILES)
|
||||
cmake_parse_arguments(QBT_TR "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
get_target_property(_binaryDir ${_target} BINARY_DIR)
|
||||
|
||||
if (NOT QBT_TR_QRC_FILE)
|
||||
message(FATAL_ERROR "QRC file is empty")
|
||||
endif()
|
||||
if (NOT QBT_TR_TS_FILES)
|
||||
message(FATAL_ERROR "TS_FILES files are empty")
|
||||
endif()
|
||||
|
||||
if(IS_ABSOLUTE "${QBT_TR_QRC_FILE}")
|
||||
file(RELATIVE_PATH _qrcToTs "${CMAKE_CURRENT_SOURCE_DIR}" "${QBT_TR_QRC_FILE}")
|
||||
else()
|
||||
set(_qrcToTs "${QBT_TR_QRC_FILE}")
|
||||
endif()
|
||||
|
||||
get_filename_component(_qrcToTsDir "${_qrcToTs}" DIRECTORY)
|
||||
|
||||
get_filename_component(_qmFilesBinaryDir "${CMAKE_CURRENT_BINARY_DIR}/${_qrcToTsDir}" ABSOLUTE)
|
||||
# to make qt5_add_translation() work as we need
|
||||
set_source_files_properties(${QBT_TR_TS_FILES} PROPERTIES OUTPUT_LOCATION "${_qmFilesBinaryDir}")
|
||||
qt5_add_translation(_qmFiles ${QBT_TR_TS_FILES})
|
||||
|
||||
set(_qrc_dest_dir "${_binaryDir}/${_qrcToTsDir}")
|
||||
set(_qrc_dest_file "${_binaryDir}/${QBT_TR_QRC_FILE}")
|
||||
|
||||
message(STATUS "copying ${QBT_TR_QRC_FILE} to ${_qrc_dest_dir}")
|
||||
file(COPY ${QBT_TR_QRC_FILE} DESTINATION ${_qrc_dest_dir})
|
||||
|
||||
set_source_files_properties("${_qrc_dest_file}" PROPERTIES
|
||||
GENERATED True
|
||||
OBJECT_DEPENDS "${_qmFiles}")
|
||||
|
||||
# With AUTORCC enabled rcc is ran by cmake before language files are generated,
|
||||
# and thus we call rcc explicitly
|
||||
qt5_add_resources(_resources "${_qrc_dest_file}")
|
||||
target_sources(${_target} PRIVATE "${_resources}")
|
||||
endfunction()
|
|
@ -1,21 +0,0 @@
|
|||
set(BU_CHMOD_BUNDLE_ITEMS ON)
|
||||
include(DeployQt5)
|
||||
|
||||
set(plugins "")
|
||||
|
||||
get_property(svgIconPluginLocation TARGET Qt5::QSvgIconPlugin
|
||||
PROPERTY LOCATION_RELEASE)
|
||||
list(APPEND plugins "${svgIconPluginLocation}")
|
||||
get_property(svgPluginLocation TARGET Qt5::QSvgPlugin
|
||||
PROPERTY LOCATION_RELEASE)
|
||||
list(APPEND plugins "${svgPluginLocation}")
|
||||
|
||||
set(sfx "")
|
||||
if(APPLE)
|
||||
set(sfx ".app")
|
||||
elseif(WIN32)
|
||||
set(sfx "${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
endif()
|
||||
|
||||
get_target_property(exe qBittorrent OUTPUT_NAME)
|
||||
install_qt5_executable("${exe}${sfx}" "${plugins}" "" "" "")
|
|
@ -1,11 +0,0 @@
|
|||
if (("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo"))
|
||||
link_libraries(-Wl,--dynamicbase)
|
||||
endif ()
|
||||
|
||||
list(APPEND LibtorrentRasterbar_CUSTOM_DEFINITIONS
|
||||
-D_FILE_OFFSET_BITS=64
|
||||
-D__USE_W32_SOCKETS)
|
||||
|
||||
# libraries from winconf.pri
|
||||
link_libraries(advapi32 iphlpapi ole32 shell32 user32 wsock32 ws2_32)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
include(MacroConfigureMSVCRuntime)
|
||||
set(MSVC_RUNTIME "dynamic")
|
||||
configure_msvc_runtime()
|
||||
|
||||
# libraries from winconf.pri
|
||||
link_libraries(advapi32 crypt32 Iphlpapi ole32 shell32 User32)
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
# Settings for compiling qBittorrent on Windows
|
||||
|
||||
list(APPEND CMAKE_LIBRARY_PATH "$ENV{LIB}")
|
||||
|
||||
set(LibtorrentRasterbar_CUSTOM_DEFINITIONS
|
||||
-DBOOST_ASIO_DISABLE_CONNECTEX
|
||||
-DBOOST_EXCEPTION_DISABLE
|
||||
-DTORRENT_USE_LIBCRYPTO
|
||||
# TODO: remove the following define as it is not used since OpenSSL >= 1.1
|
||||
-DTORRENT_USE_OPENSSL
|
||||
# TODO: remove the following define as it is not used since libtorrent >= 1.2
|
||||
-DTORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
)
|
||||
|
||||
set(LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES system)
|
||||
|
||||
# If you want to link with static version of libtorrent
|
||||
#set(LibtorrentRasterbar_USE_STATIC_LIBS True)
|
||||
#list(APPEND LibtorrentRasterbar_CUSTOM_DEFINITIONS
|
||||
# -DBOOST_SYSTEM_STATIC_LINK=1)
|
||||
|
||||
# and boost
|
||||
#set(Boost_USE_STATIC_LIBS True)
|
||||
#set(Boost_USE_STATIC_RUNTIME True)
|
||||
|
||||
add_definitions(
|
||||
-DNTDDI_VERSION=0x06010000
|
||||
-D_WIN32_WINNT=0x0601
|
||||
-D_WIN32_IE=0x0601
|
||||
-DUNICODE
|
||||
-D_UNICODE
|
||||
-DWIN32
|
||||
-D_WIN32
|
||||
-DWIN32_LEAN_AND_MEAN
|
||||
-D_CRT_SECURE_NO_DEPRECATE
|
||||
-D_SCL_SECURE_NO_DEPRECATE
|
||||
-DNOMINMAX
|
||||
-DBOOST_ALL_NO_LIB
|
||||
)
|
||||
|
||||
# Enable if libtorrent was built with this flag defined
|
||||
#list(APPEND LibtorrentRasterbar_CUSTOM_DEFINITIONS -DTORRENT_NO_DEPRECATE)
|
||||
|
||||
if (("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo"))
|
||||
list(APPEND LibtorrentRasterbar_CUSTOM_DEFINITIONS
|
||||
-DTORRENT_DEBUG)
|
||||
else ()
|
||||
add_definitions(-DNDEBUG)
|
||||
endif ()
|
||||
|
||||
# Here we assume that all required libraries are installed into the same prefix
|
||||
# with usual unix subdirectories (bin, lib, include)
|
||||
# if so, we just need to set CMAKE_SYSTEM_PREFIX_PATH
|
||||
# If it is not the case, individual paths need to be specified manually (see below)
|
||||
set(COMMON_INSTALL_PREFIX "c:/usr" CACHE PATH "Prefix used to install all the required libraries")
|
||||
list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${COMMON_INSTALL_PREFIX}")
|
||||
|
||||
# If two version of Qt are installed, separate prefixes are needed most likely
|
||||
set(QT5_INSTALL_PREFIX "${COMMON_INSTALL_PREFIX}/lib/qt5" CACHE PATH "Prefix where Qt5 is installed")
|
||||
|
||||
# it is safe to set Qt dirs even if their files are directly in the prefix
|
||||
set(Qt5_DIR "${QT5_INSTALL_PREFIX}/lib/cmake/Qt5")
|
||||
|
||||
# And now we can set specific values for the Boost and libtorrent libraries.
|
||||
# The following values are generated from the paths listed above just for an example
|
||||
# they have to be set to actual locations
|
||||
|
||||
# Boost
|
||||
# set(BOOST_ROOT "${COMMON_INSTALL_PREFIX}")
|
||||
# set(Boost_version_suffix "1_59")
|
||||
# if a link like boost-version/boost -> boost was created or the boost directory was renamed in the same way,
|
||||
# the following needs adjustment
|
||||
# set(BOOST_INCLUDEDIR "${COMMON_INSTALL_PREFIX}/include/boost-${Boost_version_suffix}")
|
||||
# set(BOOST_LIBRARYDIR "${COMMON_INSTALL_PREFIX}/lib/")
|
||||
|
||||
# libtorrent
|
||||
|
||||
# set(PC_LIBTORRENT_RASTERBAR_INCLUDEDIR "${COMMON_INSTALL_PREFIX}")
|
||||
# set(PC_LIBTORRENT_RASTERBAR_LIBDIR "${COMMON_INSTALL_PREFIX}/lib")
|
||||
|
||||
set(AUTOGEN_TARGETS_FOLDER "generated")
|
||||
|
||||
set(CMAKE_INSTALL_BINDIR ".")
|
||||
|
||||
# Test 32/64 bits
|
||||
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||
message(STATUS "Target is 64 bits")
|
||||
if (WIN32)
|
||||
set(WINXXBITS Win64)
|
||||
endif(WIN32)
|
||||
else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||
message(STATUS "Target is 32 bits")
|
||||
if (WIN32)
|
||||
set(WINXXBITS Win32)
|
||||
endif(WIN32)
|
||||
endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||
|
||||
if (MSVC)
|
||||
include(winconf-msvc)
|
||||
else (MSVC)
|
||||
include(winconf-mingw)
|
||||
endif (MSVC)
|
Loading…
Add table
Add a link
Reference in a new issue