From 7215f99610845ddc99623990512f3a2b29283e23 Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Sun, 3 Dec 2023 08:48:31 +0100 Subject: [PATCH] latest from ncrystaldev --- CMakeLists.txt | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0676709d..23b696c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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" ) @@ -232,6 +232,9 @@ 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 ) @@ -239,20 +242,23 @@ if ( NCRYSTAL_MODIFY_RPATH ) 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 @@ -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 /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 /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"