[Cmake] How does CMake decide when and where to build .dsp files?

Brad King brad.king at kitware.com
Thu Dec 12 15:16:25 EST 2002


Hi David,

> I have a program that has been built with Visual C++, and the
> developers want to continue using Visual C++ so we're stuck with
> .dsw and .dsp files.  So I was very happy when I saw that
> CMake will generate .dsw and .dsp, and I even got a small part of
> the build environment apparently to come up (a workspace with one
> of the projects).  But when I tried to add more of our projects
> to the workspace, first Visual Studio complained that the .dsp file
> wasn't generated by Studio...
[snip]

VS is right, it didn't generate the .dsp file.  CMake did.  CMake is not
designed to generate .dsp files that can be edited from Visual Studio.
It should not be used to initialize a project and then dropped.  The
CMakeLists.txt files control the project.  Any changes that are made to
the .dsp files will not be reflected in the CMakeLists.txt files.  The
.dsp files should not be removed or modified by anything but CMake.

Please remember that CMake is "cross-platform" make, meaning that a single
set of build configuration files can be used to build on any platform.

The "PROJECT" command sets the name of the project, which becomes the name
of the .dsw file:

# Project will be in FOO.dsw for MSVC 6.
PROJECT(FOO)

The .dsp files each correspond to a library or executable target:

# Library will be built by foo.dsp for MSVC 6.
ADD_LIBRARY(foo foo.cxx)

# Executable will be built by bar.dsp for MSVC 6.
ADD_EXECUTABLE(bar bar.cxx)

> In other words, it seemed my CMakeLists.txt was causing CMake to
> generate a .dsp, and then it mysteriously stopped doing so.
> And I can't find any rules in the documentation that could
> explain how this could happen.  (Of course it's obvious that it
> happened when I fooled around with various filenames, options,
> and so forth, the problem is I have found no clue as to which of my
> actions in particular might have done this, or how I can fix it
> or prevent it from happening again.)

Once the .dsp has been removed by hand, there is no way VS can know to
re-run cmake to generate the file.  Running CMake on the project again by
hand will re-generate the .dsp.

> My other problem (which may be related) is the naming of the .dsp files.
> For reasons I'm still trying to figure out completely, when it came to
> the second .dsp file, CMake initially created one with a name different
> than the .dsp that Visual Studio had been using. How does CMake
> determine the name of the .dsp file that it will write?

As shown above, the names correspond to the executable and library target
names.

-Brad




More information about the CMake mailing list