From da90ee0a2a9542674d9c391f2078a251e08c0f13 Mon Sep 17 00:00:00 2001
From: Pere Mato <pere.mato@cern.ch>
Date: Tue, 27 May 2014 10:21:13 +0200
Subject: [PATCH] Fixed GenVector and Smatrix dictionaries using -multiDict
 option. Fixes ROOT-6325

---
 cmake/modules/RootNewMacros.cmake | 35 +++++++++++++++++++------------
 math/genvector/CMakeLists.txt     |  2 +-
 math/smatrix/CMakeLists.txt       |  2 +-
 3 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/cmake/modules/RootNewMacros.cmake b/cmake/modules/RootNewMacros.cmake
index 842a3d95099..433439a1212 100644
--- a/cmake/modules/RootNewMacros.cmake
+++ b/cmake/modules/RootNewMacros.cmake
@@ -210,7 +210,7 @@ endmacro()
 #                                                    STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...)
 #---------------------------------------------------------------------------------------------------
 function(ROOT_GENERATE_DICTIONARY dictionary)
-  CMAKE_PARSE_ARGUMENTS(ARG "STAGE1" "MODULE" "LINKDEF;OPTIONS;DEPENDENCIES" ${ARGN})
+  CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT" "MODULE" "LINKDEF;OPTIONS;DEPENDENCIES" ${ARGN})
 
   #---roottest compability---------------------------------
   if(CMAKE_ROOTTEST_DICT)
@@ -265,26 +265,35 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
       endif()
     endif()
   endforeach()
-  #---Get the library and module dependencies-----------------
-  if(ARG_MODULE)
-    set(target_lib_common ${libprefix}${ARG_MODULE})
-  else()
-    get_filename_component(dict_base_name ${dictionary} NAME_WE)
+
+  #---Build the names for library, pcm and rootmap file ----
+  get_filename_component(dict_base_name ${dictionary} NAME_WE)
+  if(dict_base_name MATCHES "^G__")
     string(SUBSTRING ${dictionary} 3 -1 deduced_arg_module)
-    set(target_lib_common ${libprefix}${deduced_arg_module})
+  else()
+    set(deduced_arg_module ${dict_base_name})
   endif()
 
-  set(rootmap_name ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${target_lib_common}.rootmap)
-  set(library_name ${target_lib_common}${libsuffix})
-  set(rootmapargs -rml ${library_name} -rmf ${rootmap_name})
-
   if(ARG_MODULE)
-    set(newargs -s ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${ARG_MODULE}${libsuffix})
-    set(pcm_name ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${ARG_MODULE}_rdict.pcm)
+    set(library_name ${libprefix}${ARG_MODULE}${libsuffix})
+    if(ARG_MULTIDICT)
+      set(newargs -s ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${library_name} -multiDict)
+      set(pcm_name ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${ARG_MODULE}_${dictionary}_rdict.pcm)
+      set(rootmap_name ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${deduced_arg_module}.rootmap)
+    else()
+      set(newargs -s ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${library_name})
+      set(pcm_name ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${ARG_MODULE}_rdict.pcm)
+      set(rootmap_name ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${ARG_MODULE}.rootmap)
+    endif()
   else()
+    set(library_name ${libprefix}${deduced_arg_module}${libsuffix})
     set(pcm_name ${dictionary}_rdict.pcm)
+    set(rootmap_name ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${deduced_arg_module}.rootmap)
   endif()
 
+  set(rootmapargs -rml ${library_name} -rmf ${rootmap_name})
+
+  #---Get the library and module dependencies-----------------
   if(ARG_DEPENDENCIES)
     foreach(dep ${ARG_DEPENDENCIES})
       set(newargs ${newargs} -m  ${libprefix}${dep}_rdict.pcm)
diff --git a/math/genvector/CMakeLists.txt b/math/genvector/CMakeLists.txt
index 3903cf693a1..a499652e201 100644
--- a/math/genvector/CMakeLists.txt
+++ b/math/genvector/CMakeLists.txt
@@ -18,7 +18,7 @@ set(headers32 Math/Vector2D.h Math/Point2D.h
 	      Math/Vector3D.h Math/Point3D.h Math/Vector4D.h)
 
 ROOT_GENERATE_DICTIONARY(G__${libname}   ${headers} MODULE ${libname} LINKDEF Math/LinkDef_GenVector.h)
-ROOT_GENERATE_DICTIONARY(G__${libname}32 ${headers32}  MODULE ${libname}32 LINKDEF Math/LinkDef_GenVector32.h)
+ROOT_GENERATE_DICTIONARY(G__${libname}32 ${headers32} MULTIDICT MODULE ${libname} LINKDEF Math/LinkDef_GenVector32.h)
 
 ROOT_LINKER_LIBRARY(${libname} *.cxx G__${libname}.cxx G__${libname}32.cxx LIBRARIES Core)
 ROOT_INSTALL_HEADERS()
diff --git a/math/smatrix/CMakeLists.txt b/math/smatrix/CMakeLists.txt
index 4e571dab596..23f5af98cf5 100644
--- a/math/smatrix/CMakeLists.txt
+++ b/math/smatrix/CMakeLists.txt
@@ -17,7 +17,7 @@ ROOT_GENERATE_DICTIONARY(G__${libname}32  Math/SMatrix.h     Math/SVector.h
                                           Math/SMatrixDfwd.h Math/SMatrixFfwd.h
                                           Math/SMatrix.h     Math/SVector.h
                                           Math/SMatrixDfwd.h Math/SMatrixFfwd.h
-                                          MODULE ${libname}32
+                                          MULTIDICT MODULE ${libname}
                                           LINKDEF LinkDefD32.h)                                          
 
 ROOT_LINKER_LIBRARY(${libname} G__${libname}.cxx G__${libname}32.cxx LIBRARIES Core)
-- 
GitLab