[CMake] Changing linker program

Brad King brad.king at kitware.com
Fri Oct 29 07:28:31 EDT 2004


Stefan Granqvist wrote:
> I would like to link an object file generated from c source code (using 
> gcc) with a c++ library using the c++ linker (e.g. g++). But I have not 
> found any cmake variable to change the
> linker command, only the compiler (i.e. CMAKE_C_COMPILER variable).
> 
> Have I missed anything obvious or is it not possible to change the 
> linker (e.g. in a variable named sometning like CMAKE_C_LINKER)?
> 
> If not, what is the recommended way to make it possible to link a C 
> program with c++ library on solaris without link errors?

Currently the only way is to include a C++ source file in the 
executable.  It doesn't have to have any code, but the file must exist:

ADD_EXECUTABLE(myexe empty.cxx src1.c src2.c ...)

This is a known problem and will be fixed in a future release.

-Brad


More information about the CMake mailing list