Debian Codegraph @

examples/Pythia8Example/CMakeLists.txt

raw
1 if (USE_INSTALLED_HEPMC3)
2 #This version is for standalone compilation of examples.
3 option(USE_INTERFACE_FROM_PYTHIA8 "Use Pythia8/Pythia8ToHepMC3.h from Pythia8" OFF)
4 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
5 find_package(Pythia8 QUIET)
6 if(PYTHIA8_FOUND)
7 SET(interfacelocation ${HEPMC3_INTERFACES_DIR}/pythia8/include/Pythia8)
8 if (USE_INTERFACE_FROM_PYTHIA)
9 find_file(interfacefrompythia8 ${PYTHIA8_INCLUDE_DIR}/Pythia8Plugins/Pythia8ToHepMC3.h)
10 if (interfacefrompythia8)
11 message(STATUS " Found Pythia8Plugins/Pythia8ToHepMC3.h in Pythia8 installation in ${PYTHIA8_INCLUDE_DIR}")
12 else()
13 message(FATAL_ERROR " Pythia8Plugins/Pythia8ToHepMC3.h is absent in Pythia8 installation in ${PYTHIA8_INCLUDE_DIR}")
14 endif()
15 SET(interfacelocation ${PYTHIA8_INCLUDE_DIR}/Pythia8Plugings)
16 endif()
17 include_directories(${PROJECT_SOURCE_DIR}/include ${interfacelocation} ${PYTHIA8_INCLUDE_DIR})
18 add_executable(pythia8_example.exe ${CMAKE_CURRENT_SOURCE_DIR}/pythia8_example.cc )
19 endif()
20 else()
21 #This version is for compilation during installation. Should be consistent with Pythia used in tests
22 set(PYTHIA8_ROOT_DIR "" CACHE PATH "Location of Pythia8 installation.")
23 find_package(Pythia8 QUIET)
24 if(PYTHIA8_FOUND)
25 SET(interfacelocation ${PROJECT_SOURCE_DIR}/interfaces/pythia8/include/Pythia8)
26 if (USE_INTERFACE_FROM_PYTHIA)
27 find_file(interfacefrompythia8 ${PYTHIA8_INCLUDE_DIR}/Pythia8Plugins/Pythia8ToHepMC3.h)
28 if (interfacefrompythia8)
29 message(STATUS " Found Pythia8Plugins/Pythia8ToHepMC3.h in Pythia8 installation in ${PYTHIA8_INCLUDE_DIR}")
30 else()
31 message(FATAL_ERROR " Pythia8Plugins/Pythia8ToHepMC3.h is absent in Pythia8 installation in ${PYTHIA8_INCLUDE_DIR}")
32 endif()
33 SET(interfacelocation ${PYTHIA8_INCLUDE_DIR}/Pythia8Plugings)
34 endif()
35 find_file(interfacefrompythia8 ${PYTHIA8_INCLUDE_DIR}/Pythia8Plugins/Pythia8ToHepMC3.h)
36 include_directories(${PROJECT_SOURCE_DIR}/include ${interfacelocation} ${PYTHIA8_INCLUDE_DIR})
37 add_executable(pythia8_example.exe ${CMAKE_CURRENT_SOURCE_DIR}/pythia8_example.cc )
38 endif()
39 endif()
40
41
42 if(PYTHIA8_FOUND)
43 target_link_libraries(pythia8_example.exe ${PYTHIA8_LIBRARIES} HepMC3)
44 set_target_properties(pythia8_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR})
45
46 # create environment scripts
47
48 set(bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
49 get_filename_component(PYTHIA8_LIB_DIR ${PYTHIA8_LIBRARY} PATH)
50 set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:${PYTHIA8_LIB_DIR}")
51 set(pythia8data "${PYTHIA8_XMLDOC_DIR}")
52
53 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pythia8_example_env.sh.in
54 ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/pythia8_example_env.sh
55 @ONLY
56 )
57 # installs
58
59 install(TARGETS pythia8_example.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
60 install(FILES pythia8_ee_to_Z_to_tautau.conf DESTINATION ${CMAKE_INSTALL_BINDIR})
61 install(DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/ DESTINATION ${CMAKE_INSTALL_BINDIR}
62 FILES_MATCHING PATTERN "*env.sh*")
63
64 else()
65 message(STATUS "Examples: Pythia8 package not found. Please check if PYTHIA8_ROOT_DIR is set properly.")
66 message(STATUS "pythia8_example disabled")
67 endif()