From 02759049aad1ea8ccaf01cddfa594b14e3c6ed9b Mon Sep 17 00:00:00 2001 From: Francisco Pombal Date: Sun, 20 Sep 2020 00:34:36 +0100 Subject: [PATCH] Destroyed Compilation: CMake (mediawiki) --- Compilation:-CMake.mediawiki | 134 ----------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 Compilation:-CMake.mediawiki diff --git a/Compilation:-CMake.mediawiki b/Compilation:-CMake.mediawiki deleted file mode 100644 index e82c3ba..0000000 --- a/Compilation:-CMake.mediawiki +++ /dev/null @@ -1,134 +0,0 @@ -This guide briefly overviews how to compile (and install) qBittorrent using CMake build system on Linux and Windows. The guide does not go into details how to install particulars software packages or how to compile them. One can gather this information from the other compilation guides in this wiki. This is not a step-by-step guide. - -== What you will need: == -* A C++ compiler, supported by CMake. -* CMake, version 3.16 or newer. Get it from your packages repository or download an installer from the CMake [https://cmake.org website] -* Installed Qt, libtorrent and their dependencies (Boost, zlib, openssl). Please note that Boost support in CMake is version-explicit, and thus CMake version has to be younger than the Boost version or, otherwise, CMake might not recognize boost libraries. -* Development files (headers and libraries) for Qt, libtorrent, and Boost. - -=== Windows-specific installation note. === -Things will be easier if you install all the dependencies into the same prefix, for instance into c:\usr. This complicates uninstalling, but you receive the following advantages: %PREFIX%/include and %PREFIX%/lib can be added to your compiler search paths and you don't need to care about every library; CMake can be instructed to look for the libraries in this prefix (once for all of them). - -== Out-of-source builds == -CMake encourage you to use so called out-of-source builds (i.e. build into a different directory than the one with source files). In fact, CMake does not even provide a "clean" command to remove generated files --- you simply delete the build directory (do not confuse with a "clean" command of the build system, which removes files, generatad during a build, this CMake does provide). You may have different build directories, configured with options (see below). And, of course, you do not pollute your sources, that are always ready for git diff. - -== Configuring and generating build files == -CMake does not build a project by itself. Instead it generates rules for an actual build software. These generators include traditional makefiles as well as other platform-specific (like XCode or Visual Studio) or not (Ninja) build tools. At the same time CMake projects can be integrated with IDEs. This is done in two ways: either CMake generates project files, which include call to CMake itself to update those files if needed, or an IDE may load CMake project structure directly. The generators for Visual Studio and XCode implement the former approach, while Qt Creator, KDevelop and Visual Studio 2017 use the latter model. Before continuing you have to decide which generator you will use and will you integrate with an IDE or not. You may get a list of available generators running cmake -G or cmake --help -=== IDE Support === -;Qt Creator -: This IDE can just open the top-level project CMakeLists.txt file and load the project structure. Then it will ask you where to put build files and which make tool to use. Please note that Ninja will give you significantly shorter rebuild times, as comparing to a regular make. From version 4.3 of Qt Creator and 3.7 of CMake, support is excellent (see this [https://blog.qt.io/blog/2016/11/15/cmake-support-in-qt-creator-and-elsewhere/ blog post] for details). -;Clion -: Same as Qt Creator. -;KDevelop -: KDevelop from version 4 provides excellent support for CMake-based projects, simply open the top-level project CMakeLists.txt file and select a build directory. -;XCode -: You have to use "XCode" generator to generate project files. Then when any of the CMake project files get updated, the next build command will re-generate the XCode projects and XCode will reload them. -;Visual Studio -: Full integration from 2017 version, otherwise you have to use "Visual Studio" generator to generate project files. Then when any of the CMake project files get updated, the next build command will re-generate the projects files and Visual Studio will ask to reload them. - -With the generator selected, you have to do one of the following: -;No IDE -: Create build directory. For example, it can be a sub-directory of the source directory, like build/debug for a debug build. Cd into that directory and issue a command: -: cmake -G -D -D . If your build directory is as above (build/debug), the command may be: -: cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DSYSTEM_QTSINGLEAPPLICATION=ON ../... For the list of supported by qBittorrent and CMake options (and where to look them up) see below. -;Visual Studio -: Create build directory. This directory will contain Visual Studio project files as well. Cd into that directory and issue a command: -: cmake -G "Visual Studio xxxx" -D -D . If your build directory is as above (build/debug), the command may be: -: cmake -G "Visual Studio 2015" -DSYSTEM_QTSINGLEAPPLICATION=ON ../... For the list of supported by qBittorrent and CMake options (and where to look them up) see below. -;XCode -: Same as for Visual Studio, replace generator with "XCode". -;KDevelop, Qt Creator -: Open the top level CMakeLists.txt file. When the IDE asks you for options, enter -D -D into the input field. The options might be, for instance: -DQT5=ON -DSYSTEM_QTSINGLEAPPLICATION=ON -=== Configuring === -When you run cmake either directly or via an IDE, it will perform tasks similar to those done be automake's configure script: it will detect environment, try to find all the needed dependencies and generate build files. One might get errors from CMake at this step if it is unable to find a package (library file or include headers). In case of UNIX (Linux or OSX) this usually mean that the package is indeed not installed, while on Windows you might need to change configuration options or edit the files manually (see the next section). - -====Configuring on Windows==== -There is no common place for software installation as well as no a common way to share development requirements (like, for instance, pkgconfig). As such, there is no way to pass required information automatically. Therefore, qBittorrent provides a reasonable defaults, and you can override them via CMake options in its cache (via command line or GUI tools) or in the cmake\Modules\winconf.cmake file. - -The defaults describe the following build environment: -# All the prerequisites are installed into the same prefix (same directory) with exception for two versions of Qt installed simultaneously, see below. This path will be referenced as %PREFIX% below -# %PREFIX% is c:\usr by default. -# Qt is installed into %PREFIX%\lib\qt5. -# Boost libraries are linked statically. - -To change these defaults, either pass listed below parameters to cmake for configure state, or edit them in cmake\Modules\winconf.cmake file. CMake variable names are given below: -# To set boost location, use BOOST_ROOT variable (-DBOST_ROOT=). Alternatively, you may set include and librariess directories independently(BOOST_INCLUDEDIR and BOOST_LIBRARYDIR. To set libtorrent location, use -DPC_LIBTORRENT_RASTERBAR_INCLUDEDIR= and -DPC_LIBTORRENT_RASTERBAR_LIBDIR=. -# Pass -DCOMMON_INSTALL_PREFIX=. -# Set QT5_INSTALL_PREFIX. -# set Boost_USE_STATIC_LIBS to False to change the default setting. - -It is recommended to use the single prefix for all libraries, and change only that path when needed. - -====Configuring on macOS==== -If you are using [https://brew.sh homebrew], then chances are some of the libraries that are dependencies will not be linked to your `usr/local/*`. In this case, you will need to add some environment variables to your shell profile. - -E.g. -``` -# using homebrew to install dependecies -brew install qt openssl -# use ~/.bashrc if you are using bash -echo export Qt5_DIR=\"/usr/local/opt/qt\" >> ~/.zshrc -echo export OPENSSL_ROOT_DIR=\"/usr/local/opt/openssl\" >> ~/.zshrc -source ~/.zshrc -``` - -===Errors during configuration stage=== -CMake may report errors during the configuration stage. Most likely those errors arise when CMake is unable to find a dependency, either because it does not know where to look for it, or it is indeed absent. - -===Summary of qBittorrent configuration options=== -Here are the options that you can use to change to tune qBittorent build for your needs. The options may be passed to cmake via -D as well as may be changed in the build cache later via ccmake, cmake-gui, or your IDE (the build cache is located in your build dir). -{| -|+ QBittorrent CMake build options. -!Name -!Type -!Description -!Default value -!Conditions if any -|- -| SYSTEM_QTSINGLEAPPLICATION -| bool -| Whether to link to the system (already installed) qtsingleapplication library, or use the bundled one. -| False -| -|- -| CMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets -| bool -| Disable graphical user interface -| False -| -|- -| WEBUI -| bool -| Enable Web interface -| True -| -|- -| STACKTRACE_WIN -| bool -| Enable stacktrace in crash reports -| False -| Windows -|- -| SYSTEMD -| bool -| Install the systemd service file -| False -| not Windows, -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=ON, systemd installed -|- -| Systemd_SERVICES_INSTALL_DIR -| path (optional) -| Custom path for the installion of the systemd service file -| /lib/systemd/systemd (TODO: should be changed in the future) -| -DSYSTEMD=ON -|} - -== Compiling == -When configure phase completes successfully, CMake generates build control files for your chosen build tool. Those might be Makefiles, Ninja rules or your IDE project files. At this stage run your tool of choice in the build directory to build qBittorrent or use your IDE command. Take a look at [https://cmake.org/cmake/help/v3.5/variable/CMAKE_BUILD_TYPE.html CMAKE_BUILD_TYPE] variable to control debug/release build kind. - -===Changing build options=== -If you want to change any of the listed above CMake options, there is no need to run cmake again with all the options in the command line. Just use ccmake, cmake-gui, or your IDE to edit those options in the cmake cache (located in the build directory), and the next build command (e.g. make) will run cmake to reflect the option change automatically. Alternatively, you may use several build directories with different set op options (and IDEs like KDevelop and QtCreator allows one to switch between build directories). - -==Installing== -To install built software, either use install target (i.e. make install) or your IDE command (or "build" project named 'INSTALL' in Visual Studio). - -To control installation dir, use [https://cmake.org/cmake/help/v3.5/variable/CMAKE_INSTALL_PREFIX.html CMAKE_INSTALL_PREFIX] (and DESTDIR for UNIX systems).