Skip to content

Commit

Permalink
Polish MinGW integration: add toolchain files, CI checks
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Jan 26, 2023
1 parent 41b9f14 commit 268ec35
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 2 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/MinGW.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: MinGW

on:
push:
pull_request:


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Checkout submodules
run: git submodule update --init --recursive

- name: Install MinGW
run: sudo apt-get update && sudo apt-get install -y mingw-w64

- name: Build x86_64
run: |
mkdir build_x86_64
cd build_x86_64
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw_x86_64.cmake -DHELLOIMGUI_WITH_GLFW=ON
make -j 4
- name: Build i686
run: |
mkdir build_i686
cd build_i686
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw_i686.cmake -DHELLOIMGUI_WITH_GLFW=ON
make -j 4
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ option(HELLOIMGUI_WIN32_EXECUTABLE "Under windows, hello_imgui_add_app will crea
#------------------------------------------------------------------------------
# Options / Backend selection
#------------------------------------------------------------------------------

# Backend selection with automatic backend compilation
# (if you set any of those options, the corresponding backend will be automatically downloaded at build time)
option(HELLOIMGUI_WITH_GLFW "Add GLFW+OpenGl3 support (glfw will be automatically compiled via ExternalProject_Add)" OFF)
Expand Down Expand Up @@ -80,6 +81,7 @@ endif()
option(HELLOIMGUI_USE_GLAD "Use Glad OpenGl loader" ${need_opengl_loader})



###############################################################################
# End of options
###############################################################################
Expand Down
3 changes: 3 additions & 0 deletions cmake/mingw_i686.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
3 changes: 3 additions & 0 deletions cmake/mingw_x86_64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
2 changes: 1 addition & 1 deletion hello_imgui_cmake/hello_imgui_add_app.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function(hello_imgui_add_app)
if (WIN32 AND HELLOIMGUI_WIN32_EXECUTABLE)
# Make this an app without console, and force it to use main() as the entry point, not WinMain()
# TODO: Use WinMain instead, this hack risks undefined behaviour: https://stackoverflow.com/a/72033725/7753444
if (CMAKE_CXX_COMPILER_ID MATCHES GNU) # If MinGW
if (MINGW)
target_link_options(${app_name} PRIVATE -Wl,--subsystem,windows,--entry,mainCRTStartup)
else() # If MSVC
target_link_options(${app_name} PRIVATE /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifdef CreateWindow
#undef CreateWindow
#endif
#include "winuser.h"
#endif

#include <cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

// Adapted from imgui/backends/imgui_impl_win32.cpp
#include "imgui.h"
#include "Windows.h"
#ifndef __MINGW32__
#include <Windows.h>
#else
#include <windows.h>
#endif

namespace HelloImGui
{
Expand Down

0 comments on commit 268ec35

Please sign in to comment.