[CMake] cmake 2.8.8 doesn't create vfproj for Visual Studio 10

Bill Hoffman bill.hoffman at kitware.com
Fri Aug 17 23:34:02 EDT 2012


On 8/17/2012 9:19 PM, DonRobinson wrote:
> Disclaimer - I'm just learning cmake. I read as much as I could before
> posting. I am attempting to use Cmake 2.8.8 to create a to create a
> VS2010 SLN file. I have MS Visual Studio 10, Intel Fortran XE 12.1.2.278
> and MSVC 16.00.40219.01 all installed and work for other mixed language
> solutions (SLN files) created "by hand." Intermediate tests run
> internally by cmake appear to succeed and TryCompile executables are
> built. My listing of source files contains a mix of over 500 .f, .F77,
> .c and .h files. When the SLN file is created all files are incorporated
> into one project (vcxproj), and all .f files are treated as
> non-compilable. From a read of various posts I think that */some
> /*developers have been able to combine all source code into a single
> project file that will compile. I haven't been able to do this! I
> welcome any advice (possibly even example CMakeLists.txt files) or URLs
> about how to proceed. I'm quite stuck at this point. My experience with
> working with hand-built SLN files created from with the VS2010
> environment has been to keep .c code in separate C language projects
> which compile to LIB files that are linked. The .f code (the bulk of the
> code) is compiled separately and the LIB and OBJ files are combined at
> link time.
> ------------------------------------------------------------------------

You have to separate the fortran from the C to get it to work with the 
IDE project files.  So, all the fortran needs to be in its own 
add_library call.  You can combine them with the makefiles in CMake but 
VS has the restriction that the fortran has to be in a separate target.

Something like this should work:

add_library(fortranlib f1.f f2.f ...)
add_library(clib c1.c c2.c ...)
target_link_libraries(clib fortranlib)


-Bill



More information about the CMake mailing list