From 202cb92389a29f5c0f3d7fa52d71bd024191993c Mon Sep 17 00:00:00 2001
From: Frank Bossen <fbossen@gmail.com>
Date: Tue, 13 Dec 2022 15:46:47 +0100
Subject: [PATCH] Use single variable to control ENABLE_TRACING

---
 CMakeLists.txt                                  | 6 ++++--
 Makefile                                        | 2 +-
 source/App/BitstreamExtractorApp/CMakeLists.txt | 2 +-
 source/App/DecoderAnalyserApp/CMakeLists.txt    | 2 +-
 source/App/DecoderApp/CMakeLists.txt            | 2 +-
 source/App/EncoderApp/CMakeLists.txt            | 2 +-
 source/App/SEIFilmGrainApp/CMakeLists.txt       | 2 +-
 source/App/SEIRemovalApp/CMakeLists.txt         | 2 +-
 source/App/StreamMergeApp/CMakeLists.txt        | 2 +-
 source/App/SubpicMergeApp/CMakeLists.txt        | 2 +-
 source/Lib/CommonAnalyserLib/CMakeLists.txt     | 2 +-
 source/Lib/CommonLib/CMakeLists.txt             | 2 +-
 source/Lib/DecoderAnalyserLib/CMakeLists.txt    | 2 +-
 source/Lib/DecoderLib/CMakeLists.txt            | 2 +-
 source/Lib/EncoderLib/CMakeLists.txt            | 2 +-
 source/Lib/Utilities/CMakeLists.txt             | 2 +-
 16 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e1b24db4c..00171124ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,8 +29,10 @@ endif()
 
 set( EXTENSION_360_VIDEO OFF CACHE BOOL "If EXTENSION_360_VIDEO is on, 360Lib will be added" )
 set( EXTENSION_HDRTOOLS OFF CACHE BOOL "If EXTENSION_HDRTOOLS is on, HDRLib will be added" )
-set( SET_ENABLE_TRACING OFF CACHE BOOL "Set ENABLE_TRACING as a compiler flag" )
-set( ENABLE_TRACING OFF CACHE BOOL "If SET_ENABLE_TRACING is on, it will be set to this value" )
+
+if (DEFINED ENABLE_TRACING)
+  set( ENABLE_TRACING OFF CACHE BOOL "ENABLE_TRACING will be set to this value" )
+endif()
 
 if( CMAKE_COMPILER_IS_GNUCC )
   set( BUILD_STATIC OFF CACHE BOOL "Build static executables" )
diff --git a/Makefile b/Makefile
index c48915825c..40e9dafc03 100644
--- a/Makefile
+++ b/Makefile
@@ -83,7 +83,7 @@ CMAKE_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE=ON
 endif
 
 ifneq ($(enable-tracing),)
-CONFIG_OPTIONS += -DSET_ENABLE_TRACING=ON -DENABLE_TRACING=$(enable-tracing)
+CONFIG_OPTIONS += -DENABLE_TRACING=$(enable-tracing)
 endif
 
 ifneq ($(parallel-split),)
diff --git a/source/App/BitstreamExtractorApp/CMakeLists.txt b/source/App/BitstreamExtractorApp/CMakeLists.txt
index c6145774e9..86ed8f968b 100644
--- a/source/App/BitstreamExtractorApp/CMakeLists.txt
+++ b/source/App/BitstreamExtractorApp/CMakeLists.txt
@@ -25,7 +25,7 @@ endif()
 add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} )
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${EXE_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/App/DecoderAnalyserApp/CMakeLists.txt b/source/App/DecoderAnalyserApp/CMakeLists.txt
index 7b23371f76..5d1e301ea3 100644
--- a/source/App/DecoderAnalyserApp/CMakeLists.txt
+++ b/source/App/DecoderAnalyserApp/CMakeLists.txt
@@ -27,7 +27,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
 target_compile_definitions( ${EXE_NAME} PUBLIC RExt__DECODER_DEBUG_BIT_STATISTICS=1 )
 target_compile_definitions( ${EXE_NAME} PUBLIC RExt__DECODER_DEBUG_TOOL_STATISTICS=1 )
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${EXE_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/App/DecoderApp/CMakeLists.txt b/source/App/DecoderApp/CMakeLists.txt
index 958d2db0dc..184041e6b2 100644
--- a/source/App/DecoderApp/CMakeLists.txt
+++ b/source/App/DecoderApp/CMakeLists.txt
@@ -25,7 +25,7 @@ endif()
 add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} )
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${EXE_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/App/EncoderApp/CMakeLists.txt b/source/App/EncoderApp/CMakeLists.txt
index 960790142b..5ecdacd617 100644
--- a/source/App/EncoderApp/CMakeLists.txt
+++ b/source/App/EncoderApp/CMakeLists.txt
@@ -27,7 +27,7 @@ endif()
 add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} )
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${EXE_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/App/SEIFilmGrainApp/CMakeLists.txt b/source/App/SEIFilmGrainApp/CMakeLists.txt
index 1c26c4668c..f5396aa70f 100644
--- a/source/App/SEIFilmGrainApp/CMakeLists.txt
+++ b/source/App/SEIFilmGrainApp/CMakeLists.txt
@@ -25,7 +25,7 @@ endif()
 add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} )
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${EXE_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/App/SEIRemovalApp/CMakeLists.txt b/source/App/SEIRemovalApp/CMakeLists.txt
index ef4fe3634e..057cb2e3a6 100644
--- a/source/App/SEIRemovalApp/CMakeLists.txt
+++ b/source/App/SEIRemovalApp/CMakeLists.txt
@@ -25,7 +25,7 @@ endif()
 add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} )
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${EXE_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/App/StreamMergeApp/CMakeLists.txt b/source/App/StreamMergeApp/CMakeLists.txt
index 117652574c..7d3199ab66 100644
--- a/source/App/StreamMergeApp/CMakeLists.txt
+++ b/source/App/StreamMergeApp/CMakeLists.txt
@@ -25,7 +25,7 @@ endif()
 add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} )
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${EXE_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/App/SubpicMergeApp/CMakeLists.txt b/source/App/SubpicMergeApp/CMakeLists.txt
index 64690566da..f362e35889 100644
--- a/source/App/SubpicMergeApp/CMakeLists.txt
+++ b/source/App/SubpicMergeApp/CMakeLists.txt
@@ -25,7 +25,7 @@ endif()
 add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} )
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${EXE_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/Lib/CommonAnalyserLib/CMakeLists.txt b/source/Lib/CommonAnalyserLib/CMakeLists.txt
index 40471bb3e5..cfdd5e3d48 100644
--- a/source/Lib/CommonAnalyserLib/CMakeLists.txt
+++ b/source/Lib/CommonAnalyserLib/CMakeLists.txt
@@ -57,7 +57,7 @@ if( EXTENSION_HDRTOOLS )
   target_compile_definitions( ${LIB_NAME} PUBLIC EXTENSION_HDRTOOLS=1 )
 endif()
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${LIB_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/Lib/CommonLib/CMakeLists.txt b/source/Lib/CommonLib/CMakeLists.txt
index 368545998d..e0d63b140c 100644
--- a/source/Lib/CommonLib/CMakeLists.txt
+++ b/source/Lib/CommonLib/CMakeLists.txt
@@ -55,7 +55,7 @@ if( EXTENSION_HDRTOOLS )
   target_compile_definitions( ${LIB_NAME} PUBLIC EXTENSION_HDRTOOLS=1 )
 endif()
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${LIB_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/Lib/DecoderAnalyserLib/CMakeLists.txt b/source/Lib/DecoderAnalyserLib/CMakeLists.txt
index d91d1d50a3..291e012386 100644
--- a/source/Lib/DecoderAnalyserLib/CMakeLists.txt
+++ b/source/Lib/DecoderAnalyserLib/CMakeLists.txt
@@ -21,7 +21,7 @@ if( EXTENSION_360_VIDEO )
   target_compile_definitions( ${LIB_NAME} PUBLIC EXTENSION_360_VIDEO=1 )
 endif()
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${LIB_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/Lib/DecoderLib/CMakeLists.txt b/source/Lib/DecoderLib/CMakeLists.txt
index 9fdcfb2501..9ba9c604f7 100644
--- a/source/Lib/DecoderLib/CMakeLists.txt
+++ b/source/Lib/DecoderLib/CMakeLists.txt
@@ -20,7 +20,7 @@ if( EXTENSION_360_VIDEO )
   target_compile_definitions( ${LIB_NAME} PUBLIC EXTENSION_360_VIDEO=1 )
 endif()
   
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${LIB_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/Lib/EncoderLib/CMakeLists.txt b/source/Lib/EncoderLib/CMakeLists.txt
index 9585d923b3..996e5996d7 100644
--- a/source/Lib/EncoderLib/CMakeLists.txt
+++ b/source/Lib/EncoderLib/CMakeLists.txt
@@ -24,7 +24,7 @@ if( EXTENSION_HDRTOOLS )
   target_compile_definitions( ${LIB_NAME} PUBLIC EXTENSION_HDRTOOLS=1 )
 endif()
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${LIB_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
diff --git a/source/Lib/Utilities/CMakeLists.txt b/source/Lib/Utilities/CMakeLists.txt
index 020a0afed9..a291e6b5d0 100644
--- a/source/Lib/Utilities/CMakeLists.txt
+++ b/source/Lib/Utilities/CMakeLists.txt
@@ -20,7 +20,7 @@ if( EXTENSION_360_VIDEO )
   target_compile_definitions( ${LIB_NAME} PUBLIC EXTENSION_360_VIDEO=1 )
 endif()
 
-if( SET_ENABLE_TRACING )
+if( DEFINED ENABLE_TRACING )
   if( ENABLE_TRACING )
     target_compile_definitions( ${LIB_NAME} PUBLIC ENABLE_TRACING=1 )
   else()
-- 
GitLab