From 90076cf689bd241097d940b1f333d4898b0a9950 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 2 Jul 2021 21:41:05 -0400 Subject: add cmake config file for resource dir --- CMakeLists.txt | 5 +++++ config.h.in | 1 + platform.cpp | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dd1007..82d405f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.16) project(abaddon) +set(ABADDON_RESOURCE_DIR "/usr/share/abaddon" CACHE PATH "Fallback directory for resources on Linux") + set(CMAKE_CXX_STANDARD 17) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") @@ -35,6 +37,8 @@ if(WIN32) link_libraries(${Fontconfig_LIBRARIES}) endif() +configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h) + file(GLOB ABADDON_SOURCES "*.h" "*.hpp" @@ -54,6 +58,7 @@ file(GLOB ABADDON_SOURCES ) add_executable(abaddon ${ABADDON_SOURCES}) +target_include_directories(abaddon PUBLIC ${PROJECT_BINARY_DIR}) target_include_directories(abaddon PUBLIC ${GTKMM_INCLUDE_DIRS}) target_include_directories(abaddon PUBLIC ${ZLIB_INCLUDE_DIRS}) target_include_directories(abaddon PUBLIC ${SQLite3_INCLUDE_DIRS}) diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..ab6583d --- /dev/null +++ b/config.h.in @@ -0,0 +1 @@ +#define ABADDON_DEFAULT_RESOURCE_DIR "@ABADDON_RESOURCE_DIR@" diff --git a/platform.cpp b/platform.cpp index b5e92e3..e6338ff 100644 --- a/platform.cpp +++ b/platform.cpp @@ -2,6 +2,7 @@ #include #include #include +#include using namespace std::literals::string_literals; @@ -97,7 +98,7 @@ std::string Platform::FindResourceFolder() { const static std::string home_path = std::getenv("HOME") + "/.config/abaddon"s; - for (const auto &path : { "."s, home_path, "/usr/share/abaddon"s }) { + for (const auto &path : { "."s, home_path, std::string(ABADDON_DEFAULT_RESOURCE_DIR) }) { if (IsFolder(path + "/res") && IsFolder(path + "/css")) { found_path = path; found = true; -- cgit v1.2.3