[CMake] Separate the compiler used for compile versus link

Clinton Stimpson clinton at elemtech.com
Thu Feb 12 13:53:03 EST 2009


On Thursday 12 February 2009 11:47:09 Bill O'Hara wrote:
> Right now I have a legacy makefile which does the equivalent of
>
> gcc -c foo.c
> g++ -o foo foo.o -lasdf -lqwer
>
> Because asdf and qwer are static libraries from c++ sources.
>
> Is there a straightforward way to do something like
>
> add_executable(foo foo.c)
> target_link_libraries(foo asdf qwer)
>
> in this case and have g++ used for final compilation step?
>
> thanks
> b.

Try this:
set_target_properties(foo PROPERTIES LINKER_LANGAUGE CXX)

Clint



More information about the CMake mailing list