[CMake] C++ and FORTRAN
Bill Hoffman
bill.hoffman at kitware.com
Wed May 28 09:25:06 EDT 2008
Allen Barnett wrote:
> Hi: I have a project which consists of a C++ main and a set of FORTRAN
> computational routines which I'm trying to build on windows XP. I'm
> using visual studio 2008 (VC9) and the Intel FORTRAN compiler (10.1) on
> IA32. I'm also using CMake 2.6 patch 0.
> If I generate NMake Makefiles, everything works correctly; both the C++
> main and the FORTRAN subroutines are correctly compiled and linked.
> However, if I generate a visual studio 2008 project and try to build it
> within the GUI, the FORTRAN object is not compiled. (I have to admit
> nearly complete ignorance about how visual studio works so this is very
> likely a case of operator error; but it looks like no compilation
> directives are created for the FORTRAN source file.)
> I attached some files which emulate my project. Any guidance would be
> greatly appreciated.
> Thanks,
> Allen
>
Yup, sorry, won't work. Each target (library, exe) must be all fortran.
The IDE does not support mixed CXX and Fortran. So, you would have to
have:
CMAKE_MINIMUM_REQUIRED( VERSION 2.6 )
ENABLE_LANGUAGE( Fortran )
ADD_LIBRARY(myfortran STATIC f.f90)
ADD_EXECUTABLE(
cf
c.cpp
)
target_link_libraries(cf myfortran)
More information about the CMake
mailing list