scottyhardy / docker-wine

Docker image that includes Wine and Winetricks for running Windows applications on Linux and macOS
MIT License
886 stars 152 forks source link

cmake + MinGW Makefiles #143

Open brandonros opened 2 years ago

brandonros commented 2 years ago

Here is how I usually compile when I am on Windows:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat" # to load the necessary MSBuild and all that
cmake -A Win32 -S . -B "Win32" && cmake --build Win32 --config Debug

Would it be easy to be able to do this with docker-wine?

https://github.com/dockcross/dockcross tries to do this but it doesn't work very well.

#!/bin/bash

init_compile () {
  if [ ! -f ~/dockcross-windows-shared-x86 ]
  then
    docker run --rm dockcross/windows-shared-x86 > ~/dockcross-windows-shared-x86
    chmod +x ~/dockcross-windows-shared-x86
  fi
}

compile () {
  ~/dockcross-windows-shared-x86 bash -c 'cmake -D CMAKE_C_COMPILER="/usr/src/mxe/usr/bin/i686-w64-mingw32.shared-gcc" -D CMAKE_CXX_COMPILER="/usr/src/mxe/usr/bin/i686-w64-mingw32.shared-g++" -A Win32 -S . -B "Win32" && cmake --build Win32 --config Debug'
}

init_compile
compile
$ ./compile-ia32.sh 
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
== Using MXE wrapper: /usr/src/mxe/usr/bin/i686-w64-mingw32.shared-cmake
     - cmake version 3.20.1
     - warnings for unused CMAKE_POLICY_DEFAULT variables can be ignored
== Using MXE toolchain: /usr/src/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake
== Using MXE runresult: /usr/src/mxe/usr/share/cmake/modules/TryRunResults.cmake
== Adding "-DCMAKE_BUILD_TYPE=Release"
loading initial cache file /usr/src/mxe/usr/share/cmake/modules/TryRunResults.cmake
CMake Error at CMakeLists.txt:2 (project):
  Generator

    Unix Makefiles

  does not support platform specification, but platform

    Win32

  was specified.

-- Configuring incomplete, errors occurred!
See also "/work/Win32/CMakeFiles/CMakeOutput.log".
brandonros commented 2 years ago

https://cmake.org/cmake/help/latest/generator/MinGW%20Makefiles.html

https://github.com/jeroen/mingw-w64-docker/blob/master/i686-w64-mingw32/Dockerfile <-- 7 years old