Hi,
I’ve previously posted about some improvements to the CMake Macro that ROOT provides and these were included in ROOT 5, but seem to have been dropped in ROOT 6. In particular I believe that the ROOT_GENERATE_DICTIONARY
should search the include paths for the include files needed, at the moment it seems the paths need to be hard coded (or the headers need to be in ${CMAKE_CURRENT_SOURCE_DIR}/inc
?):
include_directories(../include)
#Would like to use the following
#ROOT_GENERATE_DICTIONARY(CustomClassesDict AClass.hpp LINKDEF CustomCLasses_LinkDef.h)
#but instead need hard coded paths:
ROOT_GENERATE_DICTIONARY(CustomClassesDict ../include/AClass.hpp LINKDEF ../include/CustomCLasses_LinkDef.h)
The issue is in RootNewMacros.cmake, instead of using a GLOB
which is not recommended and oddly picking and choosing hard coded paths (some places use inc/
and others ${CMAKE_BINARY_DIR}/include
) the macro should use the find_file
command from CMake. I don’t have the time at the moment to improve the macro again, but here is a brief excerpt of my suggested improvements from the previous post:
#---Get the list of include directories------------------
get_directory_property(incdirs INCLUDE_DIRECTORIES)
set(includedirs)
foreach( d ${incdirs})
set(includedirs ${includedirs} -I${d})
endforeach()
#---Get LinkDef.h file------------------------------------
set(linkdefs)
foreach( f ${ARG_LINKDEF})
find_file(linkFile ${f} PATHS ${incdirs})
set(linkdefs ${linkdefs} ${linkFile})
unset(linkFile CACHE)
endforeach()
#---Get the list of header files-------------------------
set(headerfiles)
foreach(fp ${ARG_UNPARSED_ARGUMENTS})
find_file(headerFile ${fp} PATHS ${incdirs})
set(headerfiles ${headerfiles} ${headerFile})
unset(headerFile CACHE)
endforeach()
If I find sometime I will rewrite the macro again and post it here.
Thanks