| 1 |
|
| 2 |
set(basic_sources ${CMAKE_CURRENT_SOURCE_DIR}/convert_example.cc |
| 3 |
${CMAKE_CURRENT_SOURCE_DIR}/cmdline.c |
| 4 |
${CMAKE_CURRENT_SOURCE_DIR}/src/WriterDOT.cc |
| 5 |
${CMAKE_CURRENT_SOURCE_DIR}/src/WriterHEPEVTZEUS.cc ) |
| 6 |
set(basic_includes ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} ) |
| 7 |
set(basic_libraries HepMC3) |
| 8 |
set(basic_defines HEPMCCONVERT_EXTENSION_HEPEVTZEUS=1 HEPMCCONVERT_EXTENSION_DOT=1) |
| 9 |
set(basic_dependencies ) |
| 10 |
set(basic_libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" ) |
| 11 |
find_package(ZLIB) |
| 12 |
if(ZLIB_FOUND) |
| 13 |
list(APPEND basic_includes ${ZLIB_INCLUDE_DIR}) |
| 14 |
list(APPEND basic_sources ${CMAKE_CURRENT_SOURCE_DIR}/src/gzstream.C ) |
| 15 |
list(APPEND basic_libraries ${ZLIB_LIBRARIES}) |
| 16 |
list(APPEND basic_defines HEPMCCONVERT_EXTENSION_GZ=1) |
| 17 |
# create environment scripts |
| 18 |
set(basic_libdir "${basic_libdir}:${ZLIB_ROOT}") |
| 19 |
endif() |
| 20 |
|
| 21 |
if(ROOT_FOUND) |
| 22 |
list(APPEND basic_includes ${PROJECT_SOURCE_DIR}/rootIO/include ${ROOT_INCLUDE_DIRS}) |
| 23 |
list(APPEND basic_sources ${CMAKE_CURRENT_SOURCE_DIR}/src/WriterRootTreeOPAL.cc ) |
| 24 |
list(APPEND basic_libraries ${ROOT_LIBRARIES} HepMC3rootIO) |
| 25 |
list(APPEND basic_defines HEPMCCONVERT_EXTENSION_ROOTTREEOPAL=1) |
| 26 |
list(APPEND basic_dependencies dictionary) |
| 27 |
# create environment scripts |
| 28 |
set(basic_libdir "${basic_libdir}:${ROOT_LIBRARY_DIR}") |
| 29 |
endif() |
| 30 |
|
| 31 |
|
| 32 |
add_executable(convert_example.exe ${basic_sources} ) |
| 33 |
include_directories(${basic_includes}) |
| 34 |
target_link_libraries(convert_example.exe ${basic_libraries} ) |
| 35 |
target_compile_definitions(convert_example.exe PRIVATE ${basic_defines} ) |
| 36 |
if (basic_dependencies) |
| 37 |
add_dependencies( convert_example.exe ${basic_dependencies} ) |
| 38 |
endif() |
| 39 |
# create environment scripts |
| 40 |
set(bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") |
| 41 |
set(libdir ${basic_libdir}) |
| 42 |
set_target_properties(convert_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}) |
| 43 |
|
| 44 |
configure_file( |
| 45 |
${CMAKE_CURRENT_SOURCE_DIR}/convert_example_env.sh.in |
| 46 |
${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/convert_example_env.sh @ONLY) |
| 47 |
|
| 48 |
# installs |
| 49 |
install(TARGETS convert_example.exe DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 50 |
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_BINDIR} FILES_MATCHING PATTERN "*.pcm" PATTERN "*config" PATTERN "CMakeFiles" EXCLUDE ) |
| 51 |
install(DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/ DESTINATION ${CMAKE_INSTALL_BINDIR} FILES_MATCHING PATTERN "*env.sh*") |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
#The cmdline.c and cmdline.h for this example are generated from file below |
| 59 |
#gengetopt -N --no-version --input=hepmcconvert.ggo --include-getopt --show-required -u"inputfile outputfile" |
| 60 |
#version "3.1" |
| 61 |
#package "hepmcconvert" |
| 62 |
#purpose "Convert between different file formats of Monte Carlo event record. |
| 63 |
#Example: |
| 64 |
# hepmcconvert -i hepmc2 -o treeroot input.hepmc output.root |
| 65 |
#" |
| 66 |
#option "input-format" i "Input format" string required values="hepmc2", "hepmc3", "hpe" ,"root", "treeroot","lhef","gz" |
| 67 |
#option "output-format" o "Output format" string required values="hepmc2", "hepmc3", "hpe" ,"root", "treeroot" ,"treerootopal","hpezeus", "dump", "dot" |
| 68 |
#option "extensions" e "Extensions, in a form extension=value, could be passed to readers/writers" multiple optional string |
| 69 |
#option "events-limit" - "Limit of events to read from input" optional long default="100000000" |
| 70 |
#option "first-event-number" - "Lowest allowed event number" optional long default="-100000000" |
| 71 |
#option "last-event-number" - "Highest allowed event number" optional long default="100000000" |
| 72 |
#option "print-every-events-parsed" - "Frequency of parsing information printouts" optional long default="100" |