From 54172331dd918402ca1277ae4123857ca2e53a0d Mon Sep 17 00:00:00 2001 From: Martin Beseda <martinbeseda@seznam.cz> Date: Sat, 8 Sep 2018 13:58:05 +0200 Subject: [PATCH] NEW: Added message.h with message macros MSG_INFO and MSG_DEBUG intended to unify and simplify library output. --- CMakeLists.txt | 16 +++++++++++----- external_dependencies/boost | 2 +- include/4neuro.h | 1 + src/examples/main.cpp | 3 ++- src/message.h | 20 ++++++++++++++++++++ 5 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 src/message.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dbd32a5..a860a137 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,13 @@ cmake_minimum_required(VERSION 3.0) project(lib4neuro) +#TODO request newer version of CMake >=3.12 + +#TODO rewrite to use add_compile_definitions if(WIN32) - ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB") + add_compile_options("-DBOOST_ALL_NO_LIB") else() - ADD_DEFINITIONS("-DBOOST_TEST_DYN_LINK") + add_compile_options("-DBOOST_TEST_DYN_LINK") endif() #------------# @@ -12,9 +15,12 @@ endif() #------------# # Release / None / Debug if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: None Debug Release." - FORCE) + set (CMAKE_BUILD_TYPE RELEASE CACHE STRING + "Choose the type of build, options are: None Debug Release." + FORCE) +elseif("CMAKE_BUILD_TYPE" STREQUAL "Debug") + #TODO rewrite to use add_compile_definitions + add_compile_options(-DDEBUG) endif (NOT CMAKE_BUILD_TYPE) #------------------------# diff --git a/external_dependencies/boost b/external_dependencies/boost index 7142eb20..65b96e76 160000 --- a/external_dependencies/boost +++ b/external_dependencies/boost @@ -1 +1 @@ -Subproject commit 7142eb200291e29c11a448c58c2c1031664aa69b +Subproject commit 65b96e76f6c51b5492bc5ef2d0d67aad8d6ae801 diff --git a/include/4neuro.h b/include/4neuro.h index d11ff041..12e1c482 100644 --- a/include/4neuro.h +++ b/include/4neuro.h @@ -21,6 +21,7 @@ #include "../src/Solvers/DESolver.h" #include "../src/constants.h" #include "../src/settings.h" +#include "../src/message.h" #endif //INC_4NEURO_4NEURO_H diff --git a/src/examples/main.cpp b/src/examples/main.cpp index 5033d030..c2d3a38c 100644 --- a/src/examples/main.cpp +++ b/src/examples/main.cpp @@ -16,8 +16,9 @@ int main(int argc, char** argv){ + MSG_INFO("INFO MESSAGE!"); - + MSG_DEBUG("DEBUG MESSAGE"); return 0; } diff --git a/src/message.h b/src/message.h new file mode 100644 index 00000000..75f8098a --- /dev/null +++ b/src/message.h @@ -0,0 +1,20 @@ +// +// Created by martin on 9/8/18. +// + +#ifndef PROJECT_MESSAGE_H +#define PROJECT_MESSAGE_H + +#define MSG_INFO(str) {\ + std::cout << "INFO: " << str << std::endl;\ +} + +#ifdef DEBUG +#define MSG_DEBUG(str) {\ + std::cout << "DEBUG: " << str << std::endl;\ +} +#else +#define MSG_DEBUG(str) +#endif + +#endif //PROJECT_MESSAGE_H -- GitLab