Skip to content
Snippets Groups Projects
Commit f1fea438 authored by Norihiro Watanabe's avatar Norihiro Watanabe Committed by GitHub
Browse files

Merge pull request #1432 from norihiro-w/fatal-abort

Abort in OGS_FATAL()
parents 08195711 d3cdf22c
No related branches found
No related tags found
No related merge requests found
......@@ -10,15 +10,31 @@
#ifndef BASELIB_ERROR_H
#define BASELIB_ERROR_H
#include <stdexcept>
#ifdef OGS_FATAL_ABORT
#include <cstdlib>
#include <logog/include/logog.hpp>
#include "StringTools.h"
#define OGS_FATAL(fmt, ...)\
{\
ERR("%s", BaseLib::format(fmt, ##__VA_ARGS__).data());\
std::abort();\
}
#else // OGS_FATAL_ABORT
#include <stdexcept>
#include "FileTools.h"
#include "StringTools.h"
#define OGS_STR(x) #x
#define OGS_STRINGIFY(x) OGS_STR(x)
#define OGS_LOCATION " at " + BaseLib::extractBaseName(__FILE__) + ", line " OGS_STRINGIFY(__LINE__)
#define OGS_FATAL(fmt, ...)\
throw std::runtime_error(BaseLib::format(fmt, ##__VA_ARGS__) + OGS_LOCATION);
#endif // OGS_FATAL_ABORT
#endif //BASELIB_ERROR_H
......@@ -87,6 +87,9 @@ option(EIGEN_NO_DEBUG "Disables Eigen's assertions" OFF)
# Logging
option(OGS_DISABLE_LOGGING "Disables all logog messages." OFF)
# Debug
option(OGS_FATAL_ABORT "Abort in OGS_FATAL" OFF)
# Compiler flags
set(OGS_CXX_FLAGS "" CACHE STRING "Additional C++ compiler flags.")
option(STL_NO_DEBUG "Disable STL debug in debug build" OFF)
......@@ -154,6 +157,10 @@ if(OGS_USE_EIGEN)
add_definitions(-DOGS_USE_EIGEN)
endif()
if (OGS_FATAL_ABORT)
add_definitions(-DOGS_FATAL_ABORT)
endif()
if(OGS_BUILD_TESTS)
set(Data_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Tests/Data CACHE INTERNAL "")
set(Data_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Tests/Data CACHE INTERNAL "")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment