From 7854d13f8b1ea4c206daf79e3e11c8dea4a8dbb4 Mon Sep 17 00:00:00 2001 From: Nicola Revelant Date: Fri, 2 Jun 2023 12:34:13 +0200 Subject: [PATCH] Improve install documentation --- CMakeLists.txt | 4 ++-- README.md | 19 +++++++++++++------ src/Frame/Frame.cpp | 8 ++++---- src/Resources/Resources.cpp | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9b9631..0a9f039 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT DEFINED DATA_PATH) - set(DATA_PATH "${CMAKE_SOURCE_DIR}/") + set(DATA_PATH "${CMAKE_SOURCE_DIR}") endif () message("Build type: ${CMAKE_BUILD_TYPE}") @@ -24,7 +24,7 @@ if (DEFINED DATA_PATH) add_subdirectory(src) else () # System configuration path (used by configure_file) - set(DATA_PATH /usr/share/${PROJECT_NAME}/) + set(DATA_PATH ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}) # Create the target add_subdirectory(src) diff --git a/README.md b/README.md index 34af5e6..7330b56 100644 --- a/README.md +++ b/README.md @@ -23,22 +23,29 @@ with the version code (MAJOR.MINOR.PATCH). ## Installation -From the source directory: +To install into ``/usr/local``, run: ```bash +git clone https://github.com/nicolarevelant/italian-draughts.git +cd italian-draughts cmake -B build -DCMAKE_BUILD_TYPE=Release -cmake --build build -cmake --install build -/usr/bin/italian-draughts +cmake --build build -- -j8 +sudo cmake --install build ``` -To set a custom application data path (instead of /usr/share/italian-draughts/) +The installation path can be changed using the ``-DCMAKE_INSTALL_PREFIX=`` +argument for ``cmake``. + +To set a custom application data path (instead of ``/share/italian-draughts``) you can set the `DATA_PATH` cmake variable. If CMAKE_BUILD_TYPE equals Debug and DATA_PATH is not set then DATA_PATH is set to the absolute path of the project root directory. -If you set a custom path the manual pages and the installation rules will be ignored. +If you set a custom DATA_PATH (or CMAKE_BUILD_TYPE equals Debug) the manual pages +and the installation target will be ignored. + +Windows and macOS are not supported yet. # Copyright and license diff --git a/src/Frame/Frame.cpp b/src/Frame/Frame.cpp index 7fac6b2..3d56fdf 100644 --- a/src/Frame/Frame.cpp +++ b/src/Frame/Frame.cpp @@ -86,13 +86,13 @@ wxMenuBar *Frame::createMenuBar() { wxPanel *Frame::createChessboard(wxWindow *parent, const std::string &path) { // load images - wxBitmap pcPawn{path + "images/pcPawn.png"}; + wxBitmap pcPawn{path + "/images/pcPawn.png"}; if (!pcPawn.IsOk()) return nullptr; - wxBitmap pcDame(path + "images/pcDame.png"); + wxBitmap pcDame(path + "/images/pcDame.png"); if (!pcDame.IsOk()) return nullptr; - wxBitmap plPawn(path + "images/plPawn.png"); + wxBitmap plPawn(path + "/images/plPawn.png"); if (!plPawn.IsOk()) return nullptr; - wxBitmap plDame(path + "images/plDame.png"); + wxBitmap plDame(path + "/images/plDame.png"); if (!plDame.IsOk()) return nullptr; wxSize imageSize = pcPawn.GetSize(); if (pcDame.GetSize() != imageSize || plPawn.GetSize() != imageSize || plDame.GetSize() != imageSize) return nullptr; diff --git a/src/Resources/Resources.cpp b/src/Resources/Resources.cpp index 8e20e18..5621417 100644 --- a/src/Resources/Resources.cpp +++ b/src/Resources/Resources.cpp @@ -20,7 +20,7 @@ const wxColour &Resources::getColor(const std::string &key, const wxColour &def) } bool Resources::fillColorsMap(ColorsMap &colors, const std::string &path, const std::string &theme) { - std::ifstream file(path + "themes/" + theme); + std::ifstream file(path + "/themes/" + theme); if (file.is_open()) { std::string line; while (std::getline(file, line)) {