[CMake] ExternalProject: adding command line flags for CMAKE_MAKE_PROGRAM
Brad King
brad.king at kitware.com
Wed Jul 30 11:35:47 EDT 2014
On 07/30/2014 11:06 AM, Williams, Norman K wrote:
> I was trying to get ExternalProjects generated with the Ninja
> generator to do a better job of handling multiple CPUs and load,
> so I tried the naïve solution below.
For reference in the archives, your previous post about this was here:
CMake, Ninja generator, and ExternalProjects
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/10543
> I needed to add flags to the program named in CMAKE_MAKE_PROGRAM.
The relevant part of the ExternalProject module source is the block
that constructs the default BUILD_COMMAND when not using a Makefile
generator:
# Drive the project with "cmake --build".
get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND)
if(cmake_command)
set(cmd "${cmake_command}")
else()
set(cmd "${CMAKE_COMMAND}")
endif()
set(args --build ${binary_dir} --config ${CMAKE_CFG_INTDIR})
At build time, "cmake --build" loads the CMAKE_MAKE_PROGRAM from the
CMakeCache.txt of the build tree, at least for the Ninja generator.
When running "cmake --build" by hand one can specify additional args:
cmake --build . -- $ExtraArgs
Everything after the "--" option will be given to the native tool.
Perhaps one could add a special-case here when cmake_generator is
"Ninja" to extend the "cmake --build" command with th needed options
to ninja.
> the only alternative is to explicitly set the BUILD_COMMAND for
> every ExternalProject_add command.
That would also work with existing CMake releases, but would have
to be conditional on the generator in use.
-Brad
More information about the CMake
mailing list