[Cmake] Comments, questions from my first CMake'd app

Ian Main ian-cmake at stemwinder.org
Tue Mar 18 18:22:20 EST 2003


On Tue, Mar 18, 2003 at 05:44:56PM -0500, Brad King wrote:
> > Use INSTALL_PROGRAM(/bin roy-config).
> > > INSTALL_FILES of course installs as mode 644, and I can't get
> > > INSTALL_PROGRAMS to install it.
> 
> I just tried this, and it looks like when INSTALL_PROGRAMS sees only one
> argument, it treats it as a regular expression to match a bunch of
> programs in a source tree.  The INSTALL_FILES provides a "FILES" option to
> allow an explicit set of files to be listed, but INSTALL_PROGRAMS does not
> currently have this.  As a hack, you can trick CMake into doing the right
> thing by using this work-around:
> 
> INSTALL_PROGRAMS(/bin roy-config roy-config)

ah! yes, that works.

> It will install the file twice, but at least the right result will be
> achieved.  This should be necessary only for configured scripts.
> 
> BTW, some CMake projects provide a pair of files that can be sourced by
> CMake to load the settings.  VTK (www.vtk.org) is an example of such a
> project.  It is slightly complicated to setup such a pair correctly, but
> makes it very easy to use your project from another CMake project.
> 
> In your case, the files would be named "ROYConfig.cmake" and something
> like "UseROY.cmake".  They would be generated by your cmake listfiles as
> part of ROY's build.  Other CMake projects could then do the following to
> load ROY's settings:
> 
> PROJECT(FOO)
> FIND_PACKAGE(ROY)
> IF(ROY_FOUND)
>   INCLUDE(${ROY_USE_FILE})
>   # Build components of this project needing ROY.
> ENDIF(ROY_FOUND)
> 
> The person running CMake on project FOO would need to set only one cache
> entry called "ROY_DIR" to the location of ROYConfig.cmake.  Once set, the
> FIND_PACKAGE command will source ROYConfig.cmake, which will setup the
> location of other files.  The ROY_USE_FILE variable would point to the
> location of the UseROY.cmake which would setup library dependencies,
> include directories, etc.

Hmm, yes, we do a very similar thing with auto*, supplying an m4 file 
that can be used to locate the package.  It actually ends up using the
configuration binary (eg roy-config) to help it find the package.  This is
good cause then you can find the prefix of the software anywhere in the
users path (at least on unix).  Heck, you could easily use roy-config
to tell it where to find ROY_DIR.

I will likely do that, but not for a few days.  I want to get this working
and then try see what my colleagues think before going much further :)
Most I know are pretty fed up with auto* though, so I think it shouldn't
be too hard a sell.

I think CMake could be poised to take on auto* now.  I know most
people who use it really don't like it.  Features like that package 
inclusion are nice too.  It would be nice if that could be standardised
somehow in an easy to use manner.  Perhaps a standard location for saving
the UseFoo.cmake files?  Finding other software packages has always been
one of the hardest parts of builds (once the linking etc is solved).

Hmm, maybe ${CMAKE_ROOT}/Packages or something?  Probably just needs to
be documented so everyone knows to use it.  Anyway, just a thought.

    Ian




More information about the CMake mailing list