magiblot / tvision

A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.
Other
2k stars 151 forks source link

tvforms build error when cross-compiling for Windows from Linux with mingw-w64 #40

Closed electroly closed 3 years ago

electroly commented 3 years ago

image

I'm using tvision commit f5c4c359001835eee9851c9675969a03785206b6 with a fresh install of Arch Linux and mingw-w64. I see that your CI is building for Windows successfully, so this seems to be an issue cross-compiling for Windows from Linux. The name of these executables (genphone, genparts) makes me think the build process is trying to run them after building them, meaning they should have been built for the build system (Linux) and not the host system (Windows).

In traditional configure scripts there's usually the ability to specify separate build and host systems for cross-compiling. Is there a way I can do this for tvision?

I have a similar issue with tvhc, which I need to run as part of my own build. My workaround was to use Wine to execute tvhc.exe, but it would be nicer if I could build tvhc for the build system instead of the host system. Perhaps the best fix is for me to just do two tvision builds, one for Windows with TV_BUILD_EXAMPLES=OFF and one for Linux with TV_BUILD_EXAMPLES=ON. This would fix it all for me, but tvision would still be unable to cross-compile the tvforms example for anyone who wants to do that.

magiblot commented 3 years ago

Hi, Brian! Happy new year.

Can you check whether the following change to examples/tvforms/CMakeLists.txt fixes the issue?

+   if (NOT CMAKE_CROSSCOMPILING)
        add_custom_command(TARGET genparts POST_BUILD COMMAND genparts WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
        add_custom_command(TARGET genphone POST_BUILD COMMAND genphone WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+   endif()

The genparts and genphone executables generate .f32 files that can be opened with the tvforms application. I thought it would be useful to generate them during the build process so that tvforms can be used out-of-the-box. This may not have been a good idea, but anyway, it seems certain that these executables won't run if the target system is different from the host system. So the change above should prevent them from executing.

Perhaps the best fix is for me to just do two tvision builds, one for Windows with TV_BUILD_EXAMPLES=OFF and one for Linux with TV_BUILD_EXAMPLES=ON.

This would make more sense, but if it makes build times longer, you should be able to keep doing it the same way as until now.

Cheers.

electroly commented 3 years ago

Confirmed. That patch works. Thanks!

magiblot commented 3 years ago

Cool. Thanks for the report!