CMakeLists.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. set(PICO_DST_INCLUDE_DIRECTORIES
  2. ${CMAKE_SOURCE_DIR}
  3. ${CMAKE_CURRENT_SOURCE_DIR}
  4. ${ROOT_INLCUDE_DIRS}
  5. )
  6. include_directories(${PICO_DST_INCLUDE_DIRECTORIES})
  7. set(PICO_DST_INCLUDE_LIBRARIES
  8. ${ROOT_LIBRARIES}
  9. )
  10. set(PicoDst_h_files
  11. PicoDstBaseEvent.h
  12. PicoDstMCEvent.h
  13. PicoDstRecoEvent.h
  14. PicoDstBaseTrack.h
  15. PicoDstMCTrack.h
  16. PicoDstRecoTrack.h
  17. PicoDstFHCal.h
  18. )
  19. set(PicoDst_cxx_files
  20. PicoDstBaseEvent.cxx
  21. PicoDstMCEvent.cxx
  22. PicoDstRecoEvent.cxx
  23. PicoDstBaseTrack.cxx
  24. PicoDstMCTrack.cxx
  25. PicoDstRecoTrack.cxx
  26. PicoDstFHCal.cxx
  27. )
  28. #---Generate dictionary
  29. ROOT_GENERATE_DICTIONARY(G__PicoDst
  30. ${PicoDst_h_files}
  31. LINKDEF PicoDst.LinkDef.h
  32. )
  33. #---Compile library
  34. add_library(PicoDst SHARED ${PicoDst_cxx_files} G__PicoDst.cxx)
  35. target_link_libraries(PicoDst ${PICO_DST_INCLUDE_LIBRARIES})
  36. set(ENV{PICO_DST_BIN} "${CMAKE_CURRENT_BINARY_DIR}")
  37. set(ENV{PICO_DST_SRC} "${CMAKE_CURRENT_SOURCE_DIR}")
  38. set(ENV{PICO_DST_LIB} "${CMAKE_CURRENT_BINARY_DIR}/libPicoDst.so")
  39. message(STATUS "PICO_DST_BIN: " $ENV{PICO_DST_BIN})
  40. message(STATUS "PICO_DST_SRC: " $ENV{PICO_DST_SRC})
  41. message(STATUS "PICO_DST_LIB: " $ENV{PICO_DST_LIB})
  42. set(BASH "/bin/bash")
  43. file( WRITE ${CMAKE_BINARY_DIR}/setPicoDst.sh "#!${BASH}\n")
  44. file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "\n")
  45. file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_BIN=$ENV{PICO_DST_BIN}\n")
  46. file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_SRC=$ENV{PICO_DST_SRC}\n")
  47. file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_LIB=$ENV{PICO_DST_LIB}\n")
  48. file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "\n")
  49. file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export LD_LIBRARY_PATH=$PICO_DST_BIN:$LD_LIBRARY_PATH\n")
  50. file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PATH=$PICO_DST_BIN:$PATH\n")
  51. IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  52. SET(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/install" CACHE PATH "forcing to install in build directory" FORCE)
  53. ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  54. set(ENV{PICO_DST_SYS} "${CMAKE_INSTALL_PREFIX}/cmake")
  55. message(STATUS "PICO_DST_SYS: " $ENV{PICO_DST_SYS})
  56. file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_SYS=$ENV{PICO_DST_SYS}\n")
  57. install(TARGETS
  58. PicoDst
  59. EXPORT PicoDstConfig
  60. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PicoDst
  61. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PicoDst
  62. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} PicoDst
  63. )
  64. export(TARGETS
  65. PicoDst
  66. NAMESPACE PicoDst::
  67. FILE "${CMAKE_CURRENT_BINARY_DIR}/PicoDstConfig.cmake"
  68. )
  69. install(EXPORT
  70. PicoDstConfig
  71. DESTINATION "${CMAKE_INSTALL_PREFIX}/cmake"
  72. NAMESPACE PicoDst::
  73. )
  74. if(NOT ONLY_ROOT)
  75. #---Compile executable
  76. set(PICODSTCONVERTER_INCLUDE_DIRECTORIES
  77. ${FAIRROOT_INCLUDE_DIR}
  78. ${MPDROOTDIR}/tpc
  79. ${MPDROOTDIR}/kalman
  80. ${MPDROOTDIR}/lhetrack
  81. ${MPDROOTDIR}/mcstack
  82. ${MPDROOTDIR}/strawendcap
  83. ${MPDROOTDIR}/etof
  84. ${MPDROOTDIR}/tof
  85. ${MPDROOTDIR}/sft
  86. ${MPDROOTDIR}/sts
  87. ${MPDROOTDIR}/zdc
  88. ${MPDROOTDIR}/mpddst
  89. ${MPDROOTDIR}/mpdbase
  90. ${MPDROOTDIR}/mpdpid
  91. )
  92. #---Add Needed libraries
  93. find_library(BASE NAMES Base PATHS ${FAIRROOT_LIBRARY_DIR})
  94. find_library(MCSTACK NAMES MCStack PATHS $ENV{FAIRLIBDIR})
  95. find_library(PASSIVE NAMES Passive PATHS $ENV{FAIRLIBDIR})
  96. find_library(MPDFIELD NAMES MpdField PATHS $ENV{FAIRLIBDIR})
  97. find_library(MPDBASE NAMES MpdBase PATHS $ENV{FAIRLIBDIR})
  98. find_library(MPDDST NAMES MpdDst PATHS $ENV{FAIRLIBDIR})
  99. find_library(MPDGENERALGENERATOR NAMES MpdGeneralGenerator PATHS $ENV{FAIRLIBDIR})
  100. find_library(KALMAN NAMES Kalman PATHS $ENV{FAIRLIBDIR})
  101. find_library(CLUSTER NAMES Cluster PATHS $ENV{FAIRLIBDIR})
  102. find_library(TPC NAMES tpc PATHS $ENV{FAIRLIBDIR})
  103. find_library(TOF NAMES Tof PATHS $ENV{FAIRLIBDIR})
  104. find_library(ETOF NAMES Etof PATHS $ENV{FAIRLIBDIR})
  105. find_library(STRAWENDCAP NAMES Strawendcap PATHS $ENV{FAIRLIBDIR})
  106. find_library(ZDC NAMES Zdc PATHS $ENV{FAIRLIBDIR})
  107. find_library(FFD NAMES Ffd PATHS $ENV{FAIRLIBDIR})
  108. find_library(CPC NAMES Cpc PATHS $ENV{FAIRLIBDIR})
  109. find_library(STRAWECT NAMES StrawECT PATHS $ENV{FAIRLIBDIR})
  110. find_library(LHETrack NAMES LHETrack PATHS $ENV{FAIRLIBDIR})
  111. find_library(STS NAMES Sts PATHS $ENV{FAIRLIBDIR})
  112. find_library(MPDPID NAMES MpdPid PATHS $ENV{FAIRLIBDIR})
  113. set(PICODSTCONVERTER_INCLUDE_LIBRARIES
  114. PicoDst ${BASE}
  115. ${MCSTACK} ${PASSIVE} ${KALMAN} ${CLUSTER} ${TPC} ${STS} ${ZDC} ${FFD}
  116. ${STRAWECT} ${STRAWENDCAP} ${LHETRACK} ${TOF}
  117. ${MPDFIELD} ${MPDBASE} ${MPDDST} ${MPDGENERALGENERATOR} ${MPDPID}
  118. )
  119. add_executable(PicoDstConverter PicoDstConverter.cpp)
  120. target_include_directories(PicoDstConverter PUBLIC ${PICODSTCONVERTER_INCLUDE_DIRECTORIES})
  121. target_link_libraries(PicoDstConverter ${PICODSTCONVERTER_INCLUDE_LIBRARIES})
  122. endif()