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
- The library name includes the
Dict
suffix which was included to avoid a collision between target names in CMake from theROOT_GENERATE_DICTIONARY
andadd_library
commands. This suffix needs to be removed to allow the rootmap file to work properly. - 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.)