IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 7e45559d authored by Marvin Gottowik's avatar Marvin Gottowik
Browse files

Merge branch 'ln-auto-fetch-pythia-source' into 'master'

Ln auto fetch pythia source

See merge request !664
parents 1ce3a813 2a02e193
No related branches found
No related tags found
1 merge request!664Ln auto fetch pythia source
Pipeline #14421 passed
......@@ -10,11 +10,6 @@
cmake_minimum_required (VERSION 3.9)
#+++++++++++++++++++++++++++++
# for pre-defined standard path
#
include (GNUInstallDirs)
#+++++++++++++++++++++++++++++
# project name
# version is: "8.major.minor.patch"
......@@ -30,6 +25,11 @@ project (
LANGUAGES CXX
)
#+++++++++++++++++++++++++++++
# for pre-defined standard path
#
include (GNUInstallDirs)
#+++++++++++++++++++++++++++++
# prevent in-source builds and give warning message
#
......@@ -44,12 +44,17 @@ endif ()
# cmake version-specific settings
#
# https://cmake.org/cmake/help/latest/policy/CMP0079.html
if (${CMAKE_VERSION} VERSION_GREATER "3.13.0")
cmake_policy (SET CMP0079 NEW)
endif ()
if (POLICY CMP0079)
cmake_policy (SET CMP0079 NEW)
endif ()
# Download timestamp for external modules
if (POLICY CMP0135)
cmake_policy (SET CMP0135 OLD)
endif ()
# AUtomatically add extensions to filenames if needed (old behaviour)
if (POLICY CMP0115)
cmake_policy (SET CMP0115 OLD)
endif ()
#+++++++++++++++++++++++++++++
# warn user if system is not UNIX
......@@ -384,7 +389,7 @@ configure_file (
)
#
# second also for install-tree
#
#
set (CORSIKA_CMAKE_DATA_DIR "${CMAKE_INSTALL_FULL_DATADIR}/corsika/data")
configure_file (
src/corsika.hpp.in
......
......@@ -23,8 +23,8 @@ file (MAKE_DIRECTORY ${CORSIKA_Pythia8_MODULE_DIR})
add_library (C8::ext::pythia8 STATIC IMPORTED GLOBAL)
if ("x_${USE_Pythia8_C8}" STREQUAL "x_SYSTEM")
find_package (Pythia8 8310 EXACT REQUIRED)
find_package (Pythia8 8310 EXACT REQUIRED)
message (STATUS "Using system-level Pythia8 version ${Pythia8_VERSION} at ${Pythia8_PREFIX}")
set (Pythia8_INCLUDE_DIRS ${Pythia8_INCLUDE_DIR})
set_target_properties (
......@@ -40,24 +40,25 @@ if ("x_${USE_Pythia8_C8}" STREQUAL "x_SYSTEM")
configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY)
# install and build are both the same here since it is external
set (Pythia8_PREFIX_INSTALL ${Pythia8_PREFIX})
set (Pythia8_LIBDIR ${Pythia8_LIBRARY})
set (Pythia8_LIBDIR_INSTALL ${Pythia8_LIBRARY})
set (Pythia8_INCDIR ${Pythia8_INCLUDE_DIR})
set (Pythia8_INCDIR_INSTALL ${Pythia8_INCLUDE_DIR})
set (Pythia8_PREFIX_INSTALL ${Pythia8_PREFIX})
set (Pythia8_LIBDIR ${Pythia8_LIBRARY})
set (Pythia8_LIBDIR_INSTALL ${Pythia8_LIBRARY})
set (Pythia8_INCDIR ${Pythia8_INCLUDE_DIR})
set (Pythia8_INCDIR_INSTALL ${Pythia8_INCLUDE_DIR})
message (STATUS "Pythia8 (system) at ${Pythia8_PREFIX}")
else ()
set (_C8_Pythia8_Download_Dir "https://pythia.org/download/pythia83")
set (_C8_Pythia8_VERSION "8312")
message (STATUS "Building modules/pythia8 using pythia${_C8_Pythia8_VERSION}.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, no examples
# and also, it is fitted into the normal CORSIKA8 install "include/corsika_modules/Pythia8, lib/corsika"
ExternalProject_Add (pythia8
URL ${CMAKE_CURRENT_SOURCE_DIR}/pythia${_C8_Pythia8_VERSION}.tar.bz2
URL_MD5 7e85d7ff3f0886f8e834f51aff4bacf0
URL ${_C8_Pythia8_Download_Dir}/pythia${_C8_Pythia8_VERSION}.tar.bz2
URL_MD5 0acde09714b5383ac807edb10f161dd9
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pythia8/source"
INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/pythia8/install"
CONFIGURE_COMMAND ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/pythia8/install
......@@ -79,16 +80,16 @@ else ()
set (Pythia8_PREFIX ${INSTALL_DIR})
set (Pythia8_INCLUDE_DIR ${Pythia8_PREFIX}/include/corsika_modules)
set (Pythia8_LIBDIR ${Pythia8_PREFIX}/lib/corsika)
set (Pythia8_LIBDIR_INSTALL ${Pythia8_PREFIX_INSTALL}/lib/corsika)
set (Pythia8_LIBDIR_INSTALL ${Pythia8_PREFIX_INSTALL}/lib/corsika)
set (Pythia8_INCDIR ${Pythia8_PREFIX}/include/corsika_modules)
set (Pythia8_INCDIR_INSTALL ${Pythia8_PREFIX_INSTALL}/include/corsika_modules)
set (Pythia8_INCDIR_INSTALL ${Pythia8_PREFIX_INSTALL}/include/corsika_modules)
add_dependencies (C8::ext::pythia8 pythia8)
set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build location
configure_file (Pythia8ConfigurationDirectory.hpp.in ${CORSIKA_Pythia8_MODULE_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY)
set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX_INSTALL}) # install location
configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY)
install (DIRECTORY ${Pythia8_PREFIX}/ DESTINATION ${Pythia8_PREFIX_INSTALL})
set (Pythia8_INCLUDE_DIRS ${Pythia8_INCLUDE_DIR})
......@@ -103,7 +104,7 @@ else ()
TARGET C8::ext::pythia8
APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${Pythia8_INCLUDE_DIRS}>
$<INSTALL_INTERFACE:include/corsika/modules/pythia8/include>
$<INSTALL_INTERFACE:include/corsika/modules/pythia8/include>
)
message (STATUS "Pythia8 build at: ${Pythia8_PREFIX}, final install to: ${Pythia8_PREFIX_INSTALL}")
......
File deleted
#!/usr/bin/env python3
import os
import sys
import shutil
if (not os.path.exists('bin/pythia8-config') or
not os.path.exists('include/Pythia8/Pythia.h') or
not os.path.exists('src/Event.cc')) :
print ("You can only run this script from within an unpacked PYTHIA tar filedirectory. This was not detected!")
sys.exit(1)
# find version
version = 'undefined'
pythia_header = open('include/Pythia8/Pythia.h')
for line in pythia_header:
line_list = line.strip().split(' ')
if (len(line_list) == 3 and
line_list[0] == '#define' and
line_list[1] == 'PYTHIA_VERSION_INTEGER') :
version = line_list[2]
break
pythia_header.close()
if (version == 'undefined'):
print ("Could not find Pythia version info")
sys.exit(2)
print ("Pythia version: {}".format(version))
if (os.path.exists('c8_package')) :
print ('Temporary directory \"c8_package\" already exists. Cleanup first.')
sys.exit(3)
tmpdir = 'c8_package/pythia{}'.format(version)
print ('create \"{}\"'.format(tmpdir))
os.makedirs(tmpdir)
copy_files_s = "AUTHORS bin CODINGSTYLE configure COPYING GUIDELINES include Makefile Makefile.inc README share src"
copy_files = copy_files_s.split()
for filename in os.listdir('./') :
file = os.path.join('./', filename)
fileNew = os.path.join(tmpdir, filename)
if (filename in copy_files) :
isdir = ''
if (os.path.isdir(file)): isdir = ' [dir]'
print ('Keep \"{}\"{}'.format(file, isdir))
if (os.path.isfile(file)):
shutil.copy(file, tmpdir)
else:
shutil.copytree(file, fileNew)
print ('Remove \"include/Pythia8Plugins\"')
plugindir = os.path.join(tmpdir, 'include/Pythia8Plugins')
if (os.path.exists(plugindir)):
shutil.rmtree(plugindir)
# remove anything in share/Pythia but xmldoc that contains parameter definitions \"<parm\"
sharedir = os.path.join(tmpdir, 'share/Pythia8')
if (not os.path.isdir(sharedir)) :
print ('Why there is no \"share/Pythia8\" directory?')
else :
print ('Only keep \"xmldoc\" inside \"share/Phythia8\"')
for filename in os.listdir(sharedir) :
file = os.path.join(sharedir, filename)
if (os.path.isdir(file)) :
if (not 'xmldoc' in file) :
print ('Remove \"{}\"'.format(file))
shutil.rmtree(file)
else :
cleanupXMLDOC = False
if (cleanupXMLDOC) :
for filename_xml in os.listdir(file) :
xml = os.path.join(file, filename_xml)
xml_data = open(xml)
keep = False
for xml_line in xml_data:
if ('<parm ' in xml_line) :
keep = True
break
xml_data.close()
if (not keep):
print ('Removing {}'.format(xml))
os.unlink(xml)
# ... 'examples' subdirectory must exist ...
os.mkdir(os.path.join(tmpdir, 'examples'))
print ('Create tar file \"pythia{version}-stripped.tar.bz2\"'.format(version=version))
os.system('cd c8_package && tar cjf pythia{version}-stripped.tar.bz2 pythia{version} && mv pythia{version}-stripped.tar.bz2 ..'.format(version=version))
os.system('md5sum pythia{version}-stripped.tar.bz2'.format(version=version))
# cleanup
shutil.rmtree('c8_package')
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