Discussion:
[CMake] Conditional install
r***@volny.cz
2009-07-27 14:19:48 UTC
Permalink
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
Tyler Roscoe
2009-07-27 15:05:24 UTC
Permalink
Post by r***@volny.cz
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
r***@volny.cz
2009-08-11 21:37:54 UTC
Permalink
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" <***@cryptio.net>
Komu: ***@volny.cz
Předmět: Re: [CMake] Conditional install
Datum: 27.7.2009 - 17:05:24
Post by r***@volny.cz
When 'make' is called, both libraries are built and
then STATICALLY linked
Post by r***@volny.cz
to the application - works perfectly.
However, when 'make install' is called, the libraries
are installed as
Post by r***@volny.cz
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
Post by r***@volny.cz
the binary). I mean something like EXCLUDE_FROM_ALL
but in form of
Post by r***@volny.cz
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
Tyler Roscoe
2009-08-11 21:45:06 UTC
Permalink
$ 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
r***@volny.cz
2009-08-12 12:45:44 UTC
Permalink
Thank you! I have overlooked the -D. I am sorry for this useless message
...

----- PŮVODNÍ ZPRÁVA -----
Od: "Tyler Roscoe" <***@cryptio.net>
Komu: ***@volny.cz
Předmět: Re: [CMake] Conditional install
Datum: 11.8.2009 - 23:45:06
Post by Tyler Roscoe
$ 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
Eric Noulard
2009-08-12 07:20:07 UTC
Permalink
Post by r***@volny.cz
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
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).
Post by r***@volny.cz
$ make
Then you build the software, strange enough to build AFTER installing.
Post by r***@volny.cz
$ 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
Post by r***@volny.cz
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 ??
Post by r***@volny.cz
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.
Post by r***@volny.cz
Thank you very much,
DanT.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
r***@volny.cz
2009-08-12 13:30:18 UTC
Permalink
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 ...
Post by Eric Noulard
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 :-(.
Post by Eric Noulard
Post by r***@volny.cz
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.

Continue reading on narkive:
Loading...