Conditional install

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Conditional install

rozelak
Dear all,

I would like to ask, if CMake supports something like "conditional" installation.
My CMakeLists.txt includes the following:

# The source files of the application (binary)
add_directory(src)

# The subdirectories with the required libraries. They are included
# through svn:externals
# They contain their own INSTALL( TARGETS .... )
add_directory(src_lib1)
add_directory(src_lib2)


When 'make' is called, both libraries are built and then STATICALLY linked
to the application - works perfectly.

However, when 'make install' is called, the libraries are installed as
well (right, they contain INSTALL() definition ...)

What I need is to tell to CMake NOT to install the libraries (they are

separate projects and it is not necessary to publish them together with
the binary). I mean something like EXCLUDE_FROM_ALL but in form of
EXCLUDE_FROM_INSTALL :-)

Is there a simple way, how to tell to CMake not to call INSTALL from
given directory? Without affecting the CMakeLists.txt of the libraries?
Like:

add_directory(src)

if (NOT install)
  add_directory(src_lib1)
  add_directory(src_lib2)
endif()

Thank you very much,
D.T.



P.S. I use cmake version 2.6-patch 2



--
Vyzkoušejte nový antivirus Kaspersky Internet Security 2010. Nejspolehlivější
ochrana před všemi druhy on-line zločinů již za 940 Kč. www.kaspersky.cz

_______________________________________________
Powered by 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:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Conditional install

Tyler Roscoe
On Mon, Jul 27, 2009 at 04:19:48PM +0200, [hidden email] wrote:

> When 'make' is called, both libraries are built and then STATICALLY linked
> to the application - works perfectly.
>
> However, when 'make install' is called, the libraries are installed as
> well (right, they contain INSTALL() definition ...)
>
> What I need is to tell to CMake NOT to install the libraries (they are
>
> separate projects and it is not necessary to publish them together with
> the binary). I mean something like EXCLUDE_FROM_ALL but in form of
> EXCLUDE_FROM_INSTALL :-)

Maybe the COMPONENT argument to install() can help you?

Otherwise, maybe only define install() rules for your components if
there is no top-level target that will end up doing the work?

if (NOT TARGET myExe)
    install(myLib1 ...)
    install(myLib2 ...)
endif ()


tyler
_______________________________________________
Powered by 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:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Conditional install

rozelak
Hallo,

thank you for your reply. I have tried to set the COMPONENT in the INSTALL()
command, but it did not lead to the expected result. The install command
I changed to (ONLY for the target I want to install, inspired by http://www.cmake.org/pipermail/cmake/2006-October/011362.html):

INSTALL(TARGETS ${LIB_NAME}  DESTINATION lib  COMPONENT dist )

and called as

>$ cmake COMPONENT=dist -P cmake_install.cmake ../
>$ make
>$ make package # CPack is configured ...

still adds also the targets NOT having COMPONENT filled (the libraries
joined by svn:externals and statically linked) into the package built.
And I cannot change CMakeLists.txt except the one in my target ...


Do you think that my original requirement is meaningful enough for feature
request to be filled?

Thank you very much,
DanT.



----- PŮVODNÍ ZPRÁVA -----
Od: "Tyler Roscoe" <[hidden email]>
Komu: [hidden email]
Předmět: Re: [CMake] Conditional install
Datum: 27.7.2009 - 17:05:24

> On Mon, Jul 27, 2009 at 04:19:48PM +0200, [hidden email]
> wrote:
> > When 'make' is called, both libraries are built and
> > then STATICALLY linked
> > > to the application - works perfectly.
> >
> > However, when 'make install' is called, the libraries
> > are installed as
> > > well (right, they contain INSTALL() definition ...)
> > >
> > What I need is to tell to CMake NOT to install the
> > libraries (they are
> > >
> > separate projects and it is not necessary to publish
> > them together with
> > > the binary). I mean something like EXCLUDE_FROM_ALL
> > but in form of
> > > EXCLUDE_FROM_INSTALL :-)
>
> Maybe the COMPONENT argument to install() can help
> you?
>
> Otherwise, maybe only define install() rules for your
> components if
> there is no top-level target that will end up doing
> the work?
>
> if (NOT TARGET myExe)
> install(myLib1 ...)
> install(myLib2 ...)
> endif ()
>
>
> tyler



_______________________________________________
Powered by 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:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Conditional install

Tyler Roscoe
On Tue, Aug 11, 2009 at 11:37:54PM +0200, [hidden email] wrote:
> >$ cmake COMPONENT=dist -P cmake_install.cmake ../

You're missing a -D before COMPONENT. Not sure if that's the cause of
all your problems but it's a good first step.

tyler
_______________________________________________
Powered by 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:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Conditional install

Eric Noulard
In reply to this post by rozelak
2009/8/11  <[hidden email]>:

> Hallo,
>
> thank you for your reply. I have tried to set the COMPONENT in the INSTALL()
> command, but it did not lead to the expected result. The install command
> I changed to (ONLY for the target I want to install, inspired by http://www.cmake.org/pipermail/cmake/2006-October/011362.html):
>
> INSTALL(TARGETS ${LIB_NAME}  DESTINATION lib  COMPONENT dist )
>
> and called as
>
>>$ cmake COMPONENT=dist -P cmake_install.cmake ../

This line is doing an installation (look at the output).

>>$ make

Then you build the software, strange enough to build AFTER installing.

>>$ make package # CPack is configured ...

Then you re-install through CPack and run cpack for building the package.

The first command line "cmake -DCOMPONENT=dist ..." and
the last one "make package" are unrelated.

You should read that:
http://www.vtk.org/Wiki/CMake:Component_Install_With_CPack

> still adds also the targets NOT having COMPONENT filled (the libraries
> joined by svn:externals and statically linked) into the package built.
> And I cannot change CMakeLists.txt except the one in my target ...

OK but as far as I know
it is not enough to use COMPONENT and get it work with CPack.
You should:
   1) tell CPACK you want component installer using
      set(CPACK_COMPONENTS_ALL ....)

   2) use a CPack generator that do support COMPONENT installer
      not ALL but a few CPack generator do support COMPONENT.

For example DEB and RPM don't:
http://public.kitware.com/Bug/view.php?id=7645
NSIS does.
TGZ, ZIP ==> I don't know.

What CPack generator are you using? ZIP, TGZ, NSIS, RPM, DEB ??

> Do you think that my original requirement is meaningful enough for feature
> request to be filled?

Yes I think it is but may be you are "only" lacking the COMPONENT
install for you target CPack generator.

>
> Thank you very much,
> DanT.




--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
Powered by 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:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Conditional install

rozelak
In reply to this post by Tyler Roscoe
Thank you! I have overlooked the -D. I am sorry for this useless message
...

----- PŮVODNÍ ZPRÁVA -----
Od: "Tyler Roscoe" <[hidden email]>
Komu: [hidden email]
Předmět: Re: [CMake] Conditional install
Datum: 11.8.2009 - 23:45:06

> On Tue, Aug 11, 2009 at 11:37:54PM +0200, [hidden email]
> wrote:
> > >$ cmake COMPONENT=dist -P cmake_install.cmake ../
> > >
> You're missing a -D before COMPONENT. Not sure if that's
> the cause of
> all your problems but it's a good first step.
>
> tyler


_______________________________________________
Powered by 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:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Conditional install

rozelak
In reply to this post by Eric Noulard
Hallo, thank you very much.
Of course, the correct sequence (alternative to 'make install') is

cmake OPTIONS path_to_CMakeLists_dir
make
cmake -D COMPONENT=dist -P cmake_install.cmake path_to_CMakeLists_dir

Now it is working for the installation.
Also thank you for the links, they are very usefull ...


> For example DEB and RPM don't:
> http://public.kitware.com/Bug/view.php?id=7645
> NSIS does.
> TGZ, ZIP ==> I don't know.
>
> What CPack generator are you using? ZIP, TGZ, NSIS,
> RPM, DEB ??

Actually, I need RPM and DEB :-(.

>
> > Do you think that my original requirement is meaningful
> > enough for feature request to be filled?
>
> Yes I think it is but may be you are "only" lacking
> the COMPONENT install for you target CPack generator.

I just thought about kind of reverse approach - to configure
what NOT TO do, and use the standard approach (make install,
make package) then; the specification of what to do in some
circumstances (using the COMPONENT) is also OK, but you must
always think twice before you start an action (install, for
example), even if you just want to a kind of 'standard' action
like install, or package (well, I mean in 'simple' cases, which
the mine is). By no means I wanted to say that
COMPONET is bad - as I read it is very powerfull ...

Thank you,
DanT.

_______________________________________________
Powered by 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:
http://www.cmake.org/mailman/listinfo/cmake