[CMake] CPack: howto change directory layout depending on the generator

Timenkov Yuri ytimenkov at gmail.com
Fri Sep 19 17:44:26 EDT 2008


On Fri, Sep 19, 2008 at 9:15 PM, Tanguy Krotoff <tkrotoff at gmail.com> wrote:

> Hi everybody
>
> I would like to change the directory layout generated by CPack given
> the generator used.
> In a way, I would like a more fine-grained control about what CPack
> generates and after reading the different docs I don't know if it is
> possible.
>
> I have a pretty complex multiplatform program with plugins, internal
> libraries... here are the different layouts I would like to achieve:

FIrst of all, there are a couple of discussions about using
CPACK_SET_DESTDIR, install prefixes and co in this list which are about same
problems: directory layout depends on generator used.
Next, cmake_install files (which contain install rules) are generated at
cmake time and it may be possible to code some variables there, which then
can be passed through cpack.

>
>
> ** NSIS:
> /app.exe
> /internal_lib1.dll
> /internal_lib2.dll
> /plugins/plugin1.dll
> /plugins/plugin2.dll
>
> ** DEB / RPM:
> /usr/bin/app
> /usr/lib/app/internal_lib1.so
> /usr/lib/app/internal_lib2.so
> /usr/lib/app/plugins/plugin1.so
> /usr/lib/app/plugins/plugin2.so
>
> ** TGZ / ZIP (same as NSIS):
> /app
> /app.sh (does a export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./app)
> /internal_lib1.so
> /internal_lib2.so
> /plugins/plugin1.so
> /plugins/plugin2.so
>
> ** If no generator is used, make install should give the same layout
> as with NSIS / TGZ / NSIS
> This way I just have to go to my build directory and run app.sh or
> app.exe directly:
> this simplifies the compile/test procedure since there is no need for
> the install step (i.e compile/install/test).
>
>
> So I have this code in my root CMakeLists.txt:
>
> if (LINUX)
>        set(INSTALL_TARGETS_DEFAULT_ARGS
>                RUNTIME DESTINATION bin
>                LIBRARY DESTINATION lib/myapp
>        )
>        set(INSTALL_PLUGINS_DEFAULT_ARGS
>                RUNTIME DESTINATION bin
>                LIBRARY DESTINATION lib/myapp/plugins
>        )
> endif
>
> if (WIN32)
>        set(INSTALL_TARGETS_DEFAULT_ARGS
>                RUNTIME DESTINATION .
>                LIBRARY DESTINATION .
>        )
>        set(INSTALL_PLUGINS_DEFAULT_ARGS
>                RUNTIME DESTINATION .
>                LIBRARY DESTINATION .
>        )
> endif
>
> As you see it does not depend on the generator invoked but on the
> platform instead
> I you would to change it to something like this:
>
> if (CPACK_GENERATOR == "DEB,RPM")
>        set(INSTALL_TARGETS_DEFAULT_ARGS
>                RUNTIME DESTINATION bin
>                LIBRARY DESTINATION lib/myapp
>        )
>        set(INSTALL_PLUGINS_DEFAULT_ARGS
>                RUNTIME DESTINATION bin
>                LIBRARY DESTINATION lib/myapp/plugins
>        )
> endif
>
> if (CPACK_GENERATOR == "TGZ,ZIP,NSIS")
>        set(INSTALL_TARGETS_DEFAULT_ARGS
>                RUNTIME DESTINATION .
>                LIBRARY DESTINATION .
>        )
>        set(INSTALL_PLUGINS_DEFAULT_ARGS
>                RUNTIME DESTINATION .
>                LIBRARY DESTINATION .
>        )
> endif
>
> if (NOT CPACK_GENERATOR)
>        set(INSTALL_TARGETS_DEFAULT_ARGS
>                RUNTIME DESTINATION .
>                LIBRARY DESTINATION .
>        )
>        set(INSTALL_PLUGINS_DEFAULT_ARGS
>                RUNTIME DESTINATION .
>                LIBRARY DESTINATION .
>        )
> endif
>
>
> Do you know if this king of things are possible?
>
> Thanks in advance,
>
> --
> Tanguy Krotoff <tkrotoff at gmail.com>
> +33 6 68 42 70 24
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080920/798bf588/attachment.htm>


More information about the CMake mailing list