diff --git a/cmake/FindPythia8.cmake b/cmake/FindPythia8.cmake index 88535cede70317aa9c2c6a53f5e84e08f1924a34..62106fad47a94e1f7d877bb8ec4b82030f25cacb 100644 --- a/cmake/FindPythia8.cmake +++ b/cmake/FindPythia8.cmake @@ -66,9 +66,16 @@ if (Pythia8_CONFIG) _Pythia8_CONFIG_ ("--libdir" Pythia8_LIBRARY STRING "the pythia8 libs") _Pythia8_CONFIG_ ("--datadir" Pythia8_DATA_DIR PATH "the pythia8 data dir") _Pythia8_CONFIG_ ("--cxxflags" Pythia8_CXXFLAGS STRING "the pythia8 cxxflags") + + # read the config string + file (READ "${Pythia8_INCLUDE_DIR}/Pythia8/Pythia.h" Pythia8_TMP_PYTHIA_H) + string (REGEX MATCH "#define PYTHIA_VERSION_INTEGER ([0-9]*)" _ ${Pythia8_TMP_PYTHIA_H}) + set (Pythia8_VERSION ${CMAKE_MATCH_1}) + message (STATUS "Found Pythia8 version: ${Pythia8_VERSION}") + endif () # standard cmake infrastructure: include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (Pythia8 DEFAULT_MSG Pythia8_PREFIX Pythia8_INCLUDE_DIR Pythia8_LIBRARY) +find_package_handle_standard_args (Pythia8 REQUIRED_VARS Pythia8_PREFIX Pythia8_INCLUDE_DIR Pythia8_LIBRARY VERSION_VAR Pythia8_VERSION) mark_as_advanced (Pythia8_DATA_DIR Pythia8_CXXFLAGS Pythia8_INCLUDE_DIR Pythia8_LIBRARY)