Skip to content

[cmake] do not check none-existing variables [6.36] #18496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,26 @@ set(DIR_PERMISSIONS DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE G
# Before setting ROOTSYS, make sure that the environment isn't polluted by a different
# ROOT build. This is significant e,g. for roottest, which will otherwise have libraries
# of a different ROOT build available / visible / reachable.
if(NOT $ENV{ROOTSYS} STREQUAL "")
if(NOT $ENV{ROOTSYS} STREQUAL "" AND NOT $ENV{ROOTSYS} STREQUAL "${CMAKE_BINARY_DIR}")
function(strip_path ENV_VAR _path)
string(REPLACE ":${_path}:" ":" _temp_envvar $ENV{${ENV_VAR}})
string(REGEX REPLACE "^${_path}:" "" _temp_envvar ${_temp_envvar})
string(REGEX REPLACE ":${_path}$" "" _temp_envvar ${_temp_envvar})
if (_temp_envvar STREQUAL _path)
set(ENV{ENV_VAR} "")
else()
set(ENV{ENV_VAR} "${_temp_envvar}")
if(NOT $ENV{${ENV_VAR}} STREQUAL "")
string(REPLACE ":${_path}:" ":" _temp_envvar $ENV{${ENV_VAR}})
string(REGEX REPLACE "^${_path}:" "" _temp_envvar ${_temp_envvar})
string(REGEX REPLACE ":${_path}$" "" _temp_envvar ${_temp_envvar})
if (_temp_envvar STREQUAL _path)
set(ENV{ENV_VAR} "")
else()
set(ENV{ENV_VAR} "${_temp_envvar}")
endif()
endif()
endfunction()
strip_path("PATH" "$ENV{ROOTSYS}/bin")
strip_path("LD_LIBRARY_PATH" "$ENV{ROOTSYS}/lib")
if(NOT WIN32)
strip_path("LD_LIBRARY_PATH" "$ENV{ROOTSYS}/lib")
endif()
if(APPLE)
strip_path("DYLD_LIBRARY_PATH" "$ENV{ROOTSYS}/lib")
endif()
strip_path("PYTHONPATH" "$ENV{ROOTSYS}/lib")
# if we leave the ':' it will result in an empty entry in the CMAKE_PREFIX_PATH
# which will interpreted as the current directory.
Expand Down
Loading