From 66a6a08bd4a745ee9e81261717fc744fb18e8565 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sat, 13 Jul 2024 20:52:14 +0200 Subject: [PATCH 01/13] Adding REST_LCG so that cvmfs/lcg will be loaded into thisREST.sh --- cmake/thisREST.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index d0cd41b62..fa23c3cf6 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -27,6 +27,12 @@ if (${REST_G4} MATCHES "ON") ) endif () +set(loadLCG "") +if( ${REST_LCG} MATCHES "ON" ) + set(loadG4 + "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n") +endif() + set(loadMPFR "") if (DEFINED MPFR_PATH) set(loadMPFR "export LD_LIBRARY_PATH=${MPFR_PATH}/lib:\$LD_LIBRARY_PATH") @@ -112,6 +118,7 @@ if [[ -f \\\"${thisROOT}\\\" ]]; then source ${thisROOT} fi +${loadLCG} ${loadG4} ${loadMPFR} ${loadCRY} From 51f5a221a0181f0412fde1ddf3630718c398acf3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 18:53:44 +0000 Subject: [PATCH 02/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cmake/thisREST.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index fa23c3cf6..73c073931 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -28,10 +28,11 @@ if (${REST_G4} MATCHES "ON") endif () set(loadLCG "") -if( ${REST_LCG} MATCHES "ON" ) +if (${REST_LCG} MATCHES "ON") set(loadG4 - "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n") -endif() + "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n" + ) +endif () set(loadMPFR "") if (DEFINED MPFR_PATH) From 5d579f32ad61b8f76a3423b1e8812f830913a71a Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sun, 14 Jul 2024 10:00:35 +0200 Subject: [PATCH 03/13] cmake/thisREST.cmake now we source LCG before any other command --- cmake/thisREST.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index fa23c3cf6..a51c4257d 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -103,6 +103,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) @@ -118,7 +120,6 @@ if [[ -f \\\"${thisROOT}\\\" ]]; then source ${thisROOT} fi -${loadLCG} ${loadG4} ${loadMPFR} ${loadCRY} From 5700bf6b3d8f2c53a459676370a9dd9a69e2ffb9 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sun, 14 Jul 2024 10:15:34 +0200 Subject: [PATCH 04/13] thisREST.cmake identifying if we are using CVMFS LCG setup --- cmake/thisREST.cmake | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index a51c4257d..3613b0e1d 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -1,5 +1,17 @@ # Write thisREST.[c]sh to INSTALL directory +##### Checking if we are using CVMFS LCG GCC11 environment +set(lcg_found FALSE) + +# Check if the CMAKE_COMMAND contains both "cvmfs", "lcg" and "x86_64-el9-gcc11" +string(FIND "${CMAKE_COMMAND}" "cvmfs" cvmfs_pos) +string(FIND "${CMAKE_COMMAND}" "lcg" lcg_pos) +string(FIND "${CMAKE_COMMAND}" "x86_64-el9-gcc11" gcc_pos) + +if (lcg_pos GREATER -1 AND cvmfs_pos GREATER -1 AND gcc_pos GREATER -1) + set(lcg_found TRUE) +endif() + # We identify the thisroot.sh script for the corresponding ROOT version execute_process( COMMAND root-config --prefix @@ -28,8 +40,8 @@ if (${REST_G4} MATCHES "ON") endif () set(loadLCG "") -if( ${REST_LCG} MATCHES "ON" ) - set(loadG4 +if( lcg_found ) + set(loadLCG "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n") endif() From 3689712abd329d3161e125fe15551871e687b29c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 14 Jul 2024 08:17:09 +0000 Subject: [PATCH 05/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cmake/thisREST.cmake | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index 3613b0e1d..9b0300ca5 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -1,6 +1,6 @@ # Write thisREST.[c]sh to INSTALL directory -##### Checking if we are using CVMFS LCG GCC11 environment +# Checking if we are using CVMFS LCG GCC11 environment set(lcg_found FALSE) # Check if the CMAKE_COMMAND contains both "cvmfs", "lcg" and "x86_64-el9-gcc11" @@ -8,9 +8,11 @@ string(FIND "${CMAKE_COMMAND}" "cvmfs" cvmfs_pos) string(FIND "${CMAKE_COMMAND}" "lcg" lcg_pos) string(FIND "${CMAKE_COMMAND}" "x86_64-el9-gcc11" gcc_pos) -if (lcg_pos GREATER -1 AND cvmfs_pos GREATER -1 AND gcc_pos GREATER -1) +if (lcg_pos GREATER -1 + AND cvmfs_pos GREATER -1 + AND gcc_pos GREATER -1) set(lcg_found TRUE) -endif() +endif () # We identify the thisroot.sh script for the corresponding ROOT version execute_process( @@ -40,10 +42,11 @@ if (${REST_G4} MATCHES "ON") endif () set(loadLCG "") -if( lcg_found ) - set(loadLCG - "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n") -endif() +if (lcg_found) + set(loadLCG + "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n" + ) +endif () set(loadMPFR "") if (DEFINED MPFR_PATH) From 7959c0b266422d30cd398e321347df4c152b24c1 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sun, 14 Jul 2024 10:18:52 +0200 Subject: [PATCH 06/13] Making it more specific to LGC_104 --- cmake/thisREST.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index 3613b0e1d..35955d082 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -5,7 +5,7 @@ set(lcg_found FALSE) # Check if the CMAKE_COMMAND contains both "cvmfs", "lcg" and "x86_64-el9-gcc11" string(FIND "${CMAKE_COMMAND}" "cvmfs" cvmfs_pos) -string(FIND "${CMAKE_COMMAND}" "lcg" lcg_pos) +string(FIND "${CMAKE_COMMAND}" "LCG_104" lcg_pos) string(FIND "${CMAKE_COMMAND}" "x86_64-el9-gcc11" gcc_pos) if (lcg_pos GREATER -1 AND cvmfs_pos GREATER -1 AND gcc_pos GREATER -1) From f261932e6f0ea87dd68fbc9c403130d34489495d Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sun, 14 Jul 2024 10:21:33 +0200 Subject: [PATCH 07/13] Ordering --- cmake/thisREST.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index 9e2ddc188..86b225c4c 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -14,6 +14,13 @@ if (lcg_pos GREATER -1 set(lcg_found TRUE) endif () +set(loadLCG "") +if (lcg_found) + set(loadLCG + "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n" + ) +endif () + # We identify the thisroot.sh script for the corresponding ROOT version execute_process( COMMAND root-config --prefix @@ -41,13 +48,6 @@ if (${REST_G4} MATCHES "ON") ) endif () -set(loadLCG "") -if (lcg_found) - set(loadLCG - "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n" - ) -endif () - set(loadMPFR "") if (DEFINED MPFR_PATH) set(loadMPFR "export LD_LIBRARY_PATH=${MPFR_PATH}/lib:\$LD_LIBRARY_PATH") From 695ce0abcc1f4f6b6646111778fcdfbae205bbdf Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sun, 14 Jul 2024 10:28:07 +0200 Subject: [PATCH 08/13] thisREST.cmake. Fixing issue --- cmake/thisREST.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index 86b225c4c..36afd9a83 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -5,7 +5,7 @@ set(lcg_found FALSE) # Check if the CMAKE_COMMAND contains both "cvmfs", "lcg" and "x86_64-el9-gcc11" string(FIND "${CMAKE_COMMAND}" "cvmfs" cvmfs_pos) -string(FIND "${CMAKE_COMMAND}" "LCG_104" lcg_pos) +string(FIND "${CMAKE_COMMAND}" "lcg" lcg_pos) string(FIND "${CMAKE_COMMAND}" "x86_64-el9-gcc11" gcc_pos) if (lcg_pos GREATER -1 @@ -17,7 +17,7 @@ endif () set(loadLCG "") if (lcg_found) set(loadLCG - "\# REST_LCG was enabled. We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n" + "\# We load LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n" ) endif () From cfeffab7e043024eba6db4349666928d18d558fb Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 16 Jul 2024 21:06:46 +0200 Subject: [PATCH 09/13] Improving LCG generation --- cmake/thisREST.cmake | 46 ++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index 36afd9a83..d56ec3d3b 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -1,25 +1,37 @@ # Write thisREST.[c]sh to INSTALL directory -# Checking if we are using CVMFS LCG GCC11 environment -set(lcg_found FALSE) - -# Check if the CMAKE_COMMAND contains both "cvmfs", "lcg" and "x86_64-el9-gcc11" -string(FIND "${CMAKE_COMMAND}" "cvmfs" cvmfs_pos) -string(FIND "${CMAKE_COMMAND}" "lcg" lcg_pos) -string(FIND "${CMAKE_COMMAND}" "x86_64-el9-gcc11" gcc_pos) - -if (lcg_pos GREATER -1 - AND cvmfs_pos GREATER -1 - AND gcc_pos GREATER -1) - set(lcg_found TRUE) -endif () - +# Check if the LCG environment was loaded. Then it will be sourced in thisREST.sh set(loadLCG "") -if (lcg_found) +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 LCG_104 environment.\nsource /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc11-opt/setup.sh\n\n" + "\# We load the LCG_${LCG_VERSION} environment.\necho \"Loading\ LCG_${LCG_VERSION}\ environment\"\nsource ${LCG_SETUP}\n" ) -endif () + +endif() # We identify the thisroot.sh script for the corresponding ROOT version execute_process( From f6c061cd1c8b83708fe0a4c819220433a2e745f0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:07:38 +0000 Subject: [PATCH 10/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cmake/thisREST.cmake | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index d56ec3d3b..c81446aeb 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -1,37 +1,39 @@ # Write thisREST.[c]sh to INSTALL directory -# Check if the LCG environment was loaded. Then it will be sourced in thisREST.sh +# Check if the LCG environment was loaded. Then it will be sourced in +# thisREST.sh set(loadLCG "") -if(DEFINED ENV{LCG_VERSION}) +if (DEFINED ENV{LCG_VERSION}) # Retrieve the value of the environment variable - set(LCG_VERSION $ENV{LCG_VERSION}) + set(LCG_VERSION $ENV{LCG_VERSION}) # Print the value of the environment variable in CMake - message(STATUS "Found LCG environment! Version: ${LCG_VERSION}") + message(STATUS "Found LCG environment! Version: ${LCG_VERSION}") - set(C_INCLUDE_PATH "$ENV{C_INCLUDE_PATH}") + set(C_INCLUDE_PATH "$ENV{C_INCLUDE_PATH}") - string(FIND "${C_INCLUDE_PATH}" ":" COLON_POSITION) + 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() + 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}") + 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}") + # 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" + "\# We load the LCG_${LCG_VERSION} environment.\necho \"Loading\ LCG_${LCG_VERSION}\ environment\"\nsource ${LCG_SETUP}\n" ) -endif() +endif () # We identify the thisroot.sh script for the corresponding ROOT version execute_process( From f9627ebecc31921cd74869d97ea32eaf6a61027e Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 16 Jul 2024 21:37:20 +0200 Subject: [PATCH 11/13] cmake/cmake_uninstall.cmake.in Fixing issue probably due to cmake version --- cmake/cmake_uninstall.cmake.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index dc36259c0..25cd0980b 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 \"$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}") From 4c803844e3a50bfc4c6574c25e288f4cef5468f2 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 16 Jul 2024 21:52:44 +0200 Subject: [PATCH 12/13] cmake/cmake_uninstall.cmake.in avoiding warning --- cmake/cmake_uninstall.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index 25cd0980b..feb51315e 100644 --- a/cmake/cmake_uninstall.cmake.in +++ b/cmake/cmake_uninstall.cmake.in @@ -9,7 +9,7 @@ foreach(file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") execute_process( - COMMAND ${CMAKE_COMMAND} -E rm \"$ENV{DESTDIR}${file}\" + COMMAND ${CMAKE_COMMAND} -E rm -f $ENV{DESTDIR}${file} OUTPUT_VARIABLE rm_out RESULT_VARIABLE rm_retval ) From db26d7e308435d1670a744f28cd86a90cd8c7fa6 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 16 Jul 2024 21:53:13 +0200 Subject: [PATCH 13/13] cmake/thisREST.cmake avoiding warning --- cmake/thisREST.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index c81446aeb..450284ef2 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -30,7 +30,7 @@ if (DEFINED ENV{LCG_VERSION}) 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" + "\# We load the LCG_${LCG_VERSION} environment.\necho \\\"Loading\ LCG_${LCG_VERSION}\ environment\\\"\nsource ${LCG_SETUP}\n" ) endif ()