From 35ce3216a83db41da0c34ec2bc8692aae0a86d86 Mon Sep 17 00:00:00 2001
From: Norihiro Watanabe <norihiro.watanabe@ufz.de>
Date: Fri, 4 Nov 2016 09:45:56 +0100
Subject: [PATCH] [CMake] set the default OGS_LOG_LEVEL to debug also in
 release build

---
 CMakeLists.txt                   | 16 ++++++++++++++++
 scripts/cmake/ProjectSetup.cmake | 15 ---------------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cf2982e9df3..466ba071c3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,6 +86,15 @@ option(EIGEN_NO_DEBUG "Disables Eigen's assertions" OFF)
 
 # Logging
 option(OGS_DISABLE_LOGGING "Disables all logog messages." OFF)
+set(OGS_LOG_LEVEL "LOGOG_LEVEL_DEBUG" CACHE STRING "Set logging level included in compilation.")
+set_property(CACHE OGS_LOG_LEVEL PROPERTY STRINGS
+    LOGOG_LEVEL_NONE
+    LOGOG_LEVEL_ERROR
+    LOGOG_LEVEL_WARN
+    LOGOG_LEVEL_INFO
+    LOGOG_LEVEL_DEBUG
+    LOGOG_LEVEL_ALL
+)
 
 # Debug
 option(OGS_FATAL_ABORT "Abort in OGS_FATAL" OFF)
@@ -166,6 +175,13 @@ if(OGS_BUILD_TESTS)
     set(Data_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Tests/Data CACHE INTERNAL "")
 endif()
 
+# Logging level
+if(OGS_DISABLE_LOGGING)
+    set(OGS_LOG_LEVEL LOGOG_LEVEL_NONE)
+endif()
+add_definitions(-DLOGOG_LEVEL=${OGS_LOG_LEVEL})
+
+
 ######################
 ### Subdirectories ###
 ######################
diff --git a/scripts/cmake/ProjectSetup.cmake b/scripts/cmake/ProjectSetup.cmake
index 28f74a18450..3884438395b 100644
--- a/scripts/cmake/ProjectSetup.cmake
+++ b/scripts/cmake/ProjectSetup.cmake
@@ -9,21 +9,6 @@ endif()
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
 
-# Logging level
-if(OGS_DISABLE_LOGGING)
-    set(OGS_LOG_LEVEL LOGOG_LEVEL_NONE)
-endif()
-
-if(NOT DEFINED OGS_LOG_LEVEL)
-    if(CMAKE_BUILD_TYPE STREQUAL "Debug")
-        add_definitions(-DLOGOG_LEVEL=LOGOG_LEVEL_DEBUG)
-    else()
-        add_definitions(-DLOGOG_LEVEL=LOGOG_LEVEL_INFO)
-    endif() # CMAKE_BUILD_TYPE = Debug
-else()
-    add_definitions(-DLOGOG_LEVEL=${OGS_LOG_LEVEL})
-endif() # NOT DEFINED OGS_LOG_LEVEL
-
 # Enable Visual Studio project folder grouping
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 
-- 
GitLab