diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index dc36259c0..feb51315e 100644 --- a/cmake/cmake_uninstall.cmake.in +++ b/cmake/cmake_uninstall.cmake.in @@ -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}") diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index d0cd41b62..450284ef2 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -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 @@ -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)