[CMake] install() question

Hendrik Sattler post at hendrik-sattler.de
Fri Oct 14 12:22:21 EDT 2011


On Thu, 13 Oct 2011 12:09:41 -0500, Robert Dailey wrote:
> First of all I'm using cmake 2.8.6 and generating Visual Studio 2003
> projects with it.
>
> There is a particular project that needs to first copy its header 
> files to a
> specific directory in a specific structure. After that, all other 
> projects
> need to reference this project's source code from the installed 
> location,
> not its actual location that it was copied from.
>
> The install() command sounded perfect for this but unfortunately it 
> seems
> that the INSTALL project builds *last*. What I need is for the files 
> to be
> installed/copied FIRST, so that the other projects will succeed when 
> I build
> them.
>
> Any idea if install() can do this? I'm not really sure of the purpose 
> for
> install(), so maybe I'm approaching this wrong.

Yes. Compilation of a project should always be possible without 
polluting the system.

For other programs or libraries in the same source tree, install() is 
not the right thing.
You have several options:
a)
Copy the headers in the right structure to the build tree and use as 
include directory. This also makes your install() command easier: you 
just have to copy the directory as-is. However, you have to setup 
dependencies correctly so that changed header files (and only those) get 
copied again if they changed. If you build in-tree (source dir == build 
dir, which is not recommended), such a scheme may have problems.

b)
Is there _any_ reason to no arrange the headers in the source tree in a 
way that makes it usuable for direct inclusion?

HS



More information about the CMake mailing list