Skip to content

Commit ff5329d

Browse files
committed
Fix #563: use DYLD_LIB... in user env script
- On macOS use the correct variable name. - Fix extra / in cmake PATH - Only add CMake to PATH if the directory isn't on the PATH already
1 parent 6cef1f9 commit ff5329d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

prerequisites/install-functions/report_results.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ report_results()
4444
echo " " | tee -a setup.csh setup.sh
4545
if [[ -x "${cmake_install_path}/cmake" ]]; then
4646
echo "# Prepend the CMake path to the PATH environment variable:" | tee -a setup.sh setup.csh
47-
echo "if [[ -z \"\${PATH}\" ]]; then " >> setup.sh
48-
echo " export PATH=\"${cmake_install_path%/}/\" " >> setup.sh
47+
echo "if [[ -z \"\${PATH}\" ]]; then " >> setup.sh
48+
echo " export PATH=\"${cmake_install_path%/}\" " >> setup.sh
4949
echo "else " >> setup.sh
50-
echo " export PATH=\"${cmake_install_path%/}/\":\${PATH} " >> setup.sh
50+
echo " if ! [[ \"\${PATH}\" =~ \"${cmake_install_path}\" ]] ; then " >> setup.sh
51+
echo " export PATH=\"${cmake_install_path%/}\":\${PATH} " >> setup.sh
52+
echo " fi " >> setup.sh
5153
echo "fi " >> setup.sh
52-
echo "set path = (\"${cmake_install_path%/}\"/\"\$path\") " >> setup.csh
54+
echo "set path = (\"${cmake_install_path%/}\" \"\$path\") " >> setup.csh
5355
fi
5456
if [[ -x "${fully_qualified_FC}" ]]; then
5557
echo "# Prepend the compiler path to the PATH environment variable:" | tee -a setup.sh setup.csh
@@ -60,15 +62,19 @@ report_results()
6062
echo "fi " >> setup.sh
6163
echo "set path = (\"${compiler_install_root%/}\"/bin \"\$path\") " >> setup.csh
6264
fi
65+
LD_LIB_P_VAR=LD_LIBRARY_PATH
66+
if [[ "${OSTYPE:-}" =~ [Dd]arwin ]]; then
67+
LD_LIB_P_VAR=DYLD_LIBRARY_PATH
68+
fi
6369
if [[ -d "${compiler_install_root%/}/lib" || -d "${compiler_install_root%/}/lib64" ]]; then
64-
echo "# Prepend the compiler library paths to the LD_LIBRARY_PATH environment variable:" | tee -a setup.sh setup.csh
70+
echo "# Prepend the compiler library paths to the ${LD_LIB_P_VAR} environment variable:" | tee -a setup.sh setup.csh
6571
compiler_lib_paths="${compiler_install_root%/}/lib64/:${compiler_install_root%/}/lib"
66-
echo "if [[ -z \"\${LD_LIBRARY_PATH}\" ]]; then " >> setup.sh
67-
echo " export LD_LIBRARY_PATH=\"${compiler_lib_paths%/}\" " >> setup.sh
72+
echo "if [[ -z \"\${!LD_LIB_P_VAR}\" ]]; then " >> setup.sh
73+
echo " export ${LD_LIB_P_VAR}=\"${compiler_lib_paths%/}\" " >> setup.sh
6874
echo "else " >> setup.sh
69-
echo " export LD_LIBRARY_PATH=\"${compiler_lib_paths%/}:\${LD_LIBRARY_PATH}\" " >> setup.sh
75+
echo " export ${LD_LIB_P_VAR}=\"${compiler_lib_paths%/}:\${!LD_LIB_P_VAR}\" " >> setup.sh
7076
echo "fi " >> setup.sh
71-
echo "set LD_LIBRARY_PATH = (\"${compiler_lib_paths%/}\"/bin \"\$LD_LIBRARY_PATH\") " >> setup.csh
77+
echo "set LD_LIBRARY_PATH = (\"${compiler_lib_paths%/}\" \"\${LD_LIBRARY_PATH}\") " >> setup.csh
7278
fi
7379
echo " " >> setup.sh
7480
if [[ -x "${mpi_install_root}/bin/mpifort" ]]; then

0 commit comments

Comments
 (0)