[CMake] Runpath issues on OSX 10.6

Michael Wild themiwi at gmail.com
Wed Jun 29 15:43:32 EDT 2011


On 06/29/2011 09:33 PM, Quanah Gibson-Mount wrote:
> --On Wednesday, June 29, 2011 9:27 PM +0200 Michael Wild
> <themiwi at gmail.com> wrote:
> 
>> On 06/29/2011 09:14 PM, Quanah Gibson-Mount wrote:
>>> --On Wednesday, June 29, 2011 8:49 PM +0200 Michael Wild
>>> <themiwi at gmail.com> wrote:
>>>
>>>> That's because on OS X you have to use the INSTALL_NAME_DIR property
>>>> (or
>>>> alternatively, the CMAKE_INSTALL_NAME_DIR variable).
>>>
>>> I put:
>>>
>>> IF(APPLE)
>>>  SET(INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
>>> ENDIF()
>>>
>>> in CMakeLists.txt, and the result is the same.  I tried
>>> CMAKE_INSTALL_NAME_DIR as well, same result.  So this does not appear to
>>> resolve the issue. :/
>>>
>>> --Quanah
>>
>> The variable is called CMAKE_INSTALL_NAME_DIR. The property must be set
>> using set_target_properties(). Also, remove all the other RPATH related
>> stuff, to avoid strange interactions. You might also want to create a
>> tiny test project for your experiments. E.g. something like this:
> 
> As noted above, I tried both the variable names.  In fact, I have now
> even stripped out the "APPLE" if:
> 
> SET(INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
> SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
> 
> I don't see either of these set in CMakeCache.txt after cmake is run.

You really should read a bit more about CMake... Only variables that are
being set() using the CACHE option or using functions like option() and
find_XXX() show up in the cache.

> 
>> cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
>> project(test)
>> set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
>> add_library(test SHARED test.c)
>> install(TARGETS test
>>   RUNTIME DESTINATION lib
>>   LIBRARY DESTINATION lib)
>>
>> where the test.c file contains a trivial function, e.g.
>>
>> void foo(void){}
>>
>>
>> Unfortunately I currently don't have access to OS X, so I wasn't able to
>> test the above...
> 
> Unfortunately, all I have is the massive behemoth of mysql.  I'm not
> really sure how to translate your example above into their sprawling
> build bits. :/  I will try again with all the RPATH pieces pulled as well.
> 
> --Quanah

That was exactly the idea! Figure out what needs to be done with the
most simple test case, and then translate it to the big, complicated
case. If you can't make it work with the simple case, don't even try
starting with the big behemoth. Absolutely basic debugging-101...

Michael


More information about the CMake mailing list