[CMake] Changing linker program

William A. Hoffman billlist at nycap.rr.com
Fri Oct 29 09:27:53 EDT 2004


You can do it like this:

ADD_EXECUTABLE(foo foo.c)
SET_TARGET_PROPERTIES(foo PROPERTIES HAS_CXX TRUE)

That should work with the most current release of cmake.
For older cmake versions, if you add a dummy c++ file to the executable,
it will do the same thing.  As long as there is at least one c++ file
in the sources of a target or the target has the propertie HAS_CXX set to
true it will use c++.

-Bill


At 05:54 AM 10/29/2004, Stefan Granqvist wrote:
>Hi,
>
>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?
>
>_________________________________________________________________
>Lättare att hitta drömresan med MSN Resor http://www.msn.se/resor/
>
>_______________________________________________
>CMake mailing list
>CMake at www.cmake.org
>http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list