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

Brad King brad.king at kitware.com
Tue Mar 18 17:44:56 EST 2003


> 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)

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.

If you are interested in getting this to work, contact me privately for
help.

-Brad




More information about the CMake mailing list