Discussion:
[cmake-developers] execute_process on windows uses CreateProcess
Mathieu Westphal
2018-04-04 07:30:49 UTC
Permalink
Hello CMake developpers.

We are using execute_process in some of our tests for a Qt based
application (ParaView)
However, on windows, the GUI does not show up and that caused some problems
for rendering.

We have investigated the problem, and it looks like execute_process on
windows is based on CreateProcess [1], But CreateProcess cannot interact
directly with the user desktop as a GUI would need.
It has to do with permissions and system environnement, see the relevant
discussions [2], [3] and [4].

So here is my question :
Is there a way, using cmake, to start a gui command on windows and have the
gui shows up ?
If not, is this intended ? Could we have this feature ?

Thanks for any hindsight !

Best,

Mathieu Westphal

[1] :
https://github.com/Kitware/KWStyle/blob/c541ae8f81d7ca739b3c03138d430cb3f41ed1c6/Utilities/KWSys/ProcessWin32.c#L1844

[2] :
https://social.msdn.microsoft.com/Forums/vstudio/en-US/24cd0f16-c5c7-4574-ac27-8e785bdf6bad/createprocess-creates-the-new-process-but-the-gui-is-not-displayed?forum=vcgeneral

[3] :
https://stackoverflow.com/questions/948417/how-to-launch-a-gui-program-in-a-windows-service?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

[4] :
https://stackoverflow.com/questions/267838/how-can-a-windows-service-execute-a-gui-application
Brad King
2018-04-04 13:28:05 UTC
Permalink
Post by Mathieu Westphal
Is there a way, using cmake, to start a gui command on windows
and have the gui shows up ?
```
execute_process(COMMAND cmd /c notepad)
```
Post by Mathieu Westphal
If not, is this intended?
Yes. Otherwise console windows appear for everything.

CreateProcessW is *the* way to create a process on Windows.
It has flags to control whether a window is shown, and we
intentionally set them to not show the window.
Post by Mathieu Westphal
Could we have this feature ?
The `cmd /c` workaround should be sufficient, but it wouldn't be
hard to add an option to the execute_process command to allow
the window to be shown.

-Brad
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers
Loading...