[CMake] EXECUTE_PROCESS too good at running programs

Brandon J. Van Every bvanevery at gmail.com
Thu Jul 20 21:36:29 EDT 2006


I'm using CMake 2.4.2 and using the Visual Studio .NET 2003 generator.  
When I do
FIND_PROGRAM(MAKEINFO_EXE NAMES makeinfo)
it picks up my MSYS makeinfo, because I have my MSYS tools in my Windows 
system path.  The exact filename found, as reported by CMakeCache.txt, is

MAKEINFO_EXE:FILEPATH=E:/msys/1.0/bin/makeinfo

Most of the MSYS tools have .exe suffixes and will run under a plain 
Windows command prompt.  Some, however, do not have .exe suffixes and 
are not meant to run outside of MSYS.  Such is makeinfo.  When I open 
makeinfo under a text editor, I see that it is some kind of binary, and 
it has a string near the top of it that says, "This program cannot be 
run in DOS mode."

EXECUTE_PROCESS proves to be exceptionally clever at getting makeinfo to 
run.  Too clever.  Somehow, it gets it to run, and returns a success 
code.  Under a VS71 generator, it should be flunking it.  Because it 
certainly doesn't work in the resultant VS71 .sln file, which presumably 
uses a 'DOS' mode to execute custom targets.

My mighty CMakeLists.txt:

FIND_PROGRAM(MAKEINFO_EXE NAMES makeinfo)
IF(MAKEINFO_EXE)

  MESSAGE("Testing whether makeinfo returns error codes.")
  EXECUTE_PROCESS(COMMAND ${MAKEINFO_EXE} --idiot
    RESULT_VARIABLE MAKEINFO_FAILED)
  IF(MAKEINFO_FAILED)
    MESSAGE("makeinfo returns an error code when given bogus arguments.")
  ELSE(MAKEINFO_FAILED)
    MESSAGE("makeinfo returns success even with bogus arguments.")
  ENDIF(MAKEINFO_FAILED)

  MESSAGE("Testing whether makeinfo actually works.")
  EXECUTE_PROCESS(COMMAND ${MAKEINFO_EXE} --version
    RESULT_VARIABLE MAKEINFO_FAILED)
  IF(MAKEINFO_FAILED)
    MESSAGE("makeinfo does not work")
    ADD_CUSTOM_TARGET(info
      COMMAND ${CMAKE_COMMAND} -E echo makeinfo does not work)
  ELSE(MAKEINFO_FAILED)
    MESSAGE("makeinfo works")
    ADD_CUSTOM_TARGET(info
      COMMAND ${MAKEINFO_EXE} --version)
  ENDIF(MAKEINFO_FAILED)

ELSE(MAKEINFO_EXE)
  MESSAGE("makeinfo not available")
  ADD_CUSTOM_TARGET(info
    COMMAND ${CMAKE_COMMAND} -E echo makeinfo not available)
ENDIF(MAKEINFO_EXE)


My results in CMakeSetup:

Testing whether makeinfo returns error codes.
makeinfo returns an error code when given bogus arguments.
Testing whether makeinfo actually works.
makeinfo works


It fails in VS71 thusly:

------ Build started: Project: info, Configuration: Debug Win32 ------

Performing Post-Build Event...
'E:\msys\1.0\bin\makeinfo' is not recognized as an internal or external 
command,
operable program or batch file.
Project : error PRJ0019: A tool returned an error code from "Performing 
Post-Build Event..."

Build log was saved at 
"file://e:\devel\vs71\info\info.dir\Debug\BuildLog.htm"
info - 1 error(s), 0 warning(s)



Cheers,
Brandon Van Every



More information about the CMake mailing list