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

Stephen Kelly steveire at gmail.com
Fri Feb 17 07:16:40 EST 2012


Eric Noulard wrote:

> 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.

Yes, that works fine as expected, thanks!

> 
>> 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) ?
> 

It is exported.

So that resolves one of the two issues I posted about. 

The other issue is regarding setting RPATH for the build step and not the 
install step, and what syntax should be used for that. 

The options are:

a) Change the behaviour of CMAKE_SKIP_RPATH to set the RPATH in the build
   dir (does this need a policy)

b) Add the new variable CMAKE_SKIP_INSTALL_RPATH to skip only the 
   installation RPATH, but do use it for the build step. (Fits with existing 
CMAKE_SKIP_BUILD_RPATH)

c) Make the existing CMAKE_SKIP_BUILD_RPATH override CMAKE_SKIP_RPATH if set 
   to false. (This probably would need a policy)

My choice is b), but I don't know if there are good reasons for the others.





More information about the cmake-developers mailing list