[CMake] Under Visual Studio , allow developers to hit "F7" to run the INSTALL target

david_bjornbak at agilent.com david_bjornbak at agilent.com
Fri Feb 10 01:10:19 EST 2012

I dug into CMake’s C++ code and found there’s a generic setting named EXCLUDE_FROM_ALL that most “targets” use to decide if a project should be under the default build but, there’s particular target type named “GLOBAL_TARGET”  does use this setting and it’s always excluded from all.

Based on what I’m reading in the CMake’s C++, the safest place to make a optional change is right at the point where it’s generating Visual Studio files.  The other logic spot in in a function cmGlobalGenerator::CreateGlobalTarget but, changes here will create a larger ripple effect on what will most likely go wrong with this type of tinkering.

The following is the spot in the code I have in mind changing and picking up both an optional setting and the current “target name” being “INSTALL”

Let me know if there’s a better way to allow Visual Studio developers to hit “F7” and have the “INSTALL” target/vs project run for them.   This current C++ will be a private patch for my team but, I prefer if we can have a more public optional setting for this request.

bool cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
                                                          cmTarget* target)
    return false;
  // if it is a utilitiy target then only make it part of the
  // default build if another target depends on it
  int type = target->GetType();
  if (type == cmTarget::GLOBAL_TARGET)
       return false;
  if(type == cmTarget::UTILITY)
    return this->IsDependedOn(project, target);
  // default is to be part of the build
  return true;

The return false after type == cmTarget::GLOBAL_TARGET will become

if ( strcmp(target->GetName(),"INSTALL") == 0  &&  SOME_OPTIONAL_SETTING )
          return true;
                 return false;


From: Yuri Timenkov [mailto:yuri at timenkov.ru]
Sent: Wednesday, February 08, 2012 7:27 PM
To: BJORNBAK,DAVID (A-Sonoma,ex1)
Cc: cmake at cmake.org
Subject: Re: [CMake] Under Visual Studio , allow developers to hit "F7" to run the INSTALL target

I use a special macro for such purposes, something like this:
    Sub Install()
        Dim prj As Project
        Dim sb As SolutionBuild = DTE.Solution.SolutionBuild
        Dim prjs As Projects = DTE.Solution.Projects

        For Each prj In prjs
            If prj.Name = "INSTALL" Then
                sb.BuildProject(sb.ActiveConfiguration.Name<http://sb.ActiveConfiguration.Name>, prj.UniqueName)
                Exit For
            End If
    End Sub

Good thing is that you can put it on toolbar or bind to hot key and run it separately (while keeping active project you're debugging).
On Tue, Feb 7, 2012 at 11:47 PM, <david_bjornbak at agilent.com<mailto:david_bjornbak at agilent.com>> wrote:
Developers on our team have found issues with the difference between “INSTALL” and the default build or “F7” build all under Visual Studio.  My question is, there’s a reasonable way to configure cmake or Visual Studio to run the INSTALL target when you hit “F7” or use the default “Build Solution” functionality to run INSTALL.

We’re working a fairly large project and the default setting of having INSTALL dependent on ALL or separating out the two targets makes sense when you’re building the entire project.

However, we allow developers to build sub projects and it makes sense if these sub project just install quickly into a larger pre-built installation directory.  The confusion currently is, they run ALL_BUILD or “F7” and the build finishes and they forget to run “INSTALL”.    Particularly we, had developers that worked formally on smaller non-Cmake Visual Studio projects and not Linux so, they’re not used to the make all and then make install defacto standard.
This request is similar as the following on “Selecting INSTALL target in Visual Studio Configuration by default”  but, I wanted to see if anyone had any other suggestions on this topic.



Powered by www.kitware.com<http://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:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120209/aedd39a7/attachment-0001.htm>

More information about the CMake mailing list