views:

23

answers:

2

I am working on something that requires some header files from a different source tree. For various reasons, I would like to keep these headers outside of my project and reference them during the make process.

I have a CMake build script that generates my makefiles, but I would like to be able to generate makefiles with references to environment variables in them, such that the generated makefile can be run like so:

HEADERS=/somewhere/on/the/filesystem make

Is this possible using CMake? Failing that, is there a way to get what I'm after using CMake only?

A: 

You can use $ENV{VARIABLE} to get the value of an environment variable, but it will only be evaluated during the cmake run and not during the make.

tibur
A: 

You should look at add_custom_command using the TARGET and PRE_LINK options.

RobertJMaynard

related questions