mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-25 00:53:43 +00:00
Get the config file path from cmake.
This commit is contained in:
parent
e2cfdb9edb
commit
56735c9d86
5 changed files with 34 additions and 1 deletions
|
@ -2,10 +2,20 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
|||
project(dindexer VERSION 0.1.1 LANGUAGES CXX C)
|
||||
|
||||
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
|
||||
option(DINDEXER_DEBUG_CFG_FILE "Enable to set the config file path to the build path" OFF)
|
||||
set(PROJECT_VERSION_BETA "1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
|
||||
|
||||
if (DINDEXER_CONFIG_FILE STREQUAL "")
|
||||
if (DINDEXER_DEBUG_CFG_FILE)
|
||||
set(DINDEXER_CONFIG_FILE ${CMAKE_CURRENT_BINARY_DIR}/dindexer.yml CACHE STRING "Path to the config file" FORCE)
|
||||
else()
|
||||
set(DINDEXER_CONFIG_FILE "$HOME/.config/dindexer.yml" CACHE STRING "Path to the config file" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Config file set to ${DINDEXER_CONFIG_FILE}")
|
||||
|
||||
find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options)
|
||||
find_package(PostgreSQL REQUIRED)
|
||||
find_package(YamlCpp 0.5.1 REQUIRED)
|
||||
|
|
|
@ -28,6 +28,13 @@ The program will go through every file in the path you specify. Hashing everythi
|
|||
You can run dindexer --help to see a list of available switches.
|
||||
|
||||
# Build instructions #
|
||||
## Dependencies ##
|
||||
The following libraries must be available on your system:
|
||||
|
||||
- PostgreSQL (libpq)
|
||||
- Boost 1.53 or later
|
||||
- yaml-cpp 0.5.1 or later
|
||||
|
||||
## Linux ##
|
||||
|
||||
mkdir dindexer_build
|
||||
|
|
|
@ -23,5 +23,6 @@
|
|||
#define VERSION_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define VERSION_BETA @PROJECT_VERSION_BETA@
|
||||
#define VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define CONFIG_FILE_PATH "@DINDEXER_CONFIG_FILE@"
|
||||
|
||||
#endif
|
||||
|
|
17
src/main.cpp
17
src/main.cpp
|
@ -26,6 +26,8 @@
|
|||
# include <mutex>
|
||||
# include <condition_variable>
|
||||
#endif
|
||||
#include <wordexp.h>
|
||||
#include "dindexerConfig.h"
|
||||
#include "filesearcher.hpp"
|
||||
#include "indexer.hpp"
|
||||
#include "settings.hpp"
|
||||
|
@ -33,6 +35,7 @@
|
|||
|
||||
namespace {
|
||||
void run_hash_calculation ( din::Indexer& parIndexer, bool parShowProgress );
|
||||
std::string expand ( const char* parString );
|
||||
} //unnamed namespace
|
||||
|
||||
int main (int parArgc, char* parArgv[]) {
|
||||
|
@ -61,7 +64,7 @@ int main (int parArgc, char* parArgv[]) {
|
|||
|
||||
din::DinDBSettings settings;
|
||||
{
|
||||
const bool loaded = din::load_settings("dindexerrc.yml", settings);
|
||||
const bool loaded = din::load_settings(expand(CONFIG_FILE_PATH), settings);
|
||||
if (not loaded) {
|
||||
std::cerr << "Can't load settings from dindexerrc.yml, quitting\n";
|
||||
return 1;
|
||||
|
@ -141,4 +144,16 @@ namespace {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string expand (const char* parString) {
|
||||
wordexp_t p;
|
||||
wordexp(parString, &p, 0);
|
||||
char** w = p.we_wordv;
|
||||
std::ostringstream oss;
|
||||
for (std::size_t z = 0; z < p.we_wordc; ++z) {
|
||||
oss << w[z];
|
||||
}
|
||||
wordfree(&p);
|
||||
return oss.str();
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
|
Loading…
Reference in a new issue