Skip to content

Commit dd2ec8b

Browse files
committed
[cmake] do not check none-existing variables
Then checking ROOTSYS, do not try to modify none-existing variables. Like LD_LIBRARY_PATH on windows. Also no need to change ROOTSYS if it set correctly
1 parent 8e73bb6 commit dd2ec8b

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

CMakeLists.txt

+16-9
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,26 @@ set(DIR_PERMISSIONS DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE G
5757
# Before setting ROOTSYS, make sure that the environment isn't polluted by a different
5858
# ROOT build. This is significant e,g. for roottest, which will otherwise have libraries
5959
# of a different ROOT build available / visible / reachable.
60-
if(NOT $ENV{ROOTSYS} STREQUAL "")
60+
if(NOT $ENV{ROOTSYS} STREQUAL "" AND NOT $ENV{ROOTSYS} STREQUAL "${CMAKE_BINARY_DIR}")
6161
function(strip_path ENV_VAR _path)
62-
string(REPLACE ":${_path}:" ":" _temp_envvar $ENV{${ENV_VAR}})
63-
string(REGEX REPLACE "^${_path}:" "" _temp_envvar ${_temp_envvar})
64-
string(REGEX REPLACE ":${_path}$" "" _temp_envvar ${_temp_envvar})
65-
if (_temp_envvar STREQUAL _path)
66-
set(ENV{ENV_VAR} "")
67-
else()
68-
set(ENV{ENV_VAR} "${_temp_envvar}")
62+
if(NOT $ENV{${ENV_VAR}} STREQUAL "")
63+
string(REPLACE ":${_path}:" ":" _temp_envvar $ENV{${ENV_VAR}})
64+
string(REGEX REPLACE "^${_path}:" "" _temp_envvar ${_temp_envvar})
65+
string(REGEX REPLACE ":${_path}$" "" _temp_envvar ${_temp_envvar})
66+
if (_temp_envvar STREQUAL _path)
67+
set(ENV{ENV_VAR} "")
68+
else()
69+
set(ENV{ENV_VAR} "${_temp_envvar}")
70+
endif()
6971
endif()
7072
endfunction()
7173
strip_path("PATH" "$ENV{ROOTSYS}/bin")
72-
strip_path("LD_LIBRARY_PATH" "$ENV{ROOTSYS}/lib")
74+
if(not WIN32)
75+
strip_path("LD_LIBRARY_PATH" "$ENV{ROOTSYS}/lib")
76+
endif()
77+
if(APPLE)
78+
strip_path("DYLD_LIBRARY_PATH" "$ENV{ROOTSYS}/lib")
79+
endif()
7380
strip_path("PYTHONPATH" "$ENV{ROOTSYS}/lib")
7481
# if we leave the ':' it will result in an empty entry in the CMAKE_PREFIX_PATH
7582
# which will interpreted as the current directory.

0 commit comments

Comments
 (0)