On Thu, May 21, 2015 at 8:56 AM, Brad King <[email protected]> wrote:
> What are you trying to do?
>
I'm trying to implement a workaround solution for setting environment
variables in my Makefiles at build time. So what I started with was this:
set(bullseye_environment COVFILE=${PROJECT_BINARY_DIR}/bullseye/test.cov)
add_custom_target(coverage_data
COMMAND env ${bullseye_environment}
${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} --clean-first
COMMAND env ${bullseye_environment} ${CMAKE_CTEST_COMMAND}
--output-on-failure
COMMENT "Generating test coverage data"
VERBATIM
)
Which works fine for Ninja generator. It works for Unix Makefiles too,
except that the parallelism is lost. I get errors like:
gmake[1]: warning: jobserver unavailable: using -j1. Add `+' to parent
make rule.
So I added another workound for that:
if(${CMAKE_GENERATOR} MATCHES ".* Makefiles$")
set(environment_build_flags "$ENV{MAKEFLAGS}")
endif()
add_custom_target(coverage_data
COMMAND env --unset=MAKEFLAGS ${bullseye_environment}
${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} --clean-first --
${environment_build_flags}
COMMAND env ${bullseye_environment} ${CMAKE_CTEST_COMMAND}
--output-on-failure
COMMENT "Generating test coverage data"
VERBATIM
)
Which allows the parallelism to work properly in an environment like:
export MAKEFLAGS=$(grep -i -c ^processor /proc/cpuinfo)
make coverage_data
Taylor
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers