4

I'm currently working from my home Windows PC on the code, that I compile on a Linux PC over an SSH connection. But since the resulting program creates a GUI, I can't really test it. Is it possible to create, besides the Linux program, a Windows exe that I can run on my home computer? Here is my CMakeLists (using QT5):

cmake_minimum_required(VERSION 2.8.11)
project(p3)

set(CMAKE_PREFIX_PATH $ENV{QT5_QMAKE_DIR})
MESSAGE(STATUS "QT5_QMAKE_DIR: " ${CMAKE_PREFIX_PATH})

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_AUTOMOC ON)

# Possibly set this to DEBUG for testing
set(CMAKE_BUILD_TYPE Release)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
#project source directories

find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)

find_package(OpenMP)
if (OPENMP_FOUND)
   message("OPENMP FOUND")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

include_directories(
  ${Qt5Widgets_INCLUDE_DIRS}
  ${Qt5Core_INCLUDE_DIRS}
  ${Qt5Gui_INCLUDE_DIRS}
)

add_definitions(${Qt5Widgets_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

if(UNIX)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

add_executable(p3
   #.cpps and .hs
)

set_property(TARGET p3 PROPERTY CXX_STANDARD 11)
target_link_libraries(p3 ${Qt5Widgets_LIBRARIES})
Alexander Shishenko
  • 940
  • 1
  • 11
  • 28
Phlipsy
  • 43
  • 6
  • 1
    Here's a question that addresses compiling for Windows on Linux; the accepted answer uses mingw, and it doesn't directly address cmake, but give it a look: https://stackoverflow.com/questions/2033997/howto-compile-for-windows-on-linux-with-gcc-g – Hatchet Jan 16 '16 at 02:39
  • 1
    Alexander's suggestion using X11 forwarding is what I use to display Linux GUI on Windows, only I use [Putty and Xming](http://www.geo.mtu.edu/geoschem/docs/putty_install.html) instead of MobaXterm. I may download it and try it out. – Paul H. Jan 16 '16 at 03:14
  • 1
    I have used Putty and Xming for a while. It was a hard time :). Seriously, they are a bit harder to set up. – Alexander Shishenko Jan 16 '16 at 03:19
  • I already use Putty, so I'll give it a shot later today. Thanks for the quick answers :) – Phlipsy Jan 16 '16 at 03:26

1 Answers1

1

You could use Linux-hosted MinGW for this, but you will have to build Qt by yourself. It is a complicated process and not all Linux applications run perfectly well on Windows.

Maybe, you can use SSH X11 forwarding with Windows-hosted SSH client with X11 support instead (MobaXterm, for example) to get application window from the server?

Alexander Shishenko
  • 940
  • 1
  • 11
  • 28