[CMake] Export environment variables in generated Makefile

Taylor Braun-Jones taylor at braun-jones.org
Sat May 16 11:44:32 EDT 2015


Here's a little more context to help understand the use case:

I'm using the BullseyeCoverage as a compiler interceptor. So I have

CMAKE_CXX_COMPILER=/opt/bullseye/bin/g++

Which is symlink that looks like this:

/opt
└── bullseye
    └── bin
        ├── covc
        └── g++ -> covc

covc is the BullseyeCoverage compiler interceptor that injects the code
coverage instrumentation before invoking the real /usr/bin/g++ compiler. So
what I really want is for covc to see the environment variables I
mentioned. There are also some other BullseyeCoverage tools that get
invoked via custom CMake targets that need to see these environment
variables as well.

What I'm hoping exists is a way for me to configure CMake to produce a
Makefile (or build.ninja ...) that exports an environment variable before
executing the build steps for any target. Or just for certain targets, but
for the sake of simplicity, I'd prefer to just export the environment
variable for any target and not worry about polluting the environment for
targets that don't need/care about the special environment variables.

Thanks again,
Taylor

On Fri, May 15, 2015 at 11:48 AM, Taylor Braun-Jones <taylor at braun-jones.org
> wrote:

> Is it possible for CMake to generate a Makefile that exports environment
> variables whenever a target is executed? I want all invocations of gcc to
> see the environment variables COVFILE=xxx and COVSRCDIR=xxx
>
> Thanks,
> Taylor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150516/d1884594/attachment.html>


More information about the CMake mailing list