[CMake] How to specify LD_LIBRARY_PATH for a test?

Orion Poplawski orion at cora.nwra.com
Tue Feb 26 13:00:49 EST 2013


We have some tests that load libraries at run time.  How can we specify that 
LD_LIBRARY_PATH needs to be set?

file(WRITE ${CMAKE_SOURCE_DIR}/testsuite/launchtest.c "${LAUNCH}")
add_executable(launchtest EXCLUDE_FROM_ALL 
${CMAKE_SOURCE_DIR}/testsuite/launchtest.c)
add_library(test_ce SHARED EXCLUDE_FROM_ALL libtest_ce.cpp)
add_custom_target(check COMMAND ${CMAKE_BUILD_TOOL} test DEPENDS launchtest 
test_ce)
get_target_property(LAUNCHTESTLOCATION launchtest LOCATION)
execute_process(
   COMMAND "fgrep" ".pro" "${BASE_SOURCE}/testsuite/Makefile.am"
   COMMAND "awk" "{printf(\"%s;\",$1)}"
   OUTPUT_VARIABLE TESTS)
foreach(TEST ${TESTS})
         add_test(${TEST} ${LAUNCHTESTLOCATION} ${TEST})
endforeach(TEST TESTS)

The test needs to be able to load the test_ce library at run-time.

Thanks!

-- 
Orion Poplawski
Technical Manager                     303-415-9701 x222
NWRA, Boulder Office                  FAX: 303-415-9702
3380 Mitchell Lane                       orion at nwra.com
Boulder, CO 80301                   http://www.nwra.com


More information about the CMake mailing list