[cmake-developers] CMake strips MAKEFLAGS from environment

Taylor Braun-Jones taylor at braun-jones.org
Thu May 21 10:08:53 EDT 2015


On Thu, May 21, 2015 at 9:44 AM, Ben Boeckel <ben.boeckel at kitware.com>
wrote:

> The problem with MAKEFLAGS is that `-i` also gets inherited and that is
> not acceptable to use when running things like try_compile since it
> causes false positives (e.g., detecting NEON extensions on x86). CMake
> clears it so that it has a better expectation of how things will run. Is
> there a reason you can't use a CMake cache variable to set
> `environment_build_flags` rather than the environment (since it would
> get remembered between cmake runs while the environment needs to be
> specified every time)?
>

Ya, I could definitely use a cache variable and that probably makes sense
to do here. But I'm not sure how it solves my problem. For example, with
this CMakeLists.txt:

cmake_minimum_required(VERSION 3.0)
set(environment_build_flags $ENV{MAKEFLAGS} CACHE STRING "MAKEFLAGS")
add_custom_target(echo_makeflags COMMAND echo "environment_build_flags:
${environment_build_flags}" VERBATIM)

I still just get:

$ make echo_makeflags
environment_build_flags:
Built target echo_makeflags

Taylor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150521/6ebd6b21/attachment.html>


More information about the cmake-developers mailing list