[CMake] Adding additional libraries at configuration or building time

Alberto Luaces aluaces at udc.es
Fri May 29 08:20:26 EDT 2009


El Miércoles 27 Mayo 2009ES 09:06:05 Alberto Luaces escribió:
> Hello,
>
> is there any way of appending additonal libraries to a CMake project
> without touching the CMakeLists.txt file? Something like
>
> cmake EXTRA_LIBS=-lfoo .
>
> or
>
> make EXTRA_LIBS=-lfoo
>
> My problem is that I have a system where some additonal system libraries
> are required at the end of the linking command line and, since the project
> is from a 3rd party, I don't want to modify the CMakeLists.txt file unless
> absolutely necessary.

Just in case someone has to deal with this in the future, I found a temporal 
solution for the ld linker: use CMAKE_*_LINKER_FLAGS with the --whole-archive 
option, so the required symbols are being used even they are listed at the 
beginnig of the linker command line, for example:

CMAKE_SHARED_LINKER_FLAGS="-Wl,--whole-archive -lgcc -lgcc_s -Wl,--no-whole-archive"

Regards,

Alberto


More information about the CMake mailing list