commit 7d151809576a071aa2e0e5f2348e1e7a4fc582bd
Author: François Trahay <francois.trahay@telecom-sudparis.eu>
Date:   Mon Aug 22 15:33:31 2022 +0200

    fix the detection of OTF2 version

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 852843f9..6c988f66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,3 +187,5 @@ include(PrintOpts)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/eztrace.pc.in
                ${CMAKE_CURRENT_BINARY_DIR}/eztrace.pc)
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eztrace.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}")
+
+message(STATUS "OTF2 version: ${OTF2_VERSION}")
diff --git a/cmake_modules/FindOTF2.cmake b/cmake_modules/FindOTF2.cmake
index cabdc482..f66d405c 100644
--- a/cmake_modules/FindOTF2.cmake
+++ b/cmake_modules/FindOTF2.cmake
@@ -47,6 +47,14 @@ ELSE()
       UNSET(_OTF2_LIB_FROM_ARG CACHE)
     ENDIF(${_ARG} MATCHES "^-l")
   ENDFOREACH(_ARG)
+
+
+  execute_process(COMMAND ${OTF2_CONFIG} "--version" OUTPUT_VARIABLE OTF2_VERSION)
+  STRING( REPLACE "otf2-config: version " "" OTF2_VERSION ${OTF2_VERSION} )
+  STRING( REPLACE "\n" "" OTF2_VERSION ${OTF2_VERSION} )
+  STRING( REPLACE "." ";" _VERSION ${OTF2_VERSION} )
+  LIST( GET _VERSION 0 OTF2_MAJOR_VERSION)
+  LIST( GET _VERSION 1 OTF2_MINOR_VERSION)
 ENDIF()
 
 include (FindPackageHandleStandardArgs)
@@ -56,9 +64,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(OTF2
   VERSION_VAR OTF2_VERSION
 )
 
-if(OTF2_FOUND)
-    message(STATUS "OTF2 interface version: ${OTF2_VERSION}")
-else()
+if(NOT OTF2_FOUND)
     unset(OTF2_CONFIG)
     unset(OTF2_CONFIG CACHE)
     unset(OTF2_LINK_DIRS)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2a8b0267..eb5f710e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,9 +33,7 @@ add_executable(eztrace
 target_compile_options(eztrace
   PRIVATE
     -Wall -Wextra -Wpedantic
-    -Werror
     -DEZTRACE_ABS_TOP_BUILDDIR="" # TODO
-    -Wno-gnu-zero-variadic-macro-arguments
 )
 
 target_include_directories(eztrace
@@ -58,8 +56,6 @@ add_executable(eztrace_avail
 target_compile_options(eztrace_avail
   PRIVATE
   -Wall -Wextra -Wpedantic
-  -Werror
-  -Wno-gnu-zero-variadic-macro-arguments
   )
 
 target_link_libraries(eztrace_avail
@@ -67,15 +63,9 @@ target_link_libraries(eztrace_avail
     eztrace-lib
 )
 
-set_target_properties(eztrace_avail 
-  PROPERTIES C_STANDARD 99
-)
 
 ################################################
 
-set_target_properties(eztrace 
-  PROPERTIES C_STANDARD 11
-)
 
 #####################################################
 
diff --git a/src/core/eztrace_config.h.in b/src/core/eztrace_config.h.in
index ae18c454..8bf56a62 100644
--- a/src/core/eztrace_config.h.in
+++ b/src/core/eztrace_config.h.in
@@ -21,6 +21,10 @@
 
 #define EZTRACE_VERSION "@CMAKE_PROJECT_VERSION@"
 
+#define OTF2_VERSION "@OTF2_VERSION@"
+#define OTF2_MAJOR_VERSION @OTF2_MAJOR_VERSION@
+#define OTF2_MINOR_VERSION @OTF2_MINOR_VERSION@
+
 // enum PPTRACE_BINARY_TYPE {
 //   PPTRACE_BINARY_TYPE_BFD, // Requires -lbfd
 //   PPTRACE_BINARY_TYPE_ELF, // Requires -lelf
diff --git a/src/eztrace-lib/CMakeLists.txt b/src/eztrace-lib/CMakeLists.txt
index 2fcba164..b746fdf9 100644
--- a/src/eztrace-lib/CMakeLists.txt
+++ b/src/eztrace-lib/CMakeLists.txt
@@ -24,17 +24,18 @@ target_compile_options(eztrace-lib
   PUBLIC
     -D_GNU_SOURCE
   PRIVATE
-    -Wall -Wextra  -Wno-gnu-zero-variadic-macro-arguments
+    -Wall -Wextra
 )
 
 target_link_libraries(eztrace-lib
+  PRIVATE
+    ${OTF2_LIBRARY}
   PUBLIC
     eztrace-core
     dl
     PRIVATE
     ${CMAKE_DL_LIBS}
     rt
-    ${OTF2_LIBRARY}
     m
     )
 
diff --git a/src/eztrace-lib/eztrace_otf2.c b/src/eztrace-lib/eztrace_otf2.c
index e7f94059..40da5f4c 100644
--- a/src/eztrace-lib/eztrace_otf2.c
+++ b/src/eztrace-lib/eztrace_otf2.c
@@ -342,8 +342,12 @@ static int _register_thread_team_member(struct to_register*r) {
 					      team->id,
 					      team->string_id,
 					      team->id,
-					      team->parent_id,
-					      OTF2_COMM_FLAG_NONE);
+					      team->parent_id
+#if OTF2_MAJOR_VERSION >= 3
+					      , OTF2_COMM_FLAG_NONE
+#endif
+					      );
+
 	if(err != OTF2_SUCCESS) {
 	  eztrace_error("OTF2_GlobalDefWriter_WriteComm failed: %s\n",
 			OTF2_Error_GetDescription(err));
@@ -396,8 +400,11 @@ static int _register_mpi_comm(int comm_id, int comm_size, uint64_t*members) {
 				  comm_id,
 				  comm_str,
 				  comm_id,
-				  comm_world_ref,
-				  OTF2_COMM_FLAG_NONE);
+				  comm_world_ref
+#if OTF2_MAJOR_VERSION >= 3
+				  , OTF2_COMM_FLAG_NONE
+#endif
+				  );
   if (err != OTF2_SUCCESS) {
     eztrace_warn("OTF2_GlobalDefWriter_WriteComm failed: %s (%s)\n",
 		 OTF2_Error_GetName(err), OTF2_Error_GetDescription(err));
@@ -937,8 +944,11 @@ void ezt_otf2_init() {
 						i /* id */,
 						process_string /* name */,
 						OTF2_LOCATION_GROUP_TYPE_PROCESS,
-						0 /* system tree */,
-						OTF2_UNDEFINED_LOCATION_GROUP );
+						0 /* system tree */
+#if OTF2_MAJOR_VERSION >= 3
+						, OTF2_UNDEFINED_LOCATION_GROUP
+#endif
+						);
       int thread_id = MPI2OTF(i);
       locations[i] = thread_id;
       members[i] = i;
@@ -979,7 +989,7 @@ void ezt_otf2_init() {
 					   OTF2_PARADIGM_MPI,
 					   OTF2_GROUP_FLAG_NONE,
 					   mpi_comm_size,
-					   members );
+					   members);
     if (err != OTF2_SUCCESS) {
       eztrace_warn("OTF2_GlobalDefWriter_WriteGroup failed: %s (%s)\n", 
 		   OTF2_Error_GetName(err), OTF2_Error_GetDescription(err));
@@ -990,8 +1000,11 @@ void ezt_otf2_init() {
 				    comm_world_ref,
 				    comm_world_str,
 				    comm_world_group,
-				    OTF2_UNDEFINED_COMM,
-				    OTF2_COMM_FLAG_NONE);
+				    OTF2_UNDEFINED_COMM
+#if OTF2_MAJOR_VERSION >= 3
+				    , OTF2_COMM_FLAG_NONE
+#endif
+);
     if (err != OTF2_SUCCESS) {
       eztrace_warn("OTF2_GlobalDefWriter_WriteComm failed: %s (%s)\n",
 		  OTF2_Error_GetName(err), OTF2_Error_GetDescription(err));
@@ -1034,8 +1047,11 @@ static void _synchronize_epochs() {
     OTF2_ErrorCode err = OTF2_GlobalDefWriter_WriteClockProperties( _ezt_trace.global_def_writer,
 								    1e9 /* 1 tick per second */,
 								    global_epoch_start,
-								    global_epoch_stop - global_epoch_start + 1,
-                                                                    OTF2_UNDEFINED_TIMESTAMP);
+								    global_epoch_stop - global_epoch_start + 1
+#if OTF2_MAJOR_VERSION >= 3
+								    , OTF2_UNDEFINED_TIMESTAMP
+#endif
+								    );
     if( err != OTF2_SUCCESS) {
       eztrace_error("OTF2_GlobalDefWriter_WriteClockProperties failed\n");
     }
diff --git a/src/modules/iotracer/iotracer_to_otf2.c b/src/modules/iotracer/iotracer_to_otf2.c
index cbce32ca..ac588048 100644
--- a/src/modules/iotracer/iotracer_to_otf2.c
+++ b/src/modules/iotracer/iotracer_to_otf2.c
@@ -384,8 +384,11 @@ void convert_iotracer_log_to_otf2(){
     OTF2_GlobalDefWriter_WriteClockProperties( global_def_writer,
                                                1e9 /* 1 tick per nanosecond */,
                                                0 /* epoch */,
-                                               2 /* length */,
-                                               OTF2_UNDEFINED_TIMESTAMP /* realtimeTimestamp */ );
+                                               2 /* length */
+#if OTF2_MAJOR_VERSION >= 3
+					      , OTF2_UNDEFINED_TIMESTAMP
+#endif
+					       );
 
     //////////////////////////////////////////////////////
 
@@ -533,8 +536,11 @@ void convert_iotracer_log_to_otf2(){
 					     process_id /* id */,
 					     process_string /* name */,
 					     OTF2_LOCATION_GROUP_TYPE_PROCESS,
-					     program_id /* system tree */,
-					     OTF2_UNDEFINED_LOCATION_GROUP );
+					     program_id /* system tree */
+#if OTF2_MAJOR_VERSION >= 3
+					     , OTF2_UNDEFINED_LOCATION_GROUP
+#endif
+);
 
 
     eztrace_log(dbg_lvl_normal, "registering %d threads\n", nb_registered_threads);
diff --git a/src/modules/posixio/posix_io_otf2.c b/src/modules/posixio/posix_io_otf2.c
index 2df961bf..b5258de0 100644
--- a/src/modules/posixio/posix_io_otf2.c
+++ b/src/modules/posixio/posix_io_otf2.c
@@ -201,8 +201,11 @@ void init_otf2_posixio() {
 				    comm_ref,
 				    comm_string_ref,
 				    group_ref,
-				    OTF2_UNDEFINED_COMM,
-				    OTF2_COMM_FLAG_NONE);
+				    OTF2_UNDEFINED_COMM
+#if OTF2_MAJOR_VERSION >= 3
+				    , OTF2_COMM_FLAG_NONE
+#endif
+				    );
   }
 }
 
