Warning, /geant4/cmake/Modules/FindPythia8.cmake is written in an unsupported language. File is not indexed.
0001 #[=======================================================================[.rst:
0002 FindPythia8
0003 ---------
0004
0005 Find the Pythia8 event generator headers and library.
0006
0007 Imported Targets
0008 ^^^^^^^^^^^^^^^^
0009
0010 This module defines the following :prop_tgt:`IMPORTED` targets:
0011
0012 ``Pythia8::Pythia8``
0013 The Pythia8 ``pythia8`` library, if found.
0014
0015 Result Variables
0016 ^^^^^^^^^^^^^^^^
0017
0018 This module will set the following variables in your project:
0019
0020 ``Pythia8_FOUND``
0021 true if the Pythia8 headers and libraries were found.
0022
0023 Hints
0024 ^^^^^
0025
0026 A user may set ``Pythia8_ROOT`` to a Pythia8 installation root to tell this
0027 module where to look.
0028
0029 #]=======================================================================]
0030
0031 # WE ONLY ALLOW USE OF THIS MODULE IN GEANT4 OR py8decayer EXAMPLE
0032 if(NOT PROJECT_NAME MATCHES "Geant4|py8decayer")
0033 message(FATAL_ERROR "This FindPythia8.cmake module is only supported for use in Geant4's py8decayer "
0034 "extended example. No support or extension of this module for use outside of this example "
0035 "will be provided.")
0036 endif()
0037
0038 # Look for the header file
0039 find_path(Pythia8_INCLUDE_DIR
0040 NAMES Pythia8/Pythia.h
0041 HINTS ${Pythia8_ROOT}/include)
0042
0043 if(NOT Pythia8_LIBRARY)
0044 find_library(Pythia8_LIBRARY
0045 NAMES pythia8 Pythia8
0046 HINTS ${Pythia8_ROOT}/lib ${Pythia8_ROOT}/lib64)
0047 endif()
0048
0049 # Determine the version
0050 if(Pythia8_INCLUDE_DIR AND EXISTS "${Pythia8_INCLUDE_DIR}/Pythia8/Pythia.h")
0051 file(STRINGS "${Pythia8_INCLUDE_DIR}/Pythia8/Pythia.h" PYTHIA8_H REGEX "^#define PYTHIA_VERSION.*$")
0052 if(PYTHIA8_H MATCHES "PYTHIA_VERSION ([0-9]\\.[0-9]+)$")
0053 set(Pythia8_VERSION "${CMAKE_MATCH_1}")
0054 else()
0055 set(Pythia8_VERSION "")
0056 endif()
0057 endif()
0058
0059 # handle the QUIETLY and REQUIRED arguments and set Pythia8_FOUND to TRUE if
0060 # all listed variables are TRUE
0061 include(FindPackageHandleStandardArgs)
0062 find_package_handle_standard_args(Pythia8
0063 REQUIRED_VARS Pythia8_INCLUDE_DIR Pythia8_LIBRARY
0064 VERSION_VAR Pythia8_VERSION)
0065
0066 mark_as_advanced(Pythia8_INCLUDE_DIR Pythia8_LIBRARY)
0067
0068 # Create imported target
0069 if(Pythia8_FOUND)
0070 if(NOT TARGET Pythia8::Pythia8)
0071 add_library(Pythia8::Pythia8 UNKNOWN IMPORTED)
0072 set_target_properties(Pythia8::Pythia8 PROPERTIES
0073 INTERFACE_INCLUDE_DIRECTORIES "${Pythia8_INCLUDE_DIR}"
0074 IMPORTED_LOCATION ${Pythia8_LIBRARY})
0075 endif()
0076 endif()