[CMake] local and system installs that include python and shell scripts

Yuri Timenkov yuri at timenkov.ru
Wed Jun 27 12:21:01 EDT 2012


I think it should be quite common case in KDE community, since GUI
usually have resources, but I don't know if apps can run from build
dir.

We use custom commands for these purposes, something like this:
         get_filename_component(destPath "${destName}" PATH)
         add_custom_command(OUTPUT ${destName}
                 MAIN_DEPENDENCY ${source}
                 COMMAND ${CMAKE_COMMAND} -E copy ${source} "${destPath}"
                 COMMENT "Copying file ${source}"
                 VERBATIM
                 )
(I don't remember if cmake can copy file with renaming or it's our legacy code)

If your scripts aren't attached to any target, you may create "custom"
one for them.

On build server you don't usually need this (because it uses install),
then you can control the behavior via special switches to allow
running locally from build directory.

I also suggest wrapping all such stuff into macros.
CMakeParseArguments helps significantly in writing macros with
informative and self-descriptive calls.

On Sat, Jun 23, 2012 at 1:29 AM, Ateljevich, Eli <eli at water.ca.gov> wrote:
> Hi again,
>
> My project is set up so that the compiled targets naturally get output to a
> structure that looks like a "development mode" installation:
>
> /myproj
>
>    /build
>
>       /bin
>
>       /lib
>
>       /include
>
>
>
> This is convenient for some users ... it is the sort of code people tinker
> with, and I think a lot of my users will actually want to keep it local. I
> will offer a more typical install as well.
>
>
>
> In addition, I have some python and shell scripts mixed in with my source
> code in subdirectories. These don’t naturally get moved anywhere during the
> build and I would like to do so to complete the "development installation"
> idea:
>
> /myproj
>
>    /build
>
>       /bin
>
>       /lib
>
>       /include
>
>       /scripts
>
>          something.sh
>
>          /pylib
>
>              scripts and python shared libraries
>
>
>
>
>
> How is this best done? Should I treat this as a case of “install”? In that
> case when development mode is on I would install to the local directory.
> Strangely, for 90% of the project the source and destination will be the
> same – which is what makes it seem weird. Or should I just use "command"
> with cmake -E style copying locally and only use install for the system
> install?
>
>
>
> It may be that either will work, but it seems from my last post or two that
> I don't always see the usual idioms and it could be neither of my guesses is
> a good one.
>
>
>
> Thanks,
>
> Eli
>
>
> --
>
> 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


More information about the CMake mailing list