[CMake] BUILD_COMMAND having a hard time getting usable command lines

David Cole david.cole at kitware.com
Mon Nov 28 08:48:44 EST 2011


On Mon, Nov 28, 2011 at 5:05 AM, J Decker <d3ck0r at gmail.com> wrote:
> On Sun, Nov 27, 2011 at 8:30 AM, Michael Hertling <mhertling at online.de> wrote:
>> On 11/26/2011 07:14 PM, J Decker wrote:
>>> Earlier I wondered if there was a way to stop recusive invocation of a
>>> build command in a cmake script - I found something like a solution;
>>> when I run the command, set an environment variable and don't run the
>>> command if that environment variable is set... But...
>>>
>>> If I specify 'TARGET' in BUILD_COMMAND, then it gets extra quotes
>>> around it, which make it impossible to pass to execute_process.  Also
>>> why doesn't cmake-gui run certain commands?
>>>
>>> ------example - probably incomplete -----------
>>>
>>> PROJECT( whatever )
>>>   build_command( GENERATOR_BUILD_COMMAND CONFIGURATION
>>> ${CMAKE_BUILD_TYPE} PROJECT_NAME ${PROJECT_NAME} TARGET all )
>>>   message( "build command:${GENERATOR_BUILD_COMMAND}" )
>>>
>>> --------- output  -------
>>>
>>> build command:e:/tools/unix/mingw/bin/mingw32-make.exe -i "all"
>>> mingw32-make.exe: *** No rule to make target `"all"'.  Stop.
>>
>> What happens if you omit the TARGET clause in BUILD_COMMAND()?
>> Target "all" should be the default when nothing is specified.
>
> yes, but then how do I specify 'install' or 'package' targets?
>
>>
>>> ---end output, begin explanation--------
>>>
>>> In order to get BUILD_COMMAND output to work at all I have to
>>>
>>>     STRING( REPLACE "\ " ";" GENERATOR_BUILD_COMMAND
>>> ${GENERATOR_BUILD_COMMAND} )
>>
>> AFAIK, that's exactly the job of SEPARATE_ARGUMENTS().
>
> ahh excellent - read through the docs like 3 times and missed that
>
>>
>>> which replaces the spaces in the command with semicolons, so it looks
>>> like seperate commands for
>>>
>>>       EXECUTE_PROCESS(COMMAND ${GENERATOR_BUILD_COMMAND}
>>> WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
>>>
>>>  and in cmake-gui the output looks something like
>>>
>>> ---
>>> build command:e:/tools/unix/mingw/bin/mingw32-make.exe -i "all"
>>> Executing command... (output just before Execute_process)
>>> Configuring done
>>> ---
>>>   but the command is never actually executed?  I go out to a command
>>> line and type cmake . and the build goes.
>>
>> I can confirm this, but if I understand correctly, you are trying
>> to build the project while it still undergoes its configuration, in
>> particular before the generation step has finished. If so, wouldn't
>> you expect quite strange behaviors? Could you provide a small and
>> self-contained example which demonstrates what you intend to do?
>
> Uhmm I'll work on that - what I have works, except not in the gui....
> works fine to type cmake . - which generates as the first thing in the
> makefiles anyway.    Had to use environment variables to lockout
> re-executing the build.
>
>>
>> Regards,
>>
>> Michael
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>

This is a completely unexpected way of using CMake. (From us CMake
developers' perspectives...)

I would not rely on this remaining working in the future.

Configure first, and then build as a separate step. Or use
ExternalProject. Or use a cmake -P script to call "cmake ." for
configuring first, and then "cmake --build ." to build.

Trying to build the project from the configure step is asking for
trouble, if you ask me....


2 cents,
David


More information about the CMake mailing list