[Cmake] Set a variable to a list of filenames that match a pattern

Bill Hoffman bill . hoffman at kitware . com
Thu, 24 Jul 2003 10:13:28 -0400


At 07:03 PM 7/23/2003, Karr, David wrote:

>In the absence of a good explanation, I would probably hack
>this "feature" out of CMake before I let any of my developers
>use it.


Since this question comes up frequently,
I have created a FAQ entry for it: 
http://www . cmake . org/cgi-bin/cmakefaq . cgi?req=show&file=faq05 . 005 . htp

5.5. Why does CMake use full paths, or can I copy my build tree?

CMake uses full paths because: 

1. configured header files may have full paths in them, and moving those files without re-configuring would cause upredicatble behavior. 

2. because cmake supports out of source builds, if custom commands used relative paths to the source tree, the would not work when they are run in the build tree because the current directory would be incorrect. 

3. on Unix systems rpaths are built into executables so they can find shared libraries at run time. If the build tree is moved old executables may use the old shared libraries, and not the new ones. 

Can the build tree be copied: 

The short answer is NO. The reason is because full paths are used in CMake, see above. 

The main problem is that cmake would need to detect when the binary tree has been moved. However, cmake is not run every time a build is done. Currently (cmake 1.6.X, and cmake 1.7.x ) do not support fixing a moved binary tree. This feature may be added before 1.8. If that feature were added, it would still require cmake to be re-run by hand each time a build tree is moved. 


CMake is of course open source and you can "hack" it if you want.  
However, beware there are issues with using relative paths for part
of the system.   If you just did the source files as you suggest, the
binary files if executable output was set would still end up in the old
build tree.   Also, some of the above problems may happen.

-Bill