Improve error handling in applen and ability to build outside the source tree.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
3632a06c4b
commit
92c257d1e5
4 changed files with 25 additions and 2 deletions
|
@ -12,6 +12,10 @@ MESSAGE("CMAKE_CXX_FLAGS_RELWIHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
|||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
# used in applen for std::silesystem
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
include_directories(source)
|
||||
|
||||
add_subdirectory(source)
|
||||
|
|
|
@ -34,3 +34,6 @@ target_link_libraries(applen
|
|||
Boost::program_options
|
||||
appleii
|
||||
)
|
||||
|
||||
add_custom_target(copy-resources ALL
|
||||
COMMAND cmake -E copy_directory ${CMAKE_SOURCE_DIR}/resource ${CMAKE_BINARY_DIR}/resource)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "Log.h"
|
||||
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
class Configuration
|
||||
{
|
||||
|
@ -31,7 +32,14 @@ std::shared_ptr<Configuration> Configuration::instance;
|
|||
|
||||
Configuration::Configuration(const std::string & filename) : myFilename(filename)
|
||||
{
|
||||
boost::property_tree::ini_parser::read_ini(myFilename, myINI);
|
||||
if (std::filesystem::exists(filename))
|
||||
{
|
||||
boost::property_tree::ini_parser::read_ini(myFilename, myINI);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFileOutput("Registry: configuration file '%s' not found\n", filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Configuration::~Configuration()
|
||||
|
|
|
@ -326,5 +326,13 @@ namespace
|
|||
|
||||
int main(int argc, const char * argv [])
|
||||
{
|
||||
return foo(argc, argv);
|
||||
try
|
||||
{
|
||||
return foo(argc, argv);
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue