Skip to content

Commit

Permalink
NetBSD support proposal.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Dec 5, 2020
1 parent 1297748 commit 3b8a633
Show file tree
Hide file tree
Showing 16 changed files with 513 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Expand Up @@ -149,7 +149,7 @@ endif()
# For miscellaneous files
if(SFML_OS_WINDOWS OR SFML_OS_IOS)
set(DEFAULT_INSTALL_MISC_DIR .)
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
set(DEFAULT_INSTALL_MISC_DIR share/SFML)
elseif(SFML_OS_MACOSX)
set(DEFAULT_INSTALL_MISC_DIR /usr/local/share/SFML)
Expand Down Expand Up @@ -291,7 +291,7 @@ endif()
# on Linux and BSD-like OS, install pkg-config files by default
set(SFML_INSTALL_PKGCONFIG_DEFAULT FALSE)

if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
set(SFML_INSTALL_PKGCONFIG_DEFAULT TRUE)
endif()

Expand Down
6 changes: 5 additions & 1 deletion cmake/Config.cmake
Expand Up @@ -35,6 +35,10 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "^OpenBSD$")
set(SFML_OS_OPENBSD 1)
# don't use the OpenGL ES implementation on OpenBSD
set(OPENGL_ES 0)
elseif(CMAKE_SYSTEM_NAME MATCHES "^NetBSD$")
set(SFML_OS_NETBSD 1)
# don't use the OpenGL ES implementation on NetBSD
set(OPENGL_ES 0)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
if(IOS)
set(SFML_OS_IOS 1)
Expand Down Expand Up @@ -73,7 +77,7 @@ endif()
# this could be e.g. macports on mac or msys2 on windows etc.
set(SFML_PKGCONFIG_DIR "/${CMAKE_INSTALL_LIBDIR}/pkgconfig")

if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig")
endif()

Expand Down
5 changes: 5 additions & 0 deletions include/SFML/Config.hpp
Expand Up @@ -91,6 +91,11 @@
// OpenBSD
#define SFML_SYSTEM_OPENBSD

#elif defined(__NetBSD__)

// NetBSD
#define SFML_SYSTEM_NETBSD

#else

// Unsupported UNIX system
Expand Down
2 changes: 1 addition & 1 deletion include/SFML/OpenGL.hpp
Expand Up @@ -45,7 +45,7 @@

#include <GL/gl.h>

#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD)
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD)

#if defined(SFML_OPENGL_ES)
#include <GLES/gl.h>
Expand Down
2 changes: 1 addition & 1 deletion include/SFML/Window/WindowHandle.hpp
Expand Up @@ -42,7 +42,7 @@ namespace sf
// Window handle is HWND (HWND__*) on Windows
typedef HWND__* WindowHandle;

#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD)
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD)

// Window handle is Window (unsigned long) on Unix - X11
typedef unsigned long WindowHandle;
Expand Down
11 changes: 9 additions & 2 deletions src/SFML/Window/CMakeLists.txt
Expand Up @@ -81,7 +81,7 @@ if(SFML_OS_WINDOWS)

# make sure that we use the Unicode version of the Win API functions
add_definitions(-DUNICODE -D_UNICODE)
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
set(PLATFORM_SRC
${SRCROOT}/Unix/CursorImpl.hpp
${SRCROOT}/Unix/CursorImpl.cpp
Expand Down Expand Up @@ -124,6 +124,13 @@ elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
${SRCROOT}/OpenBSD/JoystickImpl.cpp
${SRCROOT}/OpenBSD/JoystickImpl.hpp
)
elseif(SFML_OS_NETBSD)
set(PLATFORM_SRC
${PLATFORM_SRC}
${SRCROOT}/NetBSD/JoystickImpl.cpp
${SRCROOT}/NetBSD/JoystickImpl.hpp
)

endif()
source_group("unix" FILES ${PLATFORM_SRC})
elseif(SFML_OS_MACOSX)
Expand Down Expand Up @@ -243,7 +250,7 @@ endif()
target_include_directories(sfml-window PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/vulkan")

# find and setup usage for external libraries
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OPENBSD)
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
sfml_find_package(X11 INCLUDE "X11_INCLUDE_DIR" LINK "X11_X11_LIB" "X11_Xrandr_LIB" "X11_Xcursor_LIB")
target_link_libraries(sfml-window PRIVATE X11)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/SFML/Window/ClipboardImpl.hpp
Expand Up @@ -32,7 +32,7 @@

#if defined(SFML_SYSTEM_WINDOWS)
#include <SFML/Window/Win32/ClipboardImpl.hpp>
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD)
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD)
#include <SFML/Window/Unix/ClipboardImpl.hpp>
#elif defined(SFML_SYSTEM_MACOS)
#include <SFML/Window/OSX/ClipboardImpl.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/SFML/Window/CursorImpl.hpp
Expand Up @@ -34,7 +34,7 @@

#include <SFML/Window/Win32/CursorImpl.hpp>

#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD)
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD)

#include <SFML/Window/Unix/CursorImpl.hpp>

Expand Down
2 changes: 1 addition & 1 deletion src/SFML/Window/GlContext.cpp
Expand Up @@ -57,7 +57,7 @@

#endif

#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD)
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD)

#if defined(SFML_OPENGL_ES)

Expand Down
2 changes: 1 addition & 1 deletion src/SFML/Window/InputImpl.hpp
Expand Up @@ -32,7 +32,7 @@

#if defined(SFML_SYSTEM_WINDOWS)
#include <SFML/Window/Win32/InputImpl.hpp>
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD)
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD)
#include <SFML/Window/Unix/InputImpl.hpp>
#elif defined(SFML_SYSTEM_MACOS)
#include <SFML/Window/OSX/InputImpl.hpp>
Expand Down
4 changes: 4 additions & 0 deletions src/SFML/Window/JoystickImpl.hpp
Expand Up @@ -94,6 +94,10 @@ struct JoystickState

#include <SFML/Window/OpenBSD/JoystickImpl.hpp>

#elif defined(SFML_SYSTEM_NETBSD)

#include <SFML/Window/NetBSD/JoystickImpl.hpp>

#elif defined(SFML_SYSTEM_MACOS)

#include <SFML/Window/OSX/JoystickImpl.hpp>
Expand Down

0 comments on commit 3b8a633

Please sign in to comment.