IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 4f3975ed authored by ralfulrich's avatar ralfulrich Committed by Felix Riehn
Browse files

make pythia8 xmldoc search more robust

parent fcfbfdd0
No related branches found
No related tags found
1 merge request!311Resolve "testModules fails with segfault on release build with clang-8"
......@@ -14,7 +14,7 @@
#
function (_Pythia8_CONFIG_ option variable type doc)
execute_process(COMMAND ${Pythia8_CONFIG} ${option}
execute_process (COMMAND ${Pythia8_CONFIG} ${option}
OUTPUT_VARIABLE _local_out_
RESULT_VARIABLE _local_res_)
string (REGEX REPLACE "\n$" "" _local_out_ "${_local_out_}")
......@@ -25,6 +25,14 @@ function (_Pythia8_CONFIG_ option variable type doc)
endif ()
endfunction (_Pythia8_CONFIG_)
#################################################
#
# take directory and assume standard install layout
#
function (_Pythia8_LAYOUT_ dir variable type doc)
set (${variable} "${dir}" CACHE ${type} ${doc})
endfunction (_Pythia8_LAYOUT_)
#################################################
......@@ -52,21 +60,28 @@ set (_SEARCH_Pythia8_
/opt/pythia8
)
find_program (Pythia8_CONFIG
NAME pythia8-config
find_file (Pythia8_DIR
NAME Pythia.h
PATHS ${_SEARCH_Pythia8_}
PATH_SUFFIXES "/bin"
DOC "The location of the pythia8-config script")
PATH_SUFFIXES "/include/Pythia8"
DOC "The location of the Pythia8/Pythia.h script"
REQUIRED)
set (Pythia8_CONFIG ${Pythia8_DIR}/bin/pythia-config)
if (Pythia8_CONFIG)
set (HAVE_Pythia8 1 CACHE BOOL "presence of pythia8, found via pythia8-config")
_Pythia8_CONFIG_ ("--prefix" Pythia8_PREFIX PATH "location of pythia8 installation")
_Pythia8_CONFIG_ ("--includedir" Pythia8_INCLUDE_DIR PATH "pythia8 include directory")
_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")
# pythia-config is not relocatable
#_Pythia8_CONFIG_ ("--prefix" Pythia8_PREFIX PATH "location of pythia8 installation")
#_Pythia8_CONFIG_ ("--includedir" Pythia8_INCLUDE_DIR PATH "pythia8 include directory")
#_Pythia8_CONFIG_ ("--libdir" Pythia8_LIBRARY STRING "the pythia8 libs")
#_Pythia8_CONFIG_ ("--datadir" Pythia8_DATA_DIR PATH "the pythia8 data dir")
_Pythia8_LAYOUT_ ("${Pythia8_DIR}" Pythia8_PREFIX PATH "location of pythia8 installation")
_Pythia8_LAYOUT_ ("${Pythia8_DIR}/include" Pythia8_INCLUDE_DIR PATH "pythia8 include directory")
_Pythia8_LAYOUT_ ("${Pythia8_DIR}/lib" Pythia8_LIBRARY STRING "the pythia8 libs")
_Pythia8_LAYOUT_ ("${Pythia8_DIR}/share/Pythia8/xmldoc" Pythia8_DATA_DIR PATH "the pythia8 data dir")
# 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})
......@@ -78,4 +93,4 @@ endif ()
# standard cmake infrastructure:
include (FindPackageHandleStandardArgs)
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)
mark_as_advanced (Pythia8_DATA_DIR Pythia8_INCLUDE_DIR Pythia8_LIBRARY)
......@@ -9,7 +9,6 @@
#include <corsika/modules/pythia8/Pythia8.hpp>
#include <corsika/modules/pythia8/Decay.hpp>
#include <corsika/modules/pythia8/Random.hpp>
#include <corsika/modules/pythia8/ConfigurationDirectory.hpp>
#include <corsika/framework/utility/COMBoost.hpp>
......
......@@ -9,7 +9,6 @@
#pragma once
#include <corsika/modules/pythia8/Interaction.hpp>
#include <corsika/modules/pythia8/ConfigurationDirectory.hpp>
#include <corsika/framework/geometry/FourVector.hpp>
#include <corsika/framework/utility/COMBoost.hpp>
......
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <string>
/**
* \file Interaction.inl
**/
///! Helper macros to convert definitions into strings
#define CORSIKA_STRINGIFY(x) #x
#define CORSIKA_TOSTRING(x) CORSIKA_STRINGIFY(x)
/**
*
* Location of the pythia XML directory with crucial input and config data:
**/
static std::string const CORSIKA_Pythia8_XML_DIR =
std::string(CORSIKA_Pythia8_PREFIX) // from cmake
+ std::string("/share/Pythia8/xmldoc/");
......@@ -8,4 +8,8 @@
#pragma once
// the location of the "xmldoc" pythia directory (data files, config)
#include <Pythia8ConfigurationDirectory.hpp>
// the main pythia include
#include <Pythia8/Pythia.h>
......@@ -27,11 +27,14 @@ if ("x_${USE_PYTHIA8_C8}" STREQUAL "x_SYSTEM")
C8::ext::pythia8 PROPERTIES
IMPORTED_LOCATION ${Pythia8_LIBRARY}/libpythia8.a
IMPORTED_LINK_INTERFACE_LIBRARIES dl
INTERFACE_INCLUDE_DIRECTORIES ${Pythia8_INCLUDE_DIR}
INTERFACE_COMPILE_DEFINITIONS CORSIKA_Pythia8_PREFIX=\"${Pythia8_PREFIX}\"
INTERFACE_INCLUDE_DIRECTORIES ${Pythia8_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
)
set (Pythia8_FOUND 1 PARENT_SCOPE)
set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build and install location, pythia8 is external
configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY)
configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY)
message (STATUS "Pythia8 (system) at ${Pythia8_PREFIX}")
else ()
......@@ -39,20 +42,22 @@ else ()
set (_C8_Pythia8_VERSION "8245")
message (STATUS "Building modules/pythia8 using pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2")
message (STATUS "This will take a bit.....")
# this is not a full PYTHIA8 install, it is a bit simplified, e.g. no pythia8-config
ExternalProject_Add (pythia8
URL ${CMAKE_CURRENT_SOURCE_DIR}/pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2
URL_MD5 d3e951a2f101e8cfec26405cb61db83b
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/source
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install
LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/log
CONFIGURE_COMMAND ./configure --cxx-common=\\"${CMAKE_CXX_FLAGS} -O2 -fPIC\\" --prefix=${CMAKE_CURRENT_BINARY_DIR}/pythia8/install
CONFIGURE_COMMAND ./configure --cxx-common=\\"${CMAKE_CXX_FLAGS} -O2 -fPIC\\" --prefix=${CMAKE_CURRENT_BINARY_DIR}/pythia8/install
INSTALL_COMMAND make install COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/bin ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/share/Pythia8/examples
BUILD_IN_SOURCE ON
EXCLUDE_FROM_ALL TRUE
LOG_CONFIGURE TRUE
LOG_BUILD TRUE
LOG_INSTALL TRUE
LOG_MERGED_STDOUTERR TRUE
)
)
set (Pythia8_FOUND 1 PARENT_SCOPE)
ExternalProject_Get_Property (pythia8 INSTALL_DIR) # this is "make"
set (Pythia8_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/externals/pythia8) # this is "make install"
......@@ -63,6 +68,11 @@ else ()
add_dependencies (C8::ext::pythia8 pythia8)
set (Pythia8_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/externals/pythia8)
set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build location
configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY)
set (CORSIKA_Pythia8_LOCATION ${Pythia8_INSTALL_DIR}) # install location
configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY)
install (DIRECTORY ${INSTALL_DIR}/ DESTINATION ${Pythia8_INSTALL_DIR})
set_target_properties (
......@@ -70,13 +80,18 @@ else ()
PROPERTIES
IMPORTED_LOCATION ${Pythia8_LIBRARY}
IMPORTED_LINK_INTERFACE_LIBRARIES dl
INTERFACE_INCLUDE_DIRECTORIES ${Pythia8_INCLUDE_DIR}
INTERFACE_COMPILE_DEFINITIONS CORSIKA_Pythia8_PREFIX=\"${Pythia8_PREFIX}\"
INTERFACE_INCLUDE_DIRECTORIES "${Pythia8_INCLUDE_DIR};${CMAKE_CURRENT_BINARY_DIR}"
)
message (STATUS "Pythia8 build at ${INSTALL_DIR}, final install to ${Pythia8_INSTALL_DIR}")
endif ()
# the install location of Pythia8
install (
FILES ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp
RENAME Pythia8ConfigurationDirectory.hpp
DESTINATION include/modules/pythia8
)
##### add pythia8 to CORSIKA8 build
add_dependencies (CORSIKA8 C8::ext::pythia8)
......
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <string>
/**
* \file ConfigurationDirectory.hpp
*
* The location of Pythia XMLDOC configuration data files (particle
* data, decays, PDFs etc.) can be at different locations, depending
* on wether system version of pythia8, or the local CORSIKA8 version
* has been used. Also for the latter it is build in the
* ${PROJECT_BINARY_DIR}/modules/pythia/pythia8/install, while during
* installation (make install) it is copied to
* ${CMAKE_INSTALL_PREFIX}/share/external/pythia8. Thus, at config
* time different version of ConfigurationDirectory.hpp are created to
* always point to the right locations.
**/
namespace corsika::pythia8 {
/**
*
* Location of the pythia XML directory with crucial input and config data, from cmake:
**/
static std::string const CORSIKA_Pythia8_XML_DIR("@CORSIKA_Pythia8_LOCATION@/share/Pythia8/xmldoc/");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment