[CMake] FW: building a mixed language programm with CMake
Denis Scherbakov
denis_scherbakov at yahoo.com
Wed Jun 10 09:59:33 EDT 2009
> $ nm test.o
> U __gxx_personality_v0
> U hello1_
> 0000000000000000 T main
> $ nm hello.o
> U _gfortran_st_write
> U _gfortran_st_write_done
> U _gfortran_transfer_character
> 0000000000000000 T hello1_
So you're calling Fortran from C.
> /usr/bin/gfortran -fPIC
> CMakeFiles/hi.dir/hello.o -o hi -rdynamic -lgfortran
The problem is that CMake decides to use gfortran as a linker, not gcc,
because we specified that this is a Fortran project and forgot about C++.
So the solution is:
# To indicate that this is mixed language project
PROJECT(TEST CXX Fortran)
# To explicitly specify that your MAIN is C++'s main.
SET_TARGET_PROPERTIES(test PROPERTIES LINKER_LANGUAGE CXX)
"set_target_props" without "project" will not work.
Denis
More information about the CMake
mailing list