[cmake-developers] Modifying RPATH feature to run tests uninstalled

Eric Noulard eric.noulard at gmail.com
Fri Feb 17 07:07:38 EST 2012


2012/2/17 Stephen Kelly <steveire at gmail.com>:
> Marcel Loose wrote:
>
>> Hi Stephen,
>>
>> On Fri, 2012-02-17 at 12:06 +0100, Stephen Kelly wrote:
>>
>> -- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< --
>>
>>> diff --git a/templates/tests/CMakeLists.txt
>> b/templates/tests/CMakeLists.txt
>>> index d2e37d2..ad471c7 100644
>>> --- a/templates/tests/CMakeLists.txt
>>> +++ b/templates/tests/CMakeLists.txt
>>> @@ -83,6 +83,7 @@ macro(GRANTLEE_TEMPLATES_UNIT_TESTS)
>>>                    ${_testresource_rcc_src}
>>>      )
>>>      add_test(${_testname} ${_testname}_exec )
>>> +    set_property(TEST ${testname} PROPERTY ENVIRONMENT
>>> "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/templates/lib")
>>>
>>>
>>> Do you see anything wrong there?
>>
>> You should use ${_testname} in the set_property() command. Don't you get
>> an error message from CMake? Or do you happen to have a variable
>> "testname" as well.
>>
>
> D'Oh! You're right. I typo'd there. It works with my system Qt if I fix the
> typo.
>
> However, it doesn't solve the whole problem for me. Mostly I use a Qt in a
> non-standard prefix and I set LD_LIBRARY_PATH to find it (I have many Qts
> and a script to change my environment)
>
> I tried changing it to
>    set_property(TEST ${_testname} PROPERTY ENVIRONMENT
> "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${CMAKE_BINARY_DIR}/templates/lib")
>
> ie appending to the LD_LIBRARY_PATH, and it didn't find the correct Qt.

I'm not sure it'll append using this shell-like syntax, which suppose
shell-like evaluation for "$LD_LIBRARY_PATH".

Could you try
LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_BINARY_DIR}/templates/lib"
instead, which uses the CMake variable syntax to access environment.

> Is that something relevant for others that we should care about? Or is my
> setup unusual and irrelevant? Is it a bug that the LD_LIBRARY_PATH from my
> environment is not carried over?

Does you initial environment export LD_LIBRARY_PATH or not (simple set) ?

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org



More information about the cmake-developers mailing list