Skip to content

Commit ae315ee

Browse files
authored
added win32 to cmake + examples (#5855)
1 parent dcb0ca5 commit ae315ee

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

CMakeOptions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if(EMSCRIPTEN)
66
# When configuring web builds with "emcmake cmake -B build -S .", set PLATFORM to Web by default
77
SET(PLATFORM Web CACHE STRING "Platform to build for.")
88
endif()
9-
enum_option(PLATFORM "Desktop;Web;WebRGFW;Android;Raspberry Pi;DRM;SDL;RGFW;Memory" "Platform to build for.")
9+
enum_option(PLATFORM "Desktop;Win32;Web;WebRGFW;Android;Raspberry Pi;DRM;SDL;RGFW;Memory" "Platform to build for.")
1010

1111
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0;Software" "Force a specific OpenGL Version?")
1212

cmake/LibraryConfigurations.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ if (${PLATFORM} STREQUAL "Desktop")
9191
endif ()
9292
endif ()
9393

94+
elseif (${PLATFORM} STREQUAL "Win32")
95+
if ((NOT WIN32) AND (NOT CMAKE_C_COMPILER MATCHES "mingw|mingw32|mingw64"))
96+
message(FATAL_ERROR "Win32 platform requires Windows or a cross compiler.")
97+
endif ()
98+
99+
set(PLATFORM_CPP "PLATFORM_DESKTOP_WIN32")
100+
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
101+
102+
if (${OPENGL_VERSION} MATCHES "Software")
103+
set(GRAPHICS "GRAPHICS_API_OPENGL_SOFTWARE")
104+
endif ()
105+
106+
find_package(OpenGL QUIET)
107+
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
108+
94109
elseif (${PLATFORM} STREQUAL "Web")
95110
set(PLATFORM_CPP "PLATFORM_WEB")
96111
if(NOT GRAPHICS)

examples/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# - Linux (X11 desktop mode)
2121
# - macOS/OSX (x64, arm64 (not tested))
2222
# - Others (not tested)
23+
# > PLATFORM_DESKTOP_WIN32 (native Win32):
24+
# - Windows (Win32, Win64)
2325
# > PLATFORM_WEB_RGFW:
2426
# - HTML5 (WebAssembly)
2527
# > PLATFORM_WEB:
@@ -794,6 +796,23 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
794796
rm -f *.o
795797
endif
796798
endif
799+
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_WIN32)
800+
ifeq ($(PLATFORM_OS),WINDOWS)
801+
del *.o *.exe /s
802+
endif
803+
ifeq ($(PLATFORM_OS),BSD)
804+
find . -type f -perm -ugo+x -delete
805+
rm -fv *.o
806+
endif
807+
ifeq ($(PLATFORM_OS),LINUX)
808+
find . -type f -executable -delete
809+
rm -fv *.o
810+
endif
811+
ifeq ($(PLATFORM_OS),OSX)
812+
find . -type f -perm +ugo+x -delete
813+
rm -f *.o
814+
endif
815+
endif
797816
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
798817
find . -type f -executable -delete
799818
rm -fv *.o

0 commit comments

Comments
 (0)