3
votes

I have a project with CMake build system. Project type is Fortran

project(ProjectName Fortran)

and the Fortran compiler is recognized as well as the source code.

When trying to create a Visual Studio 9 2008 with

$ cmake . -G "Visual Studio 9 2008"

I get a Visual Studio project file for a C++ project. Which is obviously wrong. I do not have any hints on C/C++ in the project. Do I need to specify another command line option or do I need additional information in CMakeLists.txt?

[UPDATE]

I found in the /build directory of CMake some .vfproj files (beside a corresponding .vcproj file) which contain Fortran project files which are also readable by Visual Studio. The files where in directories with binary targets and modules. But in parent directories were none.

So, what is the trick to get one central Fortran Visual Studion project file for the whole project? I am still puzzled... Is it possible at all?

2
Have you seen the last 2 links in the accepted answer to this question? - Fraser
I have found it before, too. BUt, I do not see, how it could help. :-( I get a C/C++ project generated, but I do not have any hints for that in my CMakeLists.txt files. I also did not find additional parameter which might help. Also not in the links you mentioned. Do you have a more detailed hint on this topic? Maybe, I miss something here. - Rick-Rainer Ludwig
No - I'm afraid I don't use Fortran, so I'm not much use to you. The mailing list is pretty friendly though. You could try asking there. - Fraser
Yeah, I will ask the mailing list. I thought here would be someone with the same issue... Thanks anyways! - Rick-Rainer Ludwig
Which suffix do your source files use? If you use some non-standard suffix, CMake might not recognize your source files as being Fortran. By default, it then generates C projects. You might also try setting the linker language property of the library or executable explicitly, see set_target_properties. - Martin

2 Answers

1
votes

You only show one line of code from your CMakeLists file:

project(ProjectName Fortran)

How do you go about adding references to your fortran source files? It should be something like this:

add_library(MyFLib1 MyFLib1.f)

Or this:

add_executable(MyFExe MyFExe.f)

If you add a library and an executable that are based solely on fortran source files, then CMake should generate a *.vfproj file for each one.

If not, it's a bug...

0
votes

As mentioned project (ProjectName Fortran) should work.

The other option is to enable_language (Fortran).