# - Finds ROOT instalation # This module sets up ROOT information # It defines: # ROOT_FOUND If the ROOT is found # ROOT_INCLUDE_DIR PATH to the include directory # ROOT_LIBRARIES Most common libraries # ROOT_LIBRARY_DIR PATH to the library directory set(libs) find_program(ROOT_CONFIG_EXECUTABLE root-config PATHS ${ROOTSYS}/bin $ENV{ROOTSYS}/bin) if(NOT ROOT_CONFIG_EXECUTABLE) set(ROOT_FOUND FALSE) else() set(ROOT_FOUND TRUE) execute_process( COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix OUTPUT_VARIABLE ROOTSYS OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( COMMAND ${ROOT_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE ROOT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir OUTPUT_VARIABLE ROOT_INCLUDE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs OUTPUT_VARIABLE ROOT_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE) set(ROOTSYS D:/ROOT_CERN/root_v5.34.21) set(ROOT_VERSION 5.34/21) set(ROOT_INCLUDE_DIR ${ROOTSYS}/include) set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libGpad.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libHist.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libGraf.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libGraf3d.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libTree.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libRint.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libPostscript.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libMatrix.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libPhysics.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libMathCore.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libRIO.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libNet.lib) #list(APPEND libs ${ROOT_LIBRARY_DIR}/libThread.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libCore.lib) list(APPEND libs ${ROOT_LIBRARY_DIR}/libCint.lib) set(ROOT_LIBRARIES ${libs}) #set(${ROOT_LIBRARY_DIR}/*.lib) #set(ROOT_LIBRARIES -LIBPATH:${ROOT_LIBRARY_DIR} libGpad.lib libHist.lib libGraf.lib libGraf3d.lib libTree.lib libRint.lib libPostscript.lib libMatrix.lib libPhysics.lib libMathCore.lib libRIO.lib libNet.lib libThread.lib libCore.lib libCint.lib) execute_process( COMMAND ${ROOT_CONFIG_EXECUTABLE} --python-version OUTPUT_VARIABLE ROOT_PYTHONVER OUTPUT_STRIP_TRAILING_WHITESPACE) set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) # Make variables changeble to the advanced user mark_as_advanced(ROOT_CONFIG_EXECUTABLE) endif() # report result if(ROOT_FOUND) message(STATUS "Found ROOT version ${ROOT_VERSION} in ${ROOTSYS}") message(STATUS "Using ROOT include dir ${ROOT_INCLUDE_DIR}") message(STATUS "Using ROOT library dir ${ROOT_LIBRARY_DIR}") message(STATUS "Using ROOT libraries: ${ROOT_LIBRARIES}") else() if(ROOT_FIND_REQUIRED) message(FATAL_ERROR "Unable to find requested ROOT installation:${ROOT_ERROR_REASON}") else() if(NOT ROOT_FIND_QUIETLY) message(STATUS "ROOT was not found.") endif() endif() endif() #include(CMakeMacroParseArguments) old include(CMakeParseArguments) #new find_program(ROOTCINT_EXECUTABLE rootcint PATHS $ENV{ROOTSYS}/bin) find_program(GENREFLEX_EXECUTABLE genreflex PATHS $ENV{ROOTSYS}/bin) find_package(GCCXML) #---------------------------------------------------------------------------- # function ROOT_GENERATE_DICTIONARY( dictionary # header1 header2 ... # LINKDEF linkdef1 ... # OPTIONS opt1...) function(ROOT_GENERATE_DICTIONARY dictionary) CMAKE_PARSE_ARGUMENTS(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN}) #---Get the list of header files------------------------- set(headerfiles) foreach(fp ${ARG_UNPARSED_ARGUMENTS}) file(GLOB files ${fp}) if(files) foreach(f ${files}) if(NOT f MATCHES LinkDef) set(headerfiles ${headerfiles} ${f}) endif() endforeach() else() set(headerfiles ${headerfiles} ${fp}) endif() endforeach() #---Get the list of include directories------------------ # Filter out UNIX system directory to workaround bug in # rootcint (info from Andrea Dotti, and info from post: # http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=15086 get_directory_property(incdirs INCLUDE_DIRECTORIES) set(includedirs) foreach( d ${incdirs}) if(NOT ${d} STREQUAL "/usr/include") set(includedirs ${includedirs} -I${d}) endif() endforeach() #---Get LinkDef.h file------------------------------------ set(linkdefs) foreach( f ${ARG_LINKDEF}) if( IS_ABSOLUTE ${f}) set(linkdefs ${linkdefs} ${f}) else() if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) else() set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) endif() endif() endforeach() #---call rootcint------------------------------------------ add_custom_command(OUTPUT ${dictionary}.cxx ${dictionary}.h COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx -c ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs} DEPENDS ${headerfiles} ${linkdefs}) endfunction() #---------------------------------------------------------------------------- # function REFLEX_GENERATE_DICTIONARY(dictionary # header1 header2 ... # SELECTION selectionfile ... # OPTIONS opt1...) function(REFLEX_GENERATE_DICTIONARY dictionary) CMAKE_PARSE_ARGUMENTS(ARG "" "" "SELECTION;OPTIONS" "" ${ARGN}) #---Get the list of header files------------------------- set(headerfiles) foreach(fp ${ARG_UNPARSED_ARGUMENTS}) file(GLOB files ${fp}) if(files) foreach(f ${files}) set(headerfiles ${headerfiles} ${f}) endforeach() else() set(headerfiles ${headerfiles} ${fp}) endif() endforeach() #---Get Selection file------------------------------------ if(IS_ABSOLUTE ${ARG_SELECTION}) set(selectionfile ${ARG_SELECTION}) else() set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION}) endif() #---Get the list of include directories------------------ get_directory_property(incdirs INCLUDE_DIRECTORIES) set(includedirs) foreach( d ${incdirs}) set(includedirs ${includedirs} -I${d}) endforeach() #---Get preprocessor definitions-------------------------- get_directory_property(defs COMPILE_DEFINITIONS) foreach( d ${defs}) set(definitions ${definitions} -D${d}) endforeach() #---Names and others--------------------------------------- set(gensrcdict ${dictionary}.cpp) if(MSVC) set(gccxmlopts "--gccxmlopt=\"--gccxml-compiler cl\"") elseif(APPLE) set(gccxmlopts "--gccxmlopt=--gccxml-compiler g++ ") else() set(gccxmlopts) endif() #set(rootmapname ${dictionary}Dict.rootmap) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Check GCCXML and get path----------------------------- if(GCCXML) get_filename_component(gccxmlpath ${GCCXML} PATH) else() message(WARNING "GCCXML not found. Install and setup your environment to find 'gccxml' executable") endif() #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} COMMAND ${GENREFLEX_EXECUTABLE} ${headerfiles} -o ${gensrcdict} ${gccxmlopts} ${rootmapopts} --select=${selectionfile} --gccxmlpath=${gccxmlpath} ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction()