Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CMake

on:
push:
branches: [ develop, master ]
#branches: [ develop, master ]
pull_request:
branches: [ develop, master ]

Expand Down Expand Up @@ -73,6 +73,10 @@ jobs:
${{github.workspace}}/install/bin/pymcpltool --help
${{github.workspace}}/install/bin/ssw2mcpl --help
${{github.workspace}}/install/bin/mcpl2ssw --help
${{github.workspace}}/install/bin/ptrac2mcpl --help
${{github.workspace}}/install/bin/phits2mcpl --help
${{github.workspace}}/install/bin/mcpl2phits --help
${{github.workspace}}/install/bin/stock2mcpl --help
${{github.workspace}}/install/bin/ssv2mcpl --help
${{github.workspace}}/install/bin/mcpl2ssv --help

81 changes: 73 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

##################################################################################
# #
# CMake file which can be used to compile and link all code in the MCPL #
Expand Down Expand Up @@ -59,14 +60,17 @@ if(NOT DEFINED MCPL_NOTOUCH_CMAKE_BUILD_TYPE)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
#This can happen if parent project called the project(..) function before
#doing the song and dance we did above.
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Release)
endif()
endif()

option( BUILD_EXAMPLES "Whether to build examples." OFF )
option( BUILD_WITHZLIB "Whether to link with zlib if available." ON )
option( BUILD_WITHSSW "Whether to build the MCPL-SSW converters (for MCNP)." ON )
option( BUILD_WITHPTRAC "Whether to build the MCPL-PTRAC converters (for MCNP)." ON )
option( BUILD_WITHPHITS "Whether to build the MCPL-PHITS converters." ON )
option( BUILD_WITHT4 "Whether to build the TRIPOLI-4 converters." ON )
option( BUILD_WITHSSV "Whether to build the ASCII-SSV converters." ON )
option( BUILD_WITHG4 "Whether to build Geant4 plugins." OFF )
option( BUILD_FAT "Whether to also build the fat binaries." OFF )
option( INSTALL_PY "Whether to also install mcpl python files." ON )
Expand Down Expand Up @@ -117,17 +121,17 @@ if ( MODIFY_RPATH )
#via interface targets, so we have to use a variable-based workaround:
if ( NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH )
#TODO: Figure out if we really need this (perhaps only for geant4 targets?)
set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
if( NOT APPLE )
#Relocatable RPATHS: $ORIGIN in RPATH (including the $-char!!) means the
#location of the binary requiring the dependency:
list( APPEND binaryprops INSTALL_RPATH "$ORIGIN/${MCPL_relpath_BINDIR2LIBDIR}" )
else()
else ()
#On OSX, rpaths are absolute paths (todo: revisit if this is still the case)
get_filename_component( tmp "${CMAKE_INSTALL_PREFIX}/${MCPL_LIBDIR}" ABSOLUTE)
list( APPEND binaryprops INSTALL_RPATH "${tmp}" )
endif()
endif ()

#Test if compiler supports -Wl,--disable-new-dtags. If it does, apply it
#(otherwise RPATH sections in binaries become RUNPATH instead, which can be
Expand Down Expand Up @@ -159,17 +163,17 @@ file(WRITE ${TMP_TESTDIR}/test.c "${TMP_TESTLIBMSRC}")
try_compile(ALWAYS_HAS_MATH "${TMP_TESTDIR}" "${TMP_TESTDIR}/test.c")
if (ALWAYS_HAS_MATH)
set( MATH_NEEDS_LIBM OFF )
else()
else ()
set( MATH_NEEDS_LIBM ON )
set( TMP_TESTDIR ${PROJECT_BINARY_DIR}/test_libm2 )
file( WRITE ${TMP_TESTDIR}/test.c "${TMP_TESTLIBMSRC}" )
try_compile( tmp "${TMP_TESTDIR}" "${TMP_TESTDIR}/test.c" LINK_LIBRARIES m )
if( NOT tmp )
message(FATAL_ERROR "Could not figure out link flags needed to enable math functions")
endif()
endif()
endif ()

add_library( mcpl SHARED "${SRC}/mcpl/mcpl.c" )
add_library(mcpl SHARED "${SRC}/mcpl/mcpl.c")
set(MCPL_LIBNAME "${CMAKE_SHARED_LIBRARY_PREFIX}mcpl${CMAKE_SHARED_LIBRARY_SUFFIX}")
target_link_libraries( mcpl PRIVATE common )

Expand Down Expand Up @@ -222,6 +226,25 @@ if (BUILD_WITHSSW)
install(TARGETS mcpl2ssw ssw2mcpl sswmcpl ${INSTDEST})
endif()

if (BUILD_WITHPTRAC)
add_library(ptracmcpl SHARED "${SRC}/mcnpptrac/ptracmcpl.c" "${SRC}/mcnpptrac/ptracread.c")
target_include_directories(ptracmcpl PUBLIC "${SRC}/mcnpptrac")
target_link_libraries(ptracmcpl mcpl common)
if (MATH_NEEDS_LIBM)
target_link_libraries(ptracmcpl m)
endif()
add_executable(ptrac2mcpl "${SRC}/mcnpptrac/ptrac2mcpl_app.c")
target_link_libraries(ptrac2mcpl ptracmcpl)
if (binaryprops)
set_target_properties(ptracmcpl PROPERTIES ${binaryprops})
set_target_properties(ptrac2mcpl PROPERTIES ${binaryprops})
endif()
install(TARGETS ptrac2mcpl ptracmcpl ${INSTDEST})
if (BUILD_EXAMPLES)
install(FILES "${SRCEX}/example_mcnpptrac.ptrac" DESTINATION examples)
endif()
endif()

if (BUILD_WITHPHITS)
add_library(phitsmcpl SHARED "${SRC}/phits/phitsmcpl.c" "${SRC}/phits/phitsread.c")
target_include_directories(phitsmcpl PUBLIC "${SRC}/phits")
Expand All @@ -238,6 +261,47 @@ if (BUILD_WITHPHITS)
endif()
endif()

if (BUILD_WITHT4)
add_library(stockmcpl SHARED "${SRC}/tripolistock/stockmcpl.c" "${SRC}/tripolistock/stockread.c")
target_include_directories(stockmcpl PUBLIC "${SRC}/tripolistock")
target_link_libraries(stockmcpl mcpl common)
if (MATH_NEEDS_LIBM)
target_link_libraries(stockmcpl m)
endif()
add_executable(stock2mcpl "${SRC}/tripolistock/stock2mcpl_app.c")
target_link_libraries(stock2mcpl stockmcpl)
if (binaryprops)
set_target_properties(stockmcpl PROPERTIES ${binaryprops})
set_target_properties(stock2mcpl PROPERTIES ${binaryprops})
endif()
install(TARGETS stock2mcpl stockmcpl ${INSTDEST})
if (BUILD_EXAMPLES)
install(FILES "${SRCEX}/example_tripolistock.stock" DESTINATION examples)
endif()
endif()

if (BUILD_WITHSSV)
add_library(ssvmcpl SHARED "${SRC}/ssv/ssvmcpl.c" "${SRC}/ssv/ssvread.c")
target_include_directories(ssvmcpl PUBLIC "${SRC}/ssv")
target_link_libraries(ssvmcpl mcpl common)
if (MATH_NEEDS_LIBM)
target_link_libraries(ssvmcpl m)
endif()
add_executable(ssv2mcpl "${SRC}/ssv/ssv2mcpl_app.c")
target_link_libraries(ssv2mcpl ssvmcpl)
add_executable(mcpl2ssv "${SRC}/ssv/mcpl2ssv_app.c")
target_link_libraries(mcpl2ssv ssvmcpl)
if (binaryprops)
set_target_properties(ssvmcpl PROPERTIES ${binaryprops})
set_target_properties(ssv2mcpl PROPERTIES ${binaryprops})
set_target_properties(mcpl2ssv PROPERTIES ${binaryprops})
endif()
install(TARGETS ssv2mcpl mcpl2ssv ssvmcpl ${INSTDEST})
if (BUILD_EXAMPLES)
install(FILES "${SRCEX}/example_ascii.ssv" "${SRCEX}/example_writessv.ipynb" DESTINATION examples)
endif()
endif()

if (INSTALL_PY)
install(FILES "${SRC}/python/mcpl.py" DESTINATION ${MCPL_PYPATH})
install(PROGRAMS "${SRC}/python/pymcpltool" DESTINATION ${MCPL_BINDIR})
Expand Down Expand Up @@ -284,6 +348,7 @@ if (BUILD_FAT)
endif()
if (BUILD_WITHPHITS)
add_executable(phits2mcpl_fat "${SRCFAT}/phits2mcpl_app_fat.c")
target_link_libraries(phits2mcpl_fat m)
add_executable(mcpl2phits_fat "${SRCFAT}/mcpl2phits_app_fat.c")
if (MATH_NEEDS_LIBM)
target_link_libraries( phits2mcpl_fat m common )
Expand Down Expand Up @@ -323,7 +388,7 @@ endif()
if (BUILD_WITHG4)
find_package(Geant4)
if(NOT Geant4_FOUND)
message(FATAL_ERROR "BUILD_WITHG4 set to ON but failed to enable Geant4 support.")
message("BUILD_WITHG4 set to ON but failed to enable Geant4 support.")
endif()
else()
set(Geant4_FOUND NO)
Expand Down
12 changes: 12 additions & 0 deletions FILES
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@ src/mcnpssw/ : MCPL hooks for MCNP in C, in the form of a few .h/.c file
pairs and two command line applications which can be used
to convert between the MCPL format and the SSW files used
by MCNP.
src/mcnpptrac/ : MCPL hooks for MCNP in C, in the form of a few .h/.c file
pairs and two command line applications which can be used
to convert between the MCPL format and the PTRAC files used
by MCNP.
src/phits/ : MCPL hooks for PHITS in C, in the form of a few .h/.c file
pairs and two command line applications which can be used
to convert between the MCPL format and the binary dump
files used by PHITS.
src/tripolistock/ : MCPL hooks for TRIPOLI-4 in C, in the form of a few .h/.c
file pairs and two command line applications which can be
used to convert between the MCPL format and the .stock
files used by TRIPOLI-4 (STORAGE).
src/ssv/ : MCPL hooks for ASCII-SSV in C, in the form of a few .h/.c
file pairs and two command line applications which can be
used to convert between the MCPL format and an ASCII
Space Separated Values format.
src/mcstas/ : No actual code is here, just a small reminder of how the
MCPL plugin shipped with McStas can be used.
src/mcxtrace/ : No actual code is here, just a small reminder of how the
Expand Down
2 changes: 2 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ is a quick recipe (using an in-source build for simplicity):
* -DBUILD_FAT=ON [whether to build "fat" binaries, default is OFF]
* -DBUILD_WITHG4=OFF [whether to build G4 hooks, default is ON]
* -DBUILD_WITHSSW=OFF [whether to build SSW hooks, default is ON]
* -DBUILD_WITHPTRAC=OFF [whether to build PTRAC hooks, default is ON]
* -DBUILD_WITHPHITS=OFF [whether to build PHITS hooks, default is ON]
* -DBUILD_WITHSTOCK=OFF [whether to build STOCK hooks, default is ON]
* -DINSTALL_PY=OFF [whether to install python files, default is ON]
* -DMODIFY_RPATH=OFF [do not do any special rpath treatment for binaries]

Expand Down
12 changes: 6 additions & 6 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ utilities include both command line tools and programming interfaces for C/C++
and python.

MCPL I/O hooks for Geant4 (geant4.cern.ch) and MCNP (SSW files) are included in
this distribution as well. Hooks for McStas (mcstas.org) and McXtrace
(mcxtrace.org) are already included directly upstream in those applications. A
few examples of how to use the Geant4 hooks, or how to interact with MCPL files
from standalone C code, are also provided. Refer to the FILES file for more
information about included files, and refer to the INSTALL file for build
instructions.
this distribution. Basic hooks for TRIPOLI-4 (STORAGE) and MCNP (PTRAC) are
included as well. Hooks for McStas (mcstas.org) and McXtrace (mcxtrace.org) are
already included directly upstream in those applications. Afew examples of how
to use the Geant4 hooks, or how to interact with MCPL filesfrom standalone C
code, are also provided. Refer to the FILES file for moreinformation about
included files, and refer to the INSTALL file for build instructions.

MCPL and most code distributed here was written 2015-2019 by Thomas Kittelmann
([email protected]). The MCNP-SSW converters were written in close
Expand Down
Loading