diff --git a/CMakeLists.txt b/CMakeLists.txt index b5255cd69dfd04992c71b429eb29de86110b1c6b..5f2cb930bb038b47036787573c1ebc552c2e630d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ SET(OV_CUSTOM_DEPENDENCIES_PATH "${CMAKE_SOURCE_DIR}/dependencies") SET(OV_SOURCE_DEPENDENCIES_PATH "${CMAKE_SOURCE_DIR}/dependencies-source") SET(BRAND_NAME "OpenViBE" CACHE STRING "Brand with which titles and documentation will be prefixed") +OPTION(OV_DISPLAY_ERROR_LOCATION ON) OPTION(PUBLISH_DOC_ASSETS "Publish plugin documentation assets" ON) # If OpenMP is available, it will allow Eigen to use multiple cores in matrix math. @@ -119,6 +120,10 @@ ENDIF() ################################################################# string(TOLOWER ${BRAND_NAME} LOWER_BRAND_NAME) ADD_DEFINITIONS(-DBRAND_NAME="${BRAND_NAME}") + +IF(OV_DISPLAY_ERROR_LOCATION) + ADD_DEFINITIONS(-DOV_DISPLAY_ERROR_LOCATION) +ENDIF() ################################################################# SET(OV_LAUNCHER_SOURCE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules/launchers") diff --git a/openvibe/include/openvibe/ovAssert.h b/openvibe/include/openvibe/ovAssert.h index 055565061756187a288c7a978712e40761512195..ef65ca577c09f76106a1a1bf1cd560a55401df8a 100644 --- a/openvibe/include/openvibe/ovAssert.h +++ b/openvibe/include/openvibe/ovAssert.h @@ -132,7 +132,11 @@ while (0) */ #define OV_WARNING_UNLESS_K(expression, message) OV_WARNING_UNLESS(expression, message, this->getLogManager()) - +#if defined OV_DISPLAY_ERROR_LOCATION +#define OV_ERROR_LOG_LOCATION(file, line) ", {Error location} : {" << file << "::" << line << "}" +#else +#define OV_ERROR_LOG_LOCATION(file, line) "" +#endif /** * \def OV_ERROR_LOG(description, type, file, line, logManager) * @@ -148,9 +152,7 @@ do { \ << convertErrorTypeToString(type) \ << " (code " \ << static_cast<unsigned int>((type)) \ - << ")}, {Error location} : {" \ - << file << "::" << line\ - << "}\n"; \ + << ")}" << OV_ERROR_LOG_LOCATION(file, line) << "\n"; \ } \ while (0) @@ -340,6 +342,12 @@ while (0) */ #define OV_ERROR_UNLESS_KRN(expression, description, type) OV_ERROR_UNLESS(expression, description, type, nullptr, this->getErrorManager(), this->getLogManager()) +#if defined OV_DISPLAY_ERROR_LOCATION +#define OV_FATAL_LOG_LOCATION ", {Error location} : {" << __FILE__ << "::" << __LINE__ << "}" +#else +#define OV_FATAL_LOG_LOCATION "" +#endif + /** * \def OV_FATAL(description, type, logManager) * @@ -355,9 +363,7 @@ do { \ << convertErrorTypeToString(type) \ << " (code " \ << static_cast<unsigned int>((type)) \ - << ")}, {Error location} : {" \ - << __FILE__ << "::" << __LINE__\ - << "}\n"; \ + << ")}" << OV_FATAL_LOG_LOCATION << "\n"; \ std::abort(); \ } \ while (0) diff --git a/scripts/windows-build.cmd b/scripts/windows-build.cmd index 91ee21da784b1e94f68f0605180424b397f72cd9..6c16f5ca4a0d73d89a25b9c310aca05d873cb09e 100644 --- a/scripts/windows-build.cmd +++ b/scripts/windows-build.cmd @@ -10,6 +10,7 @@ set RerunCmake=false set PackageOption=FALSE set UserDataSubdir=OpenVIBE set BrandName=OpenViBE +set DisplayErrorLocation=ON goto parameter_parse @@ -21,6 +22,7 @@ goto parameter_parse echo -d^|--debug build in debug mode echo -r^|--release build in release mode echo --make-package make packages at the end + echo --hide-error-location do not display complete error locations echo --rerun-cmake force cmake rerun echo --userdata-subdir [dirname] name of the userdata sub directory echo --brand-name [brand name] name of the brand to prefix titles and documentation @@ -63,6 +65,11 @@ if /i "%1" == "-h" ( Goto parameter_parse ) else if /i "%1" == "--make-package" ( set PackageOption=TRUE + set DisplayErrorLocation=OFF + SHIFT + Goto parameter_parse +) else if /i "%1" == "--hide-error-location" ( + set DisplayErrorLocation=OFF SHIFT Goto parameter_parse ) else if /i "%1" == "--rerun-cmake" ( @@ -133,6 +140,7 @@ if %CallCmake%=="true" ( -DCMAKE_BUILD_TYPE=%BuildType% ^ -DCMAKE_INSTALL_PREFIX=%install_dir% ^ -DOV_PACKAGE=%PackageOption% ^ + -DOV_DISPLAY_ERROR_LOCATION=%DisplayErrorLocation% ^ -DBUILD_UNIT_TEST=%ov_build_unit% ^ -DBUILD_VALIDATION_TEST=%ov_build_validation% ^ %ov_cmake_test_data% ^