[CMake] EXECUTE_PROCESS too good at running programs

David Cole david.cole at kitware.com
Fri Jul 21 09:06:16 EDT 2006


If you have the MSYS tools in your Windows system path and you can run 
makeinfo from a Windows "cmd" prompt then it should also be able to work 
from Visual Studio. If you click on "Start > Run" and type "cmd" and hit 
enter, can you run makeinfo from that "raw Windows cmd prompt"?

The flaw here is in the mismatch between Visual Studio's handling of the 
PATH and your expectation that it should be in sync with your actual 
current PATH env value. VS copies the PATH at Visual Studio install time 
and *never* updates it again except by user direction...

You can try adding "E:\msys\1.0\bin" to the end of the list of Visual 
Studio paths under "Tools > Options > Projects > VC++ Directories > 
Win32 / Executable Files" -- what you'll see in there is a list of VS 
directories first, followed by a snapshot copy of the PATH from when you 
installed VS.

Really, VS is just helping you out... You just didn't know you preferred 
"stability" over "up-to-date-ness"... :-)

HTH,
David


Brandon J. Van Every wrote:

> 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
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list