Includes in a compiled TRint application

Hi,

I am facing a problem using a TRint application. My app is creating a root terminal, with all my libraries already loaded inside. This app is build in a cmake file.

What I don’t understand, is that when I execute the application and I look to the includes that have been automatically added, there is all the sources and build path that are added. So if my build directory is no more present, I got error messages. Here the output of the “.I” command to show the includes:

.I
-isysroot
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-I
/Applications/root_v6.26.04/etc/
-I
/Applications/root_v6.26.04/etc//cling
-I
/Applications/root_v6.26.04/etc//cling/plugins/include
-I
/Applications/root_v6.26.04/include/
-cxx-isystem
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1
-isystem
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include
-isystem
/Applications/root_v6.26.04/etc//cling/lib/clang/9.0.1/include
-extern-c-isystem
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
-I
/Users/dudouet/Softs/TkN/TkN-Lib/install/include
-I
/Users/dudouet/Softs/TkN/TkN-Lib/sources/src/sqlite3
-I
/Applications/root_v6.26.04/include
-I
/Users/dudouet/Softs/TkN/TkN-Lib/build
-I
/Users/dudouet/Softs/TkN/TkN-Lib/sources/src/base
-I
/Users/dudouet/Softs/TkN/TkN-Lib/build/src/base/
-resource-dir
/Applications/root_v6.26.04/etc//cling/lib/clang/9.0.1
-fmodule-cache-path
/Applications/root_v6.26.04/lib
-nostdinc++
-stdlib=libc++

How these includes are generated, and how to proceed to remove them ?

Thanks in advance

Jérémie

It looks like a cmake issue ? right ? @bellenot may know.

Actually it seems to be done by the ROOT_GENERATE_DICTIONARY function that adds automatically the source an build paths to the INCLUDE_DIRECTORIES

1 Like

Hi,

I finally solved the problem. I put the solution here for those that could be interested:

1 - to remove the includes coming from the build and source directory, use the option OPTIONS -noIncludePaths in the ROOT_GENERATE_DICTIONARY fonction

But it is then necessary to define the ROOT_INCLUDE_PATH env variable to be able to find the headers.

2 - Even doing this still let traces on the source directory when building the dictionaries. So if the source directory is no more existing, the TRint print plenty of error messages. The solution for this is to gives to the ROOT_GENERATE_DICTIONARY relative paths for the includes instead of absolute, like in this example:

#---------------------------------------------------------------------------------------------------
#---GENERATE_ROOT_DICTIONARY(libname LINKDEF [name of LinkDef.h] HEADERS [toto.h titi.h ...] DEPENDENCIES [lib1 lib2])
#
#---Generate ROOT dictionary & rootmap.
#   For ROOT6 we generate the .pcm file too.
#   rootmap and pcm will be installed in ${CMAKE_INSTALL_LIBDIR}
#---------------------------------------------------------------------------------------------------

function(GENERATE_ROOT_DICTIONARY libname)
    CMAKE_PARSE_ARGUMENTS(ARG "" "LINKDEF" "HEADERS;SOURCES;DEPENDENCIES" ${ARGN})

    #--remove source path from header filenames to be given to dictionary generator
    set(dictgen_headers)
    foreach(head ${ARG_HEADERS})
      get_filename_component(no_dir_head ${head} NAME)
      set(dictgen_headers ${dictgen_headers} ${no_dir_head})
    endforeach()

    ROOT_GENERATE_DICTIONARY(G__${libname} ${dictgen_headers} MODULE ${libname} LINKDEF ${ARG_LINKDEF} OPTIONS -noIncludePaths)
    set_source_files_properties(${libname}_rdict.pcm ${libname}.rootmap PROPERTIES GENERATED TRUE)
    set_source_files_properties(G__${libname}.cxx G__${libname}.h  PROPERTIES GENERATED TRUE)

    ROOT_LINKER_LIBRARY(${libname} ${ARG_SOURCES} G__${libname}.cxx DEPENDENCIES ${ARG_DEPENDENCIES})
endfunction()

Using this fonction, all works correctly

Cheers

Jérémie

1 Like