Skip to content

Commit

Permalink
Merge pull request #532 from rest-for-physics/jgalan_lcg
Browse files Browse the repository at this point in the history
Adding LCG to thisREST.sh if LCG environment is identified
  • Loading branch information
jgalan authored Jul 20, 2024
2 parents 84a7760 + 9e8f8f7 commit a1cba19
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
execute_process(
"${CMAKE_COMMAND}" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
COMMAND ${CMAKE_COMMAND} -E rm -f $ENV{DESTDIR}${file}
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
RESULT_VARIABLE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
Expand Down
37 changes: 37 additions & 0 deletions cmake/thisREST.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Write thisREST.[c]sh to INSTALL directory

# Check if the LCG environment was loaded. Then it will be sourced in
# thisREST.sh
set(loadLCG "")
if (DEFINED ENV{LCG_VERSION})
# Retrieve the value of the environment variable
set(LCG_VERSION $ENV{LCG_VERSION})

# Print the value of the environment variable in CMake
message(STATUS "Found LCG environment! Version: ${LCG_VERSION}")

set(C_INCLUDE_PATH "$ENV{C_INCLUDE_PATH}")

string(FIND "${C_INCLUDE_PATH}" ":" COLON_POSITION)

if (COLON_POSITION GREATER_EQUAL 0)
# Extract the substring from the beginning up to the position of the
# first ':'
string(SUBSTRING "${C_INCLUDE_PATH}" 0 "${COLON_POSITION}" C_CLEAN)
else ()
# If ':' is not found, use the entire string
set(C_CLEAN "${C_INCLUDE_PATH}")
endif ()

string(REPLACE "include" "setup.sh" LCG_SETUP "${C_CLEAN}")

# Print the modified string
message(STATUS "Original path: ${C_CLEAN}")
message(STATUS "Modified path: ${LCG_SETUP}")

set(loadLCG
"\# We load the LCG_${LCG_VERSION} environment.\necho \\\"Loading\ LCG_${LCG_VERSION}\ environment\\\"\nsource ${LCG_SETUP}\n"
)

endif ()

# We identify the thisroot.sh script for the corresponding ROOT version
execute_process(
COMMAND root-config --prefix
Expand Down Expand Up @@ -97,6 +132,8 @@ file( WRITE \${CMAKE_INSTALL_PREFIX}/thisREST.sh
\"\#!/bin/bash
${loadLCG}
\# check active shell by checking for existence of _VERSION variable
if [[ -n \\\"\\\${BASH_VERSION}\\\" ]]; then
thisdir=\\\$(cd \\\$(dirname \\\${BASH_ARGV[0]}); pwd)
Expand Down

0 comments on commit a1cba19

Please sign in to comment.