CMake ROOT_GENERATE_DICTIONARY rootmap

Hi,

I’ve run into some issue with the auto generation of a rootmap file on a Mac from the cmake macro ROOT_GENERATE_DICTIONARY.
Roughly the cmake file looks like this:

#Generate a ROOT dictionary.
ROOT_GENERATE_DICTIONARY(CustomClassesDict
   ../include/AClass.hpp
   LINKDEF ../include/CustomClasses_LinkDef.h)

#Create the CustomClasses library with the ROOT dictionary.
add_library(CustomClasses SHARED
   AClass.cpp
   CustomClassesDict)

#Link to ROOT.
target_link_libraries(CustomClasses ${ROOT_LIBRARIES})

#Set the install directory.
install(TARGETS CustomClasses DESTINATION lib/)

First the rootmap file needs to be installed manually, the fact that the rootmap and pcm files were being generated was not clear to me at first. Not sure there is anyway around this, but here is a short solution:

#Install the ROOT 6 PCM and rootmap files.
if (${ROOT_VERSION} VERSION_GREATER "6.0")
   install(
      FILES
      ${CMAKE_CURRENT_BINARY_DIR}/libCustomClassesDict_rdict.pcm
      ${CMAKE_CURRENT_BINARY_DIR}/libCustomClassesDict.rootmap
      DESTINATION lib/)
endif (${ROOT_VERSION} VERSION_GREATER "6.0")

More importantly the generate rootmap has some problems with the library name:

[ libCustomClassesDict.so ]
# List of selected classes
class AClass
header AClass.hpp
  1. The library name includes the Dict suffix which was included to avoid a collision between target names in CMake from the ROOT_GENERATE_DICTIONARY and add_library commands. This suffix needs to be removed to allow the rootmap file to work properly.
  2. The extension is .so, but the generated library has an extension .dylib. I did not manually specify the suffix, but this was decided by CMake automatically.

I’ve created a small project to demonstrate these issues at
https://github.com/ksmith0/root-cmake

(This issue was previously discussed here. In addition, another issue with the include path was posted here.)

I suppose @mato will comment on this one as well…

Cheers, Bertrand.

@mato Any suggestions here? Just wanted to ping you before I forget about it.

I agree that this is not very convenient. In the case of build ROOT itself, for which we use the same macro, we do the installation automatically. I’ll see if we can add an option to declare the installation automatically.

Thanks for reporting. This is certainly a bug. I have created a JIRA issue Loading...

Thanks for the update.

This issue is resolved by specifying the MODULE option to ROOT_GENERATE_DICTIONARY. (@mato provided this solution in one of the bug comments.)

ROOT_GENERATE_DICTIONARY(CustomClassesDict
   ../include/AClass.hpp
   LINKDEF ../include/CustomClasses_LinkDef.h
   MODULE CustomClasses)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.