Cmake and FindROOT

Hi,

I found an updated version of FindROOT.cmake in an old commit from 2012, http://root.cern.ch/gitweb?p=root.git;a=commit;h=c750eec91fc70c4f2c5bd1fd0bbaa0fb0979c056. It might be useful if this was more prominently indicated that there is a new version as the information of the FAQ http://root.cern.ch/drupal/content/can-i-integrate-root-my-cmake-build is quite dated, from 2009.

Also, I have made some corrections to properly handle dictionary generation in which the header files are not in the same directory as the source files. I’ve attached my most recent version for those who are interested in this. Be sure to change the filename to FindROOT.cmake (The forum would not let me upload the file with this extension.)
FindROOT_cmake.C (5.94 KB)

I have committed your modified FindROOT.cmake to the 5.34 branch. Thanks for your contribution.

After some further study of cmake I have again improved the FindROOT.cmake file. This is a reduction of the previous file which was performing unnecessary steps. I’ve also added the variable ROOT_GUI_LIBRARIES for those who are compiling ROOT gui with the standard root-config --glibs. I also removed extraneous commented lines.

I am not making use of the REFLEX_GENERATE_LIBRARY command so it has not been tested, but I did not alter it significantly enough to change its functionality.

The attached file should be renamed to FindROOT.cmake
FindROOT_cmake.C (5.49 KB)

I found an issue with ROOT_GENERATE_DICTIONARY for ROOT 5 with GCC > 4.9 on Arch Linux
rootcint would crash when given every directory from INCLUDE_DIRECTORIES
the culprit turned out to be "-I/usr/include"
The “continue()” command was added to CMake in December so I’ve added that here:
github.com/dougphy/frate/commit … be6a38d4b4
To skip adding -I/usr/include to the custom command

Just curious, do you include /usr/include on purpose or is it in INCLUDE_DIRECTORIES by default? If by default, why does it cause an issue with your distribution and not previously? These raises the more general question of why does Cint crash when this directory is passed to it?

/usr/include is part of INCLUDE_DIRECTORIES by default – I also find the crash a bit weird. It only occurs on Arch with ROOT5 and not ROOT6. Like I said – I think it might be a GCC issue, definitely not sure though. I’m making this assumption based on the following error:

[ddavis@proton ~/ASW/frateZ/build]$ make VERBOSE=1 /usr/bin/cmake -H/home/ddavis/ASW/frateZ -B/home/ddavis/ASW/frateZ/build --check-build-system CMakeFiles/Makefile.cmake 0 /usr/bin/cmake -E cmake_progress_start /home/ddavis/ASW/frateZ/build/CMakeFiles /home/ddavis/ASW/frateZ/build/CMakeFiles/progress.marks make -f CMakeFiles/Makefile2 all make[1]: Entering directory '/home/ddavis/ASW/frateZ/build' make -f CMakeFiles/frateZ.dir/build.make CMakeFiles/frateZ.dir/depend make[2]: Entering directory '/home/ddavis/ASW/frateZ/build' /usr/bin/cmake -E cmake_progress_report /home/ddavis/ASW/frateZ/build/CMakeFiles 1 [ 9%] Generating frateZDict.cxx /physics/ROOT/v5-34/bin/rootcint -cint -f frateZDict.cxx -c -I/usr/include -I/physics/ROOT/v5-34/include -I/home/ddavis/ASW/frateZ -I/home/ddavis/ASW/frateZ/include /home/ddavis/ASW/frateZ/include/frateZ/Swizzler.h /home/ddavis/ASW/frateZ/include/frateZ/PhysicsObject.h /home/ddavis/ASW/frateZ/include/frateZ/Jet.h /home/ddavis/ASW/frateZ/include/frateZ/Lepton.h /home/ddavis/ASW/frateZ/include/frateZ/LeptonPair.h /home/ddavis/ASW/frateZ/include/frateZ/MET.h /home/ddavis/ASW/frateZ/include/frateZ/FinalState.h /home/ddavis/ASW/frateZ/include/frateZ/Scaler.h /home/ddavis/ASW/frateZ/include/frateZ/LinkDef.h #error "You need a ISO C conforming compiler to use the glibc headers" Error: Missing one of ' \/' expected at or after line 97. Error: Unexpected end of file (G__fgetstream():2) /usr/include/sys/cdefs.h:436: Error: Symbol extern"C"{#define __need_size_t#define __need_NULL#include<stddef is not defined in current scope /usr/include/stdio.h:44: Error: Failed to evaluate extern"C"{#define __need_size_t#define __need_NULL#include<stddef.h>#include<bits/types Error: Failed to evaluate extern"C"{#define __need_size_t#define __need_NULL#include<stddef.h>#include<bits/types.h>#define __need_FILE#define __need___FILE#endif#if!defined __FILE_defined&&defined __need_FILE struct _IO_FILE Error: Symbol __BEGIN_NAMESPACE_STD typedef struct _IO_FILE FILE is not defined in current scope /usr/include/stdio.h:48: Error: Missing one of '{' expected at or after line 90. Error: Unexpected end of file (G__fignorestream():3) /usr/include/stdio.h:947: Error: Missing one of '{' expected at or after line 517. Error: Unexpected end of file (G__fignorestream():3) /usr/include/string.h:646: Error: Symbol div_t is not defined in current scope /usr/include/stdlib.h:101: Error: Symbol lldiv_t is not defined in current scope /usr/include/stdlib.h:121: Error: Missing one of '{' expected at or after line 466. Error: Unexpected end of file (G__fignorestream():3) /usr/include/stdlib.h:970: Error: Missing whitespace at or after line 490. Error: Unexpected end of file (G__fgetspace():2) /usr/include/math.h:493: Report: Unrecognized string '__END_DECLS' ignored /usr/include/math.h:494: Warning: Error occurred during reading source files Warning: Error occurred during dictionary source generation !!!Removing frateZDict.cxx frateZDict.h !!! Error: /physics/ROOT/v5-34/bin/rootcint: error loading headers... CMakeFiles/frateZ.dir/build.make:61: recipe for target 'frateZDict.cxx' failed make[2]: *** [frateZDict.cxx] Error 1 make[2]: Leaving directory '/home/ddavis/ASW/frateZ/build' CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/frateZ.dir/all' failed make[1]: *** [CMakeFiles/frateZ.dir/all] Error 2 make[1]: Leaving directory '/home/ddavis/ASW/frateZ/build' Makefile:116: recipe for target 'all' failed make: *** [all] Error 2