I'd like to say thanks to those who have responded to my plea for help.  I was 
able to finally figure out what the problem was and figured I should share.

As I suspected it was something stupid.  We use DevStudio .NET 2003 and Intel 
Fortran 9.0 to build our projects on windows.  We have C++ code with Fortran 
libraries and using DevStudio as the build environment we have built and linked 
successfully.  So we knew it could be done.  When we started using CMake from 
the command line we forgot about all those environment variables that the IDE 
auto-magically takes care of for you.  By simply calling the Intel Fortran 
Environment setup batch file (ifortvars.bat), we got all of the missing vars 
setup and the CMake generated makefile started to work flawlessly.

Thanks for the help,
Mike

-----Original Message-----
From: "Caron, Michael C. (US SSA)" <michael.ca...@baesystems.com>
Subject: [CMake] Trying to mix C++ and Fortran code...
To: "cmake@cmake.org" <cmake@cmake.org>
Message-ID: <cd5fe9$4mm...@dmzms99802.na.baesystems.com>
Content-Type: text/plain; charset="us-ascii"

I've just started using CMake and have great hopes for it making my life 
simpler.  I currently have a windows console project that mixes C++ and Fortran 
code.  I have the main body of the code (in Fortran), an interface to display 
code written in C++(in Fortran), and some display code (C++).  I have used 
Visual Studio .NET 2003 and Intel Fortran 9.0 to build and link these 
successfully already, by building the project files and tweaking the 
appropriate build settings.  I'd like to switch to cmake generated build files 
so I can cross compile on Linux with a minimal amount of effort.  I could build 
makefiles for the Linux side, but then I'd have the nightmare of keeping both 
builds in sync.

I have created the CMakeLists.txt files for each of the subprojects (Fortran 
executable, Fortran Lib, and C++ Lib).  I've also generated nmake makefiles for 
each of the subprojects and used them to build with expected results.  Both the 
Fortran and C++ libs are built successfully and the Fortran executable fails 
complaining about unresolved externals (makes sense since I didn't point it to 
the libs yet).  When I add the code to the Fortran executable CMakeLists.txt to 
add_subdir for each of the static libs, and add the code to link the static 
libs things start to fall apart.

When I generate the make files my C++ lib no longer builds.  Looking around 
online I discovered the FortranCInterface and the FortranCInterface_VERIFY(CXX) 
cmake command.  I added an include for the FortranCInterface and the 
FortranCInterface_VERIFY(CXX) to the executable CMakeLists.txt file figuring 
that might provide some insight.  When I try to run cmake on that 
CMakeLists.txt file cmake complains that it could not compile the simple test 
file for the verify.

I know I can mix C++ and Fortran using the compilers I have, I've done it.  I 
must be missing some cmake magic.  Hopefully it is something stupid and someone 
will be able to see it and point it out to me.

Thanks in advance,
Michael Caron


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to