Adding new directory to FairRoot

  • Create a sub-directory in the FAIRROOT directory (MyDir)
  • Edit the file FAIRROOT/CMakeList.txt and add MyDir to the list of subdirectories

          add_subdirectory (base)
          add_subdirectory (parbase)
          add_subdirectory (geobase)
          add_subdirectory (MyDir)

  • In MyDir create a file CMakeList.txt this file should contain:

    set(INCLUDE_DIRECTORIES
         ${ROOT_INCLUDE_DIR}
         ${BASE_INCLUDE_DIRECTORIES}
         .......(here you add the modules you use (include))
         {FAIRROOT_SOURCE_DIR}/MyDir
    )

    include_directories( ${INCLUDE_DIRECTORIES})
    set(LINK_DIRECTORIES
         ${ROOT_LIBRARY_DIR}
         ${FAIRROOT_LIBRARY_DIR}
         (any library path you need comes here)
    )

    link_directories( ${LINK_DIRECTORIES})

    set(MyDir_SRCS
         MyDetGeo.cxx
         MyDetParSet.cxx
         ....
    )

    # fill list of header files from list of source files
    # by exchanging the file extension
    CHANGE_FILE_EXTENSION(*.cxx *.h MyDir_HEADERS "${MyDir_SRCS}")

    set(MyDir_LINKDEF MyDirLinkDef.h)
    set(MyDir_DICTIONARY ${CMAKE_CURRENT_BINARY_DIR}/MyDirDict.cxx)

    ROOT_GENERATE_DICTIONARY("${MyDir_HEADERS}" "${MyDir_LINKDEF}"
    "${MyDir_DICTIONARY}" "${INCLUDE_DIRECTORIES}")

    set(MyDir_SRCS ${MyDir_SRCS} ${MyDir_DICTIONARY})

    add_library(MyDir SHARED ${MyDir_SRCS})
    target_link_libraries(Mydir ${ROOT_LIBRARIES})
    set_target_properties(MyDir PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES})

    ################ install ###################
    install(TARGETS MyDir DESTINATION ${CMAKE_BINARY_DIR}/lib)