Warning, /eic-smear/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 # CMakeLists.txt for libeicsmear.
0002 #
0003 # To build using cmake, create a build directory, navigate
0004 # to it and run cmake. e.g. assuming we start in the eicsmear
0005 # source directory:
0006 # mkdir build
0007 # cd build
0008 # cmake .. (or whatever the path to the source directory is)
0009 #
0010 # For PYTHIA6-related code to be built the user must
0011 # provide the following argument to cmake:
0012 # -DPYTHIA6_LIBDIR=<path to directory containing libPythia6>
0013 #
0014 # You can specify an install directory via
0015 # -DCMAKE_INSTALL_PREFIX=<path>
0016 # then do
0017 # make install
0018 # to install the headers and libraries under that location.
0019 # There is no "make uninstall" but (on Unix-like systems)
0020 # you can do
0021 # xargs rm < install_manifest.txt
0022 # from the cmake build directory.
0023
0024 cmake_minimum_required(VERSION 3.10)
0025 project(eicsmear VERSION 1.1.12 LANGUAGES CXX )
0026
0027 # cmake needs a bit of help to find modules
0028 set(
0029 CMAKE_MODULE_PATH
0030 ${CMAKE_MODULE_PATH}
0031 ${CMAKE_SOURCE_DIR}/cmake/Modules/
0032 ${CMAKE_SOURCE_DIR}/cmake/
0033 )
0034
0035 # Need ROOT first to define some macros
0036 # 6.16 _should_ be sufficient, but I couldn't test it
0037 # Anything before that needs special cmake attention for dictionary generation
0038 # Bumping it up further to 6.20 for smoother cmake support
0039 find_package(ROOT 6.20 CONFIG REQUIRED)
0040
0041 message ( " ROOT Libraries = " ${ROOT_LIBRARIES} )
0042
0043 # # Clumsy hack if we ever need it again
0044 # string(SUBSTRING ${ROOT_VERSION} 0 1 ROOT_MAJOR)
0045 # string(SUBSTRING ${ROOT_VERSION} 2 2 ROOT_MINOR)
0046 # message ( " ROOT_VERSION = " ${ROOT_VERSION})
0047 # message ( " ROOT_MAJOR = " ${ROOT_MAJOR})
0048 # message ( " ROOT_MINOR = " ${ROOT_MINOR})
0049 # IF(${ROOT_MINOR} GREATER 24)
0050 # if(NOT DEFINED CMAKE_CXX_STANDARD)
0051 # set(CMAKE_CXX_STANDARD 14)
0052 # endif()
0053 # ENDIF()
0054
0055 # Is HepMC available?
0056 find_package(HepMC3 QUIET HINTS ${HepMC3_DIR} ${HepMC3} )
0057
0058 # Make zlib required. It's almost everywhere, and this avoids ugly ifdefs and such
0059 find_package(ZLIB REQUIRED)
0060
0061 ##############################################################################################################
0062
0063 # Main target is the libeicsmear library
0064 # staying away from wildcards and variables
0065 add_library(
0066 eicsmear
0067 SHARED
0068 src/gzstream.cc
0069 src/functions.cxx
0070 src/erhic/BeamParticles.cxx
0071 src/erhic/BuildTree.cxx
0072 src/erhic/EventDis.cxx
0073 src/erhic/EventDjangoh.cxx
0074 src/erhic/EventDpmjet.cxx
0075 src/erhic/EventFactory.cxx
0076 src/erhic/EventGmcTrans.cxx
0077 src/erhic/EventHepMC.cxx
0078 src/erhic/EventMC.cxx
0079 src/erhic/EventMilou.cxx
0080 src/erhic/EventPepsi.cxx
0081 src/erhic/EventPythia.cxx
0082 src/erhic/EventRapgap.cxx
0083 src/erhic/EventSimple.cxx
0084 src/erhic/EventDEMP.cxx
0085 src/erhic/EventSartre.cxx
0086 src/erhic/File.cxx
0087 src/erhic/Forester.cxx
0088 src/erhic/Kinematics.cxx
0089 src/erhic/ParticleIdentifier.cxx
0090 src/erhic/ParticleMC.cxx
0091 src/erhic/Pid.cxx
0092 src/smear/Acceptance.cxx
0093 src/smear/Bremsstrahlung.cxx
0094 src/smear/Detector.cxx
0095 src/smear/Device.cxx
0096 src/smear/Distributor.cxx
0097 src/smear/EventDisFactory.cxx
0098 src/smear/EventSmear.cxx
0099 src/smear/FormulaString.cxx
0100 src/smear/ParticleID.cxx
0101 src/smear/ParticleMCS.cxx
0102 src/smear/PerfectID.cxx
0103 src/smear/PlanarTracker.cxx
0104 src/smear/RadialTracker.cxx
0105 src/smear/Smear.cxx
0106 src/smear/SmearTree.cxx
0107 src/smear/Tracker.cxx
0108 src/smear/NumSigmaPid.cxx
0109 )
0110
0111 # include directories
0112 target_include_directories(eicsmear
0113 PUBLIC
0114 $<INSTALL_INTERFACE:include>
0115 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
0116
0117 PRIVATE
0118 ${CMAKE_CURRENT_SOURCE_DIR}/cint
0119 ${ROOT_INCLUDE_DIRS}
0120 )
0121
0122 # Require at least c++11. Could require individual features instead too
0123 target_compile_features(eicsmear PUBLIC cxx_std_11)
0124
0125 # Can add addtional options here
0126 target_compile_options(eicsmear PRIVATE -Wall -Wextra -pedantic -g)
0127
0128 # Optional sources if HepMC3 is installed
0129 if(HepMC3_FOUND)
0130 message ( "-- HepMC3 library found at ${HEPMC3_LIB} --> Adding HepMC sources and headers" )
0131 target_sources( eicsmear
0132 PRIVATE
0133 src/erhic/EventFactoryHepMC.cxx
0134 src/erhic/TreeToHepMC.cxx
0135 )
0136 target_include_directories(eicsmear
0137 PRIVATE
0138 ${HEPMC3_INCLUDE_DIR}
0139 )
0140 else()
0141 message ( "-- HepMC3 library not found" )
0142 endif()
0143 message ( "---- You can specify a HepMC3 installation using \"-DHepMC3=[path/to/lib]\" " )
0144
0145
0146 ##############################################################################################################
0147 # Generate CINT dictionary.
0148 #----------------------------------------------------------------------------
0149 # Arguments are:
0150 #---ROOT_GENERATE_DICTIONARY( dictionary headerfiles NODEPHEADERS ghdr1 ghdr2 ...
0151 # MODULE module DEPENDENCIES dep1 dep2
0152 # BUILTINS dep1 dep2
0153 # STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...)
0154 #
0155 # <dictionary> is the dictionary stem; the macro creates (among other files) the dictionary source as
0156 # <dictionary>.cxx
0157 # <headerfiles> are "as included"; set appropriate INCLUDE_DIRECTORIES property on the directory.
0158 # The dictionary target depends on these headers. These files must exist.
0159 # <NODEPHEADERS> same as <headerfiles>. If these files are not found (given the target include path)
0160 # no error is emitted. The dictionary does not depend on these headers.
0161
0162 ## Note, Even using MULTIDICT option, I end up with duplicate symbols if trying to spread one library over multiple dictionaries
0163 ## Not worth the trouble, combining them all into one.
0164
0165 # if(ROOT_VERSION VERSION_LESS 6.20)
0166 # include("${ROOT_DIR}/modules/RootNewMacros.cmake")
0167 # else()
0168 # include("${ROOT_DIR}/RootMacros.cmake")
0169 # endif()
0170
0171 include("${ROOT_DIR}/RootMacros.cmake")
0172 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
0173 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cmake")
0174
0175 # Main eRHIC dictionary.
0176 # To make hepmc sources optional, build up arguments
0177 set(
0178 ERHIC_HEADERS
0179 eicsmear/functions.h
0180 eicsmear/erhic/BeamParticles.h
0181 eicsmear/erhic/DisKinematics.h
0182 eicsmear/erhic/EventBase.h
0183 eicsmear/erhic/EventDis.h
0184 eicsmear/erhic/EventDjangoh.h
0185 eicsmear/erhic/EventDpmjet.h
0186 eicsmear/erhic/EventFactory.h
0187 eicsmear/erhic/EventGmcTrans.h
0188 eicsmear/erhic/EventMC.h
0189 eicsmear/erhic/EventMCFilterABC.h
0190 eicsmear/erhic/EventMilou.h
0191 eicsmear/erhic/EventPepsi.h
0192 eicsmear/erhic/EventPythia.h
0193 eicsmear/erhic/EventRapgap.h
0194 eicsmear/erhic/EventSimple.h
0195 eicsmear/erhic/EventDEMP.h
0196 eicsmear/erhic/EventSartre.h
0197 eicsmear/erhic/EventHepMC.h
0198 eicsmear/erhic/File.h
0199 eicsmear/erhic/Forester.h
0200 eicsmear/erhic/Kinematics.h
0201 eicsmear/erhic/Particle.h
0202 eicsmear/erhic/ParticleIdentifier.h
0203 eicsmear/erhic/ParticleMC.h
0204 eicsmear/erhic/Pid.h
0205 eicsmear/erhic/VirtualEvent.h
0206 eicsmear/erhic/VirtualParticle.h
0207 )
0208 set( ERHIC_INCPATHS
0209 ${CMAKE_SOURCE_DIR}/include
0210 ${CMAKE_SOURCE_DIR}/cint
0211 ${ROOT_INCLUDE_DIRS}
0212 )
0213
0214 if(HepMC3_FOUND)
0215 list( APPEND
0216 ERHIC_HEADERS
0217 eicsmear/erhic/EventFactoryHepMC.h
0218 )
0219 list( APPEND
0220 ERHIC_INCPATHS
0221 ${HEPMC3_INCLUDE_DIR}
0222 )
0223 endif()
0224
0225 ROOT_GENERATE_DICTIONARY( G__eicsmear
0226 ${ERHIC_HEADERS}
0227 MULTIDICT
0228 MODULE eicsmear
0229 LINKDEF cint/LinkDef.h
0230 )
0231
0232 # Require at least c++11
0233 target_compile_features(G__eicsmear PUBLIC cxx_std_11)
0234
0235 # Smearing code dictionary.
0236 ROOT_GENERATE_DICTIONARY( smearDict
0237 eicsmear/smear/Acceptance.h
0238 eicsmear/smear/Bremsstrahlung.h
0239 eicsmear/smear/Detector.h
0240 eicsmear/smear/Device.h
0241 eicsmear/smear/Distributor.h
0242 eicsmear/smear/EventS.h
0243 eicsmear/smear/EventSmear.h
0244 eicsmear/smear/EventDisFactory.h
0245 eicsmear/smear/FormulaString.h
0246 eicsmear/smear/functions.h
0247 eicsmear/smear/ParticleID.h
0248 eicsmear/smear/ParticleMCS.h
0249 eicsmear/smear/PerfectID.h
0250 eicsmear/smear/PlanarTracker.h
0251 eicsmear/smear/RadialTracker.h
0252 eicsmear/smear/Smear.h
0253 eicsmear/smear/Smearer.h
0254 eicsmear/smear/Tracker.h
0255 eicsmear/smear/PID.h
0256 eicsmear/smear/NumSigmaPid.h
0257 MULTIDICT
0258 MODULE eicsmear
0259 LINKDEF cint/smearLinkDef.h
0260 )
0261
0262 # Require at least c++11
0263 target_compile_features(smearDict PUBLIC cxx_std_11)
0264
0265 ## Build PYTHIA6-dependent functionality if a library directory was specified.
0266 ## This comprises PYTHIA-related stuff in the main eRHIC directory,
0267 ## plus the hadronic code.
0268 if(PYTHIA6_LIBDIR)
0269 message ( "-- PYTHIA6_LIBDIR specified --> Adding PYTHIA sources and headers" )
0270
0271 # Create the pythia dictionary.
0272 ROOT_GENERATE_DICTIONARY( pythiaDict
0273 eicsmear/erhic/Pythia6.h
0274 eicsmear/erhic/Pythia6EventBuilder.h
0275 eicsmear/erhic/Pythia6ParticleBuilder.h
0276 MULTIDICT
0277 MODULE eicsmear
0278 LINKDEF cint/LinkDefPythia.h
0279 )
0280 # Require at least c++11
0281 target_compile_features(pythiaDict PUBLIC cxx_std_11)
0282
0283 # Create the hadronic dictionary.
0284 ROOT_GENERATE_DICTIONARY( hadronicDict
0285 eicsmear/hadronic/EventMC.h
0286 eicsmear/hadronic/EventPythia.h
0287 eicsmear/hadronic/ParticleMC.h
0288 eicsmear/hadronic/Pythia6EventFactory.h
0289 eicsmear/hadronic/EventSmear.h
0290 MULTIDICT
0291 MODULE eicsmear
0292 LINKDEF cint/hadronicLinkDef.h
0293 )
0294 # Require at least c++11
0295 target_compile_features(hadronicDict PUBLIC cxx_std_11)
0296
0297 # Additional PYTHIA-related and hadronic source files
0298 target_sources( eicsmear
0299 PRIVATE
0300 src/erhic/Pythia6.cxx
0301 src/erhic/Pythia6EventBuilder.cxx
0302 src/erhic/Pythia6ParticleBuilder.cxx
0303 src/hadronic/EventMC.cxx
0304 src/hadronic/EventPythia.cxx
0305 src/hadronic/EventSmear.cxx
0306 src/hadronic/ParticleMC.cxx
0307 src/hadronic/Pythia6EventFactory.cxx
0308 )
0309 endif(PYTHIA6_LIBDIR)
0310
0311
0312 ##############################################################################################################
0313
0314 ## Build the library
0315 ## this can be improved with newer root versions
0316
0317 target_link_libraries(eicsmear ROOT::Core ROOT::RIO ROOT::Rint ROOT::Tree ROOT::EG ROOT::Physics -lz )
0318
0319 if(PYTHIA6_LIBDIR)
0320 target_link_libraries(eicsmear ROOT::EGPythia6 ROOT::Eve )
0321 endif(PYTHIA6_LIBDIR)
0322
0323 if(HepMC3_FOUND)
0324 target_link_libraries(eicsmear ${HEPMC3_LIBRARIES} )
0325 endif()
0326
0327 ##############################################################################################################
0328
0329 ## Build executables
0330
0331 # eic-smear interface
0332 add_executable(eic-smear scripts/eic-smear.cxx)
0333 target_compile_features(eic-smear PUBLIC cxx_std_11)
0334 target_compile_options(eic-smear PRIVATE -Wall -Wextra -pedantic -g)
0335 target_link_libraries(eic-smear eicsmear )
0336 target_include_directories(eic-smear
0337 PRIVATE
0338 ${ROOT_INCLUDE_DIRS}
0339 )
0340
0341 # if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
0342 # target_compile_options(eic-smear PUBLIC -fPIC)
0343 # endif()
0344 install(TARGETS eic-smear DESTINATION bin)
0345
0346 ## pythia6:
0347 if ( PYTHIA6_LIBDIR )
0348 add_executable(compiled_runpythia
0349 scripts/compiled_runpythia.cpp
0350 scripts/runpythia.cpp
0351 )
0352
0353 target_include_directories(compiled_runpythia
0354 PRIVATE
0355 ${ROOT_INCLUDE_DIRS}
0356 )
0357 target_compile_features(compiled_runpythia PUBLIC cxx_std_11)
0358 target_compile_options(compiled_runpythia PRIVATE -Wall -Wextra -pedantic -g)
0359
0360
0361 target_link_libraries(compiled_runpythia
0362 eicsmear ROOT::Core ROOT::RIO ROOT::Rint ROOT::Tree ROOT::EG ROOT::EGPythia6 ROOT::Eve
0363 )
0364 endif(PYTHIA6_LIBDIR)
0365
0366 ##############################################################################################################
0367
0368 ## Install library
0369 # Could also use include(GNUInstallDirs)
0370 # and then destinations of the form ${CMAKE_INSTALL_INCLUDEDIR}
0371 install(TARGETS eicsmear
0372 EXPORT eicsmear-export
0373 LIBRARY DESTINATION lib
0374 ARCHIVE DESTINATION lib
0375 )
0376
0377 ## Ideally, one would have a small list of headers
0378 ## matched to the target via set_target_properties(eicsmear PROPERTIES PUBLIC_HEADER eicsmear/functions.h )
0379 ## and then use PUBLIC_HEADER DESTINATION include above.
0380 ## However, ROOT wants to see all headers, so we just copy them into place by hand
0381 ## Note that this means the pythia6-related headers get installed regardless of
0382 ## whether that functionality is compiled in (because they live in the same directories).
0383
0384 ## Install headers and pcm files
0385 install (DIRECTORY ${CMAKE_SOURCE_DIR}/include/eicsmear/erhic
0386 DESTINATION include/eicsmear
0387 )
0388 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/eicsmear/smear
0389 DESTINATION DESTINATION include/eicsmear
0390 )
0391
0392 INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/eicsmear/functions.h
0393 DESTINATION include/eicsmear
0394 )
0395
0396 INSTALL(FILES
0397 ${CMAKE_CURRENT_BINARY_DIR}/libeicsmear32.rootmap
0398 DESTINATION lib
0399 )
0400
0401 INSTALL(FILES
0402 ${CMAKE_CURRENT_BINARY_DIR}/libeicsmear_G__eicsmear_rdict.pcm
0403 ${CMAKE_CURRENT_BINARY_DIR}/libeicsmear_smearDict_rdict.pcm
0404 DESTINATION lib
0405 )
0406
0407 if(PYTHIA6_LIBDIR)
0408 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/eicsmear/hadronic
0409 DESTINATION include/eicsmear
0410 )
0411 INSTALL(FILES
0412 ${CMAKE_CURRENT_BINARY_DIR}/libeicsmear_pythiaDict_rdict.pcm
0413 ${CMAKE_CURRENT_BINARY_DIR}/libeicsmear_hadronicDict_rdict.pcm
0414 DESTINATION lib
0415 )
0416
0417 endif()
0418
0419 ## Generate configuration file
0420 install(EXPORT eicsmear-export
0421 FILE
0422 eicsmearConfig.cmake
0423 NAMESPACE
0424 eicsmear::
0425 DESTINATION
0426 cmake
0427 )
0428
0429 ## Final message
0430 message( " !! After installation, you should also install detectors and tests from https://github.com/eic/eicsmeardetectors. ")
0431
0432
0433 # Version check no longer needed b/c c++11 is now always required.
0434 # But leaving it in for future needs
0435 # string(SUBSTRING ${ROOT_VERSION} 0 1 ROOT_MAJOR)
0436 # message ( " ROOT_VERSION = " ${ROOT_VERSION})
0437 # message ( " ROOT_MAJOR = " ${ROOT_MAJOR})
0438 # IF(${ROOT_MAJOR} GREATER 5)
0439 # if(NOT DEFINED CMAKE_CXX_STANDARD)
0440 # set(CMAKE_CXX_STANDARD 11)
0441 # endif()
0442 #ENDIF()
0443