if (USE_INSTALLED_HEPMC3)
  include_directories(${HEPMC3_INTERFACES_DIR}/pythia6/include/Pythia6/)
  set (ptoh3 ${HEPMC3_INTERFACES_DIR}/pythia6/include/Pythia6/Pythia6ToHepMC3.cc)
  if (NOT HEPMC3_INTERFACES_DIR)
    message(STATUS "HepMC3 Examples: The used installation of HepMC3 does not have interfaces installed. Follow the documentation to install the interfaces.")
    message(STATUS "HepMC3 Examples: Pythia6Example will be disabled.")
  endif()
else()
  include_directories(${PROJECT_SOURCE_DIR}/interfaces/pythia6/include/Pythia6/)
  set (ptoh3 ${PROJECT_SOURCE_DIR}/interfaces/pythia6/include/Pythia6/Pythia6ToHepMC3.cc)
endif()
set_source_files_properties(${ptoh3} PROPERTIES SKIP_LINTING ON)
if ( (USE_INSTALLED_HEPMC3 AND HEPMC3_INTERFACES_DIR) OR (NOT  USE_INSTALLED_HEPMC3) )
  add_executable(pythia6_example.exe ${CMAKE_CURRENT_SOURCE_DIR}/main63.f ${CMAKE_CURRENT_SOURCE_DIR}/pythia-6.4.28.f ${ptoh3})
  target_link_libraries(pythia6_example.exe HepMC3::HepMC3)
  target_compile_definitions(pythia6_example.exe PRIVATE PYTHIA6HEPEVTSIZE=4000)
  set_target_properties(pythia6_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR})
  set_target_properties(pythia6_example.exe PROPERTIES LINKER_LANGUAGE Fortran)
  if (NOT "${CMAKE_Fortran_COMPILER_ID}" STREQUAL  "${CMAKE_CXX_COMPILER_ID}")
    set_target_properties(pythia6_example.exe PROPERTIES  INTERPROCEDURAL_OPTIMIZATION OFF)
  endif()
  if (USE_INSTALLED_HEPMC3)
    install(TARGETS pythia6_example.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
  endif()
endif()
