Skip to content

Commit b9310b6

Browse files
committed
[CMake] Don't set LD_LIBRARY_PATH in test macros
This should not be needed anymore because of the runpath mechanism, and by leaving it out from the test environment we are making sure that this keeps working.
1 parent 36fdd62 commit b9310b6

File tree

7 files changed

+8
-53
lines changed

7 files changed

+8
-53
lines changed

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,7 @@ if(runtime_cxxmodules)
556556
set(modules_idx_cmd COMMAND ${CMAKE_COMMAND} -E env PATH="${library_output_dir}\\\;%PATH%"
557557
ROOTIGNOREPREFIX=1 ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
558558
else()
559-
set(modules_idx_cmd COMMAND ${ld_library_path}=${library_output_dir}:$ENV{${ld_library_path}}
560-
ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
559+
set(modules_idx_cmd COMMAND ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
561560
ROOTIGNOREPREFIX=1 ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
562561
endif()
563562
add_custom_command(OUTPUT ${library_output_dir}/modules.idx
@@ -582,7 +581,7 @@ if(WIN32)
582581
ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
583582
ROOTIGNOREPREFIX=1 ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b -n -x ${CMAKE_SOURCE_DIR}/tutorials/hsimple.C -e return)
584583
else()
585-
set(hsimple_cmd COMMAND ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH} ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$ENV{${ld_library_path}}
584+
set(hsimple_cmd COMMAND ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
586585
ROOTIGNOREPREFIX=1 ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b -n -x ${CMAKE_SOURCE_DIR}/tutorials/hsimple.C -e return)
587586
endif()
588587
add_custom_command(OUTPUT tutorials/hsimple.root

bindings/tpython/test/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ if(MSVC)
1414
PYTHONPATH=${ROOTSYS}/bin;$ENV{PYTHONPATH})
1515
else()
1616
set(tpython_gtest_env
17-
PATH=${ROOTSYS}/bin:$ENV{PATH}
18-
LD_LIBRARY_PATH=${ROOTSYS}/lib:$ENV{LD_LIBRARY_PATH}
1917
PYTHONPATH=${ROOTSYS}/lib:$ENV{PYTHONPATH})
2018
endif()
2119

cmake/modules/RootMacros.cmake

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,6 @@ function(ROOT_ADD_PYUNITTESTS name)
18841884
else()
18851885
set(ROOT_ENV
18861886
PATH=${ROOTSYS}/bin:$ENV{PATH}
1887-
${ld_library_path}=${ROOTSYS}/lib:$ENV{${ld_library_path}}
18881887
PYTHONPATH=${ROOTSYS}/lib:$ENV{PYTHONPATH})
18891888
endif()
18901889
string(REGEX REPLACE "[_]" "-" good_name "${name}")
@@ -1910,7 +1909,6 @@ function(ROOT_ADD_PYUNITTEST name file)
19101909
else()
19111910
set(ROOT_ENV
19121911
PATH=${ROOTSYS}/bin:$ENV{PATH}
1913-
${ld_library_path}=${ROOTSYS}/lib:$ENV{${ld_library_path}}
19141912
PYTHONPATH=${ROOTSYS}/lib:$ENV{PYTHONPATH})
19151913
endif()
19161914
string(REGEX REPLACE "[_]" "-" good_name "${name}")
@@ -3130,15 +3128,13 @@ function(ROOTTEST_ADD_TEST testname)
31303128
else()
31313129
string(REPLACE ";" ":" _path "${ROOTTEST_ENV_PATH}")
31323130
string(REPLACE ";" ":" _pythonpath "${ROOTTEST_ENV_PYTHONPATH}")
3133-
string(REPLACE ";" ":" _librarypath "${ROOTTEST_ENV_LIBRARYPATH}")
31343131

31353132

31363133
set(environment ENVIRONMENT
31373134
${ROOTTEST_ENV_EXTRA}
31383135
${ARG_ENVIRONMENT}
31393136
PATH=${_path}:$ENV{PATH}
3140-
PYTHONPATH=${_pythonpath}:$ENV{PYTHONPATH}
3141-
${ld_library_path}=${_librarypath}:$ENV{${ld_library_path}})
3137+
PYTHONPATH=${_pythonpath}:$ENV{PYTHONPATH})
31423138
endif()
31433139

31443140
if(ARG_WORKING_DIR)
@@ -3383,15 +3379,13 @@ function(ROOTTEST_ADD_UNITTEST_DIR)
33833379
else()
33843380
string(REPLACE ";" ":" _path "${ROOTTEST_ENV_PATH}")
33853381
string(REPLACE ";" ":" _pythonpath "${ROOTTEST_ENV_PYTHONPATH}")
3386-
string(REPLACE ";" ":" _librarypath "${ROOTTEST_ENV_LIBRARYPATH}")
33873382

33883383

33893384
set(environment ENVIRONMENT
33903385
${ROOTTEST_ENV_EXTRA}
33913386
${ARG_ENVIRONMENT}
33923387
PATH=${_path}:$ENV{PATH}
3393-
PYTHONPATH=${_pythonpath}:$ENV{PYTHONPATH}
3394-
${ld_library_path}=${_librarypath}:$ENV{${ld_library_path}})
3388+
PYTHONPATH=${_pythonpath}:$ENV{PYTHONPATH})
33953389
endif()
33963390

33973391
ROOT_ADD_TEST(${fulltestname} COMMAND ${binary}

roottest/CMakeLists.txt

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -230,25 +230,8 @@ if(MSVC)
230230
else()
231231
set(ROOTTEST_ENV_PYTHONPATH ${ROOT_LIBRARY_DIR})
232232
endif()
233-
set(ROOTTEST_ENV_LIBRARYPATH ${ROOT_LIBRARY_DIR})
234233
set(ROOTTEST_ENV_EXTRA)
235234

236-
# Optionally, add Fortran link directories. This is needed in particular for
237-
# macOS, where the path of the Fortran library might not be in the default
238-
# DYLD_LIBRARY_PATH, but it gets picked up with enable_language(Fortran).
239-
if(APPLE AND fortran)
240-
# Convert Fortran link dirs to colon-separated string
241-
string(REPLACE ";" ":" FORTRAN_LINK_PATH "${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}")
242-
243-
# Append to ROOTTEST_ENV_LIBRARYPATH
244-
set(ROOTTEST_ENV_LIBRARYPATH "${ROOTTEST_ENV_LIBRARYPATH}:${FORTRAN_LINK_PATH}")
245-
246-
# Deduplicate ROOTTEST_ENV_LIBRARYPATH
247-
string(REPLACE ":" ";" _tmp "${ROOTTEST_ENV_LIBRARYPATH}")
248-
list(REMOVE_DUPLICATES _tmp)
249-
string(REPLACE ";" ":" ROOTTEST_ENV_LIBRARYPATH "${_tmp}")
250-
endif()
251-
252235
if(MSVC)
253236
set(ROOTTEST_ENVIRONMENT
254237
PYTHONPATH=${ROOTTEST_ENV_PYTHONPATH})
@@ -257,8 +240,7 @@ else()
257240
string(REGEX REPLACE ":$" "" TESTPYTHONPATH "${ROOTTEST_ENV_PYTHONPATH}:$ENV{PYTHONPATH}")
258241
set(ROOTTEST_ENVIRONMENT
259242
PATH=${ROOTTEST_ENV_PATH}:$ENV{PATH}
260-
PYTHONPATH=${TESTPYTHONPATH}
261-
${ld_library_path}=${ROOTTEST_ENV_LIBRARYPATH}:$ENV{${ld_library_path}})
243+
PYTHONPATH=${TESTPYTHONPATH})
262244
if (gnuinstall)
263245
set(ROOTTEST_ENVIRONMENT ${ROOTTEST_ENVIRONMENT} ROOTIGNOREPREFIX=1)
264246
endif()

roottest/root/ntuple/makeproject/rntuple/CMakeLists.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,8 @@ target_link_directories(read_rntuple PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/librntu
5353

5454
# Need to also explicitly set the LD_LIBRARY_PATH (at least on MacOS), so that
5555
# the generated library with the custom class can be loaded by the read test.
56-
# Setting the value of ${ld_library_path} in the ENVIRONMENT argument of the
57-
# ROOTTEST_ADD_TEST function will not work, because that function sets the same
58-
# variable internally, thus overriding our choice. The simplest thing to do is
59-
# to append our directory to the ${ROOTTEST_ENV_LIBRARYPATH} contents, which
60-
# are automatically used by ROOTTEST_ADD_TEST
61-
set(_roottest_env_librarypath ${ROOTTEST_ENV_LIBRARYPATH})
62-
set(ROOTTEST_ENV_LIBRARYPATH "${ROOTTEST_ENV_LIBRARYPATH}:${CMAKE_CURRENT_BINARY_DIR}/librntuplestltest")
6356
ROOTTEST_ADD_TEST(read_rntuple
6457
EXEC ./read_rntuple
6558
FIXTURES_REQUIRED read_rntuple_executable
6659
# PATH is used on Windows to find libraries for loading
67-
ENVIRONMENT PATH=${CMAKE_CURRENT_BINARY_DIR}/librntuplestltest)
68-
set(ROOTTEST_ENV_LIBRARYPATH ${_roottest_env_librarypath})
69-
60+
ENVIRONMENT ${ld_library_path}=${CMAKE_CURRENT_BINARY_DIR}/librntuplestltest)

roottest/root/ntuple/makeproject/ttree/CMakeLists.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,8 @@ target_link_directories(read_ttree PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/libttrees
5454

5555
# Need to also explicitly set the LD_LIBRARY_PATH (at least on MacOS), so that
5656
# the generated library with the custom class can be loaded by the read test.
57-
# Setting the value of ${ld_library_path} in the ENVIRONMENT argument of the
58-
# ROOTTEST_ADD_TEST function will not work, because that function sets the same
59-
# variable internally, thus overriding our choice. The simplest thing to do is
60-
# to append our directory to the ${ROOTTEST_ENV_LIBRARYPATH} contents, which
61-
# are automatically used by ROOTTEST_ADD_TEST
62-
set(_roottest_env_librarypath ${ROOTTEST_ENV_LIBRARYPATH})
63-
set(ROOTTEST_ENV_LIBRARYPATH "${ROOTTEST_ENV_LIBRARYPATH}:${CMAKE_CURRENT_BINARY_DIR}/libttreestltest")
6457
ROOTTEST_ADD_TEST(read_ttree
6558
EXEC ./read_ttree
66-
FIXTURES_REQUIRED makeproject_read_ttree_executable
59+
FIXTURES_REQUIRED makeproject_read_ttree_executable
6760
# PATH is used on Windows to find libraries for loading
68-
ENVIRONMENT PATH=${CMAKE_CURRENT_BINARY_DIR}/libttreestltest)
69-
set(ROOTTEST_ENV_LIBRARYPATH ${_roottest_env_librarypath})
61+
ENVIRONMENT ${ld_library_path}=${CMAKE_CURRENT_BINARY_DIR}/libttreestltest)

tutorials/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ if(DEFINED ROOT_SOURCE_DIR) # Testing using the binary tree
1818
set(ROOT_root_CMD root.exe)
1919
if(NOT MSVC) # Ignore environment on Windows
2020
set(ROOT_environ PATH=${CMAKE_BINARY_DIR}/bin:$ENV{PATH}
21-
${ld_library_path}=${CMAKE_BINARY_DIR}/lib:$ENV{${ld_library_path}}
2221
ROOT_INCLUDE_PATH=${CMAKE_BINARY_DIR}/tutorials/io/tree:${DEFAULT_ROOT_INCLUDE_PATH}
2322
PYTHONPATH=${CMAKE_BINARY_DIR}/lib:$ENV{PYTHONPATH})
2423
else()

0 commit comments

Comments
 (0)