[CMake] using cmake on windows - query on existing targets
Chauhan, Vikas
vikas.chauhan at anritsu.com
Mon Jan 11 15:51:00 EST 2010
> > Actually, when I used the macro I found that though this macro gives
> > a
> > useful functionality it is not exactly what I wanted.
> >
> > What I want to do can be illustrated the following example:
> > I have a main project/dir - projectSystem
> > I have three component/dir - projectcomponent1, projectcomponent2,
> > projectcomponent3.
> >
> > Now on windows from the directory where the cmake generated files
are
> > present, at present I issue a command :
> > cmake --build PATH_TO_PROJECTSYSTEM
> > This builds the projectSystem alongwith projectComponent1,
> > projectComponent2 & projectComponent3.
> >
> > Now, I want to do two things on command window(from the dir where
> > cmake
> > build files are generated):
> > 1. Query the list of sub-targets(components) available. In this case
> > the
> > result is a list
> > projectComponent1
> > projectComponent2
> > projectComponent3
> > 2. Now based on the list in 1, optionally build any component. For
> > example issue a command:
> >
> > cmake --build projectComponent1
> >
> > Can we achieve this? Or is it asking for too much :)
> >
> > Thanks,
> > Vikas
>
> I'm new to CMake too, but it looks like you could do what you want
with the
> option() directive.
>
> So I would have in my CMakeLists.txt something like:
>
> option(ProjectComponent1 "Builds the first project component" OFF)
> etc.
>
> And later on:
> if(ProjectComponent1)
> add_subdirectory(${ProjectComponent1_DIR})
> endif(ProjectComponent1)
> etc.
>
> and then in ccmake set the option to ON when you want to build with
it. I'd be
> surprised if there wasn't a way to define separate make targets
somewhere
> instead though, so you could do "make projectComponent1", but I'm not
sure
> about how to do that.
I understand what you mean and it is similar to what the macro suggested
by Alex does.
However, I do not want a developer to have a need to change setting in
the cmake GUI for what I need.
What I want is that:
1. the user should be able to see a list of components & sub-components,
using a command from the cmd window from the location where the cmake
GUI has generated the build files.
2. the user should be able to choose a sub-component to build without
asking to build the whole component. Also, I do not want to be
generating build files every time I choose to build a different
sub-component.
Is this possible?
Please note that I am on windows. I guess this is easily possible on
Linux. As make allows you to query a list of targets & can build
specific targets as well. Please correct me if I am wrong.
Thanks,
Vikas
More information about the CMake
mailing list