[CMake] FW: building a mixed language programm with CMake
Natalie Happenhofer
nataliehapp at hotmail.com
Thu Jun 11 05:28:03 EDT 2009
Great, now it works!
My CMakeLists.txt now looks like this:
cmake_minimum_required(VERSION 2.4)
project(hi CXX Fortran)
ADD_LIBRARY(hello SHARED hello.f90)
SET(TEST_SRCS test.cxx)
ADD_EXECUTABLE(hi ${TEST_SRCS})
TARGET_LINK_LIBRARIES(hi hello)
SET_TARGET_PROPERTIES(hi PROPERTIES LINKER_LANGUAGE CXX)
Thanks a lot for your help!
Greetings,
Natalie
> Date: Wed, 10 Jun 2009 06:59:33 -0700
> From: denis_scherbakov at yahoo.com
> Subject: Re: [CMake] FW: building a mixed language programm with CMake
> To: cmake at cmake.org; nataliehapp at hotmail.com
>
>
> > $ 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
>
>
>
_________________________________________________________________
Gratis Internet Explorer 8 optimizado para MSN
http://www.ie8.msn.com/microsoft/internet-explorer-8/es-xl/ie8.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090611/5e122d3b/attachment.htm>
More information about the CMake
mailing list