[CMake] INSTALL and Up-to-date problem

Michael Hertling mhertling at online.de
Wed Aug 24 06:51:05 EDT 2011


On 08/24/2011 11:00 AM, Florian Stinglmayr wrote:
> Hello List!
> 
> I have a rather unusual setup of graphic files:
> 
> someexe/gfx/
> -- *.png
> -- variant1
> -- -- subvariant1
> -- -- -- *.png
> -- variant1
> -- -- subvariant2
> -- -- --*.png
> -- variant2
> etc.
> 
> So I have a general graphics folder, and for specific variants of the
> software -- and its sub variants -- specific folders containing only a
> few graphics that differ in that very specific variant. Due to space
> restrictions on the target hardware, we currently copy the specific
> graphics (e.g. those in variant1/subvariant2) over the generic ones we
> install first. File names are the same, say you may have a generic
> "background1.png", and in a sub variant you have a specific
> "background1.png" that differs somehow (be it dimensions, colours
> etc.). I mirrored this behaviour in cmake like this:
> 
> # Generic ones
> FILE(GLOB GFX1 "${TARGET}/gfx/*.*")
> # Specific ones
> FILE(GLOB GFX2 "${TARGET}/gfx/${VARIANT}/${SUBVARIANT}/*.*")
> 
> INSTALL(FILES ${GFX1} ${GFX2}
>              DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET}/gfx")
> 
> Now what happens: cmake installs the generic files, and when it
> supposed to install the specific ones it says "Up-to-date:".
> 
> I have checked, both ${VARIANT} and ${SUBVARIANT} are properly set.
> I have also checked: cmake installs only the generic ones.
> 
> Is there anyway to force installation of certain specific files,
> regardless if cmake things they are "Up-to-date"?

make install CMAKE_INSTALL_ALWAYS=1

> Or should I just reverse installation order, so cmake says on the
> generic ones that they are "Up-to-date"?

This might help also, but a more CMake-like solution, IMO,
are appropriately set up installation components, e.g.:

INSTALL(FILES ... DESTINATION ... COMPONENT basic)
INSTALL(FILES ... DESTINATION ... COMPONENT generic)
INSTALL(FILES ... DESTINATION ... COMPONENT var1subvar1)
INSTALL(FILES ... DESTINATION ... COMPONENT var1subvar2)
INSTALL(FILES ... DESTINATION ... COMPONENT var2)

ADD_CUSTOM_TARGET(install.basic ${CMAKE_COMMAND}
    -DCOMPONENT=basic
    -P cmake_install.cmake)
ADD_CUSTOM_TARGET(install.generic ${CMAKE_COMMAND}
    -DCOMPONENT=generic
    -P cmake_install.cmake)
ADD_CUSTOM_TARGET(install.var1subvar1 ${CMAKE_COMMAND}
    -DCOMPONENT=var1subvar1
    -P cmake_install.cmake)
ADD_CUSTOM_TARGET(install.var1subvar2 ${CMAKE_COMMAND}
    -DCOMPONENT=var1subvar2
    -P cmake_install.cmake)
ADD_CUSTOM_TARGET(install.var2 ${CMAKE_COMMAND}
    -DCOMPONENT=var2
    -P cmake_install.cmake)

ADD_DEPENDENCIES(generic basic)
ADD_DEPENDENCIES(var1subvar1 basic)
ADD_DEPENDENCIES(var1subvar2 basic)
ADD_DEPENDENCIES(var2 basic)

In this way, you can say, e.g., "make install.var1subvar2" to install
the basic set of files along with the var1subvar2's one but excluding
the generic set. Thus, you have fine-grained control which files are
installed without encountering any files twice, provided the
installation components are set up properly.

Regards,

Michael


More information about the CMake mailing list