[CMake] Magical transformation of /path/to/libmylib.so to -lmylib

Jens Mueller jens.k.mueller at gmx.de
Wed Jul 13 18:54:19 EDT 2011


Michael Hertling wrote:
> On 07/11/2011 11:34 PM, Jens Mueller wrote:
> > Hi,
> > 
> > I'm trying to figure out where the path for a found library is changed.
> > In my case Curses is found at /usr/lib/libcurses.so. When linking with
> > gcc "/usr/lib/libcurses.so" is replaced by "-lcurses" as it is specified
> > at http://www.cmake.org/Wiki/CMake_2.6_Notes#Linking_to_System_Libraries.
> > Where can I find the code that causes these changes? I looked into
> > share/Modules/ at various CMake* files but I'm unable find the code.
> > 
> > Jens
> 
> The system directories are identified during the initial detection
> of the compiler ABI ("Detecting <LANG> compiler ABI info"), see
> 
> Modules/CMakeDetermineCompilerABI.cmake
> Modules/CMakeParseImplicitLinkInfo.cmake
> 
> w.r.t. the CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES variables.
> 
> AFAIK, the actual conversion of the full path to a -l option
> is performed in Source/cmComputeLinkInformation.cxx by:
> 
> cmComputeLinkInformation::AddFullItem()
> cmComputeLinkInformation::CheckImplicitDirItem()
> cmComputeLinkInformation::AddUserItem()
> 
> Previously, the underlying cmComputeLinkInformation::ImplicitLinkDirs
> set is populated by cmComputeLinkInformation::LoadImplicitLinkInfo()
> from the CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES variables' contents.

Thanks very much. This helped a lot. I see much clearer now. The
compiler I'm using uses gcc for linking. I made sure that the implicit
link directories are properly extracted. But somehow I need to
trigger/allow the conversion of full path to -l. It does not work
automatically. Do I have to configure this for a new language/new
compiler?

Jens


More information about the CMake mailing list