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

J Decker d3ck0r at gmail.com
Sat Nov 26 13:14:16 EST 2011


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.

---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} )

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.


More information about the CMake mailing list