diff --git a/.gitignore b/.gitignore index 9ffa696ff8..d3ee55d433 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,7 @@ CMakePresets.json CMakeUserPresets.json .vs/ out/ + +# vcpkg +vcpkg_installed*/ + diff --git a/CMakeLists.txt b/CMakeLists.txt index 252e61fbd6..65a8820751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -cmake_minimum_required(VERSION 3.3.0) +cmake_minimum_required(VERSION 3.10.0) project(KeePassXC) set(APP_ID "org.keepassxc.${PROJECT_NAME}") diff --git a/INSTALL.md b/INSTALL.md index bc1a4ed5b6..3f2a419d05 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,34 +6,21 @@ For more information, see also the [_Building KeePassXC_](https://github.com/kee The [QuickStart Guide](https://keepassxc.org/docs/KeePassXC_GettingStarted.html) gets you started using KeePassXC on your Windows, macOS, or Linux computer using pre-compiled binaries from the [downloads page](https://keepassxc.org/download). -Build Dependencies -================== +Toolchain and Build Dependencies +================================ -The following tools must exist within your PATH: +The following build tools must exist within your PATH: -* make -* cmake (>= 3.3.0) -* g++ (>= 4.7) or clang++ (>= 6.0) +* cmake (>= 3.16.0) +* make (>= 4.2) or ninja (>= 1.10) +* g++ (>= 4.9) or clang++ (>= 6.0) * asciidoctor (>= 2.0) -The following libraries are required: - -* Qt 5 (>= 5.9.5): qtbase5, qtbase5-private, libqt5svg5, qttools5, qt5-image-formats-plugins -* botan (>= 2.12) -* libargon2 -* zlib -* minizip -* readline (for completion in cli) -* qtx11extras, libxi, and libxtst (for auto-type on X11) -* qrencode -* libusb-1.0, pcsc-lite (for Yubikey support on Linux) +* Besides a working C++ toolchain, KeePassXC also has a number of direct build and runtime dependencies. For detailed information about how to install them, please refer to the GitHub wiki: -Prepare the Building Environment -================================ - -* [Building Environment on Linux](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-Linux) -* [Building Environment on Windows](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-Windows) -* [Building Environment on MacOS](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-macOS) +* [Set up Build Environment on Linux](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-Linux) +* [Set up Build Environment on Windows](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-Windows) +* [Set up Build Environment on macOS](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-macOS) Build Steps =========== @@ -63,48 +50,45 @@ To compile from source, open a **Terminal (Linux/MacOS)**, the **MSVC Tools Comm git checkout latest ``` -2. Navigate to the directory where you have downloaded KeePassXC and type these commands: + 2. Navigate to the directory where you have downloaded KeePassXC and run: - ``` - mkdir build - cd build - cmake -DWITH_XC_ALL=ON .. - make - ``` + ``` + mkdir build + cd build + cmake -DWITH_XC_ALL=ON .. + make + ``` + + If you have `vcpkg` installed, add `-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake` to the `cmake` command to automatically download and install all required build and runtime dependencies locally to your build directory before compiling KeePassXC. Using `vcpkg` is the preferred way to install dependencies on macOS and required on Windows if using the MSVC toolchain. + +For more detailed build instructions for each platform, please refer to the [GitHub wiki](https://github.com/keepassxreboot/keepassxc/wiki/Building-KeePassXC). -Note: These steps place the compiled KeePassXC binary inside the `./build/src/` directory. +Note: These steps place the compiled KeePassXC binary inside the `./build/src/` directory (`src/KeePassXC.app/Contents/MacOS` on macOS). ## MacOS Build Notes -If you installed Qt5 via Homebrew, you should be able to compile KeePassXC without any changes. If CMake fails to find your Qt installation, you can specify it manually by adding the following parameter: +If you installed Qt5 via Homebrew and CMake fails to find your Qt installation, you can specify it manually by adding the following parameter: `-DCMAKE_PREFIX_PATH=$(brew --prefix qt5)/lib/cmake` -(or whatever your Qt installation path is) - When building with ASAN support on macOS, you need to use `export ASAN_OPTIONS=detect_leaks=0` before running the tests (LSAN is no supported on macOS). ## Windows Build Notes -For detailed build steps see the [Windows Build Instructions](https://github.com/keepassxreboot/keepassxc/wiki/Building-KeePassXC#windows). - -If you are using MSVC, you may have to specify your Vcpkg toolchain by adding the following CMake parameter: `-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake` - If you are using MSYS2, you have to add ```-G "MSYS Makefiles"``` at the beginning of the cmake command. CMake Configuration Options ========================== -## Common Parameters +## Recommended CMake Build Parameters ``` --DCMAKE_INSTALL_PREFIX=$(brew --prefix) -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE= -DWITH_GUI_TESTS=ON ``` -## KeePassXC Parameters +## Additional CMake Parameters KeePassXC comes with a variety of build options that can turn on/off features. Most notably, we allow you to build the application with all TCP/IP networking code disabled. Please note that we still require and link against Qt5's network library in order to use local named pipes on all operating systems. Each of these build options are supplied at the time of calling cmake: diff --git a/cmake/FindQREncode.cmake b/cmake/FindQREncode.cmake index 69850edf5c..230dafae2d 100644 --- a/cmake/FindQREncode.cmake +++ b/cmake/FindQREncode.cmake @@ -15,14 +15,7 @@ find_path(QRENCODE_INCLUDE_DIR NAMES qrencode.h) -if (VCPKG_INSTALLED_DIR) - find_library(QRENCODE_LIBRARY_RELEASE qrencode) - find_library(QRENCODE_LIBRARY_DEBUG qrencoded) - set(QRENCODE_LIBRARY optimized ${QRENCODE_LIBRARY_RELEASE} debug ${QRENCODE_LIBRARY_DEBUG}) -else() - find_library(QRENCODE_LIBRARY qrencode) -endif() - +find_library(QRENCODE_LIBRARY qrencode) mark_as_advanced(QRENCODE_LIBRARY QRENCODE_INCLUDE_DIR) include(FindPackageHandleStandardArgs) diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000000..6ee4877f36 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,76 @@ +{ + "name": "keepassxc", + "version-string": "2.8.0", + "builtin-baseline": "2a6371b01420d8820d158b4707e79931feba27aa", + "dependencies": [ + { + "name": "argon2", + "version>=": "20190702" + }, + { + "name": "botan", + "version>=": "3.1.1" + }, + { + "name": "minizip", + "version>=": "1.3" + }, + { + "name": "libqrencode", + "version>=": "4.1.1" + }, + { + "name": "libxi", + "version>=": "1.8", + "platform": "linux | freebsd" + }, + { + "name": "libxtst", + "version>=": "1.2.4", + "platform": "linux | freebsd" + }, + { + "name": "qt5", + "version>=": "5.15.11" + }, + { + "name": "qt5-imageformats", + "version>=": "5.15.11" + }, + { + "name": "qt5-macextras", + "version>=": "5.15.11", + "platform": "osx" + }, + { + "name": "qt5-svg", + "version>=": "5.15.11" + }, + { + "name": "qt5-tools", + "version>=": "5.15.11" + }, + { + "name": "qt5-translations", + "version>=": "5.15.11" + }, + { + "name": "qt5-wayland", + "version>=": "5.15.11", + "platform": "linux | freebsd" + }, + { + "name": "qt5-x11extras", + "version>=": "5.15.11", + "platform": "linux | freebsd" + }, + { + "name": "readline", + "version>=": "0#5" + }, + { + "name": "zlib", + "version>=": "1.3" + } + ] +}