[CMake] EXEC_PROGRAM vs EXECUTE_PROCESS

Filipe Sousa filipe at ipb.pt
Thu Feb 9 08:34:21 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

Now that cmake has EXECUTE_PROCESS command, should we use this instead
of EXEC_PROGRAM?

I notice that both commands captures output in a different way:

EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
  ARGS -query QT_VERSION
  OUTPUT_VARIABLE output1
  RETURN_VALUE ret
  )
EXECUTE_PROCESS(
  COMMAND "${QT_QMAKE_EXECUTABLE}" -query QT_VERSION
  RESULT_VARIABLE ret
  OUTPUT_VARIABLE output2
  )

MESSAGE(STATUS "--------------")
MESSAGE(STATUS "out1=${output1}")
MESSAGE(STATUS "out2=${output2}")
MESSAGE(STATUS "--------------")

Output:
- -- --------------
- -- out1=4.1.0
- -- out2=4.1.0

- -- --------------

EXECUTE_PROCESS does not remove the last \n (\r\n on Windows) like
EXEC_PROGRAM. Is this the desired behavior for EXECUTE_PROCESS or do I
have to

IF(WIN32)
  STRING(REPLACE "\r\n" "" output2 "${output2}")
ELSE(WIN32)
  STRING(REPLACE "\n" "" output2 "${output2}")
ENDIF(WIN32)


- --
Filipe Sousa
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD60TdbQdNYqwwwCwRAh16AJ0YUgi70CjkckdHoJh5cp1vZvrAHgCeNQdW
LtMVhib8o4jeiTh8rtCq9TI=
=y0Px
-----END PGP SIGNATURE-----


More information about the CMake mailing list