Skip to content

Commit

Permalink
latest from ncrystaldev
Browse files Browse the repository at this point in the history
  • Loading branch information
tkittel committed Dec 3, 2023
1 parent 72322a6 commit 7215f99
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ if ( DEFINED NCRYSTAL_SETUPPY_MODE )
_ncrystal_option_force( NCRYSTAL_ENABLE_EXAMPLES "OFF" )
_ncrystal_option_force( NCRYSTAL_ENABLE_DYNLOAD "ON" )
_ncrystal_option_force( NCRYSTAL_NOTOUCH_CMAKE_BUILD_TYPE "ON" )
_ncrystal_option_force( NCRYSTAL_MODIFY_RPATH "OFF" )#FIXME JUST TESTING "ON" here
_ncrystal_option_force( NCRYSTAL_MODIFY_RPATH "OFF" )
_ncrystal_option_force( NCRYSTAL_ENABLE_SETUPSH "OFF" )
_ncrystal_option_force( NCRYSTAL_ENABLE_DATA "EMBED" )#otherwise the c++ library can not locate the files
_ncrystal_option_force( NCRYSTAL_ENABLE_GEANT4 "OFF" )#plan is to move out of ncrystal repo
Expand All @@ -128,8 +128,8 @@ if ( DEFINED NCRYSTAL_SETUPPY_MODE )
_ncrystal_option_force( CMAKE_INSTALL_INCLUDEDIR "NCrystal/ncrystal_pyinst_data/include" )
_ncrystal_option_force( CMAKE_INSTALL_DATADIR "NCrystal/ncrystal_pyinst_data/data" )
_ncrystal_option_force( NCrystal_DATAFILESDIR "NCrystal/ncrystal_pyinst_data/stdlib_data" )
#FIXME: Postpone until e.g. mcstas comps stop hardcoding "-lNCrystal":
_ncrystal_option_force( NCRYSTAL_NAMESPACE "pip${PROJECT_VERSION_MAJOR}d${PROJECT_VERSION_MINOR}d${PROJECT_VERSION_PATCH}" )
- #TODO: Postpone adding the following namespace until e.g. mcstas comps stop hardcoding "-lNCrystal":
#_ncrystal_option_force( NCRYSTAL_NAMESPACE "pip${PROJECT_VERSION_MAJOR}d${PROJECT_VERSION_MINOR}d${PROJECT_VERSION_PATCH}" )
endif()
else()
set( NCRYSTAL_SETUPPY_MODE "OFF" )
Expand Down Expand Up @@ -232,27 +232,33 @@ set( libncg4props "" )#empty list
if ( NCRYSTAL_MODIFY_RPATH )
#Set RPATH properties. For some annoying reason, this is not possible to do
#via interface targets, so we have to use a variable-based workaround:
set( tmp_rpath "" )#empty list
set( tmp_rpath_libncg4 "" )#empty list

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 )
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/${NCrystal_relpath_BINDIR2LIBDIR}" )
list( APPEND libncg4props INSTALL_RPATH $ORIGIN )
list( APPEND tmp_rpath "$ORIGIN/${NCrystal_relpath_BINDIR2LIBDIR}" )
list( APPEND tmp_rpath_libncg4 $ORIGIN )
else()
#On OSX, rpaths are absolute paths (todo: revisit if this is still the case)
get_filename_component( tmp "${CMAKE_INSTALL_PREFIX}/${NCrystal_LIBDIR}" ABSOLUTE)
list( APPEND binaryprops INSTALL_RPATH "${tmp}" )
list( APPEND libncg4brops INSTALL_RPATH "${tmp}" )
list( APPEND tmp_rpath "${tmp}" )
list( APPEND tmp_rpath_libncg4 "${tmp}" )
endif()

if ( DEFINED ENV{CONDA_PREFIX} AND EXISTS "$ENV{CONDA_PREFIX}/lib" )
#In a conda environment we add $CONDA_PREFIX/lib to the rpath:
list( APPEND tmp_rpath "$ENV{CONDA_PREFIX}/lib" )
list( APPEND tmp_rpath_libncg4 "$ENV{CONDA_PREFIX}/lib" )
endif()

#TMP# if ( DEFINED ENV{CONDA_PREFIX} AND EXISTS "$ENV{CONDA_PREFIX}/lib" )
#TMP# #In a conda environment we add $CONDA_PREFIX/lib to the rpath:
#TMP# list( APPEND binaryprops INSTALL_RPATH "$ENV{CONDA_PREFIX}/lib" )
#TMP# list( APPEND libncg4brops INSTALL_RPATH "$ENV{CONDA_PREFIX}/lib" )
#TMP# endif()
list( APPEND binaryprops INSTALL_RPATH "${tmp_rpath}" )
list( APPEND libncg4brops INSTALL_RPATH "${tmp_rpath_libncg4}" )

#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 @@ -732,10 +738,10 @@ if (NCRYSTAL_ENABLE_PYTHON)
ncinstall( FILES "${PROJECT_BINARY_DIR}/_nclibpath.py" DESTINATION ${NCrystal_PYMODDIR})
else()
if ( NCRYSTAL_SETUPPY_MODE )
#Python files will be grapped from <src>/NCrystal by setup.py itself, so
#we do nothing. However, _chooks.py still needs the information about
#libname and namespace in _nclibpath.py:
message( STATUS "Creating _nclibpath.py needed for setup.py installation.")
#Static python files will be grapped from <src>/NCrystal by setup.py
#itself, so we do nothing. However, _chooks.py also needs the information
#about libname and namespace in _nclibpath.py:
message( STATUS "Adding _nclibpath.py needed for setup.py installation.")
file(WRITE "${PROJECT_BINARY_DIR}/_nclibpath.py.in"
"#File autogenerated by NCrystal's CMakeLists.txt:\n"
"import pathlib\n"
Expand Down

0 comments on commit 7215f99

Please sign in to comment.