[CMake] linking with .so w/ non-standard names

Kenneth Chang kchang at athenacr.com
Fri Aug 14 12:23:23 EDT 2009


Tried this, ABCD_LIBRARY gets the correct path, but for some reason, 
target_link_libraries likes to convert it to -Lxxx -lyyy on the link 
line.  (I've previously typed the name of the file directly into the 
target_link_libraries() command too)

I'm seeing some of these properties like EXTERNAL_OBJECT, but it's not 
really working either.

set_source_files_properties(
  abcd.so
  PROPERTIES
  EXTERNAL_OBJECT true
  GENERATED true
  LOCATION /path/to/so
  )

add_executable( sfitqd
  sfitqd.cc
  abcd.so
)


Michael Wild wrote:
> Perhaps something like this:
>
> set( CMAKE_SHARED_LIBRARY_PREFIX_bak ${CMAKE_SHARED_LIBRARY_PREFIX} )
> set( CMAKE_SHARED_LIBRARY_PREFIX )
> find_library( ABCD_LIBRARY abcd )
> set( CMAKE_SHARED_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX_bak} )
>
> ....
>
> target_link_libraries( a.out ${ABCD_LIBRARY} )
>
>
> HTH
>
> Michael
>
> On 14. Aug, 2009, at 0:16, Clinton Stimpson wrote:
>
>>
>> How about this:
>> target_link_libraries(a.out /path/to/abcd.so)
>> If you use find_library(), then you should be getting full names 
>> already.
>>
>> Clint
>>
>> Kenneth Chang wrote:
>>> Hi,
>>>
>>> I have this third party library that has a .so named like abcd.so 
>>> instead of libabcd.so.  Putting the name in
>>>
>>> target_link_libraries( a.out abcd.so )
>>>
>>> doesn't work because this generates -labcd on the link line and then 
>>> ld can't find it.  What do I need to do to get this to link?
>>>
>>> Thanks!
>>> Kenny
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at 
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at: 
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at 
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at: 
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>



More information about the CMake mailing list