Skip to content

Commit

Permalink
port to NetBSD
Browse files Browse the repository at this point in the history
The NetBSD port will only work after
epezent/implot#565 is merged and Dolphin updates
to a version with the fix. In the meantime, you can apply the fix
yourself to a Dolphin checkout.
  • Loading branch information
guijan committed Apr 22, 2024
1 parent e618085 commit 9c46f9d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
29 changes: 21 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_library(FOUNDATION_LIBRARY Foundation)
find_library(IOB_LIBRARY IOBluetooth)
find_library(IOK_LIBRARY IOKit)
find_library(OPENGL_LIBRARY OpenGL)
endif()

if(ENABLE_LTO)
Expand Down Expand Up @@ -518,9 +517,26 @@ if(ENABLE_X11)
endif()
endif()

set(OpenGL_GL_PREFERENCE GLVND CACHE STRING "Linux-only: if GLVND, use the vendor-neutral GL libraries (default). If LEGACY, use the legacy ones (might be necessary to have optirun/primusrun work)")
set_property(CACHE OpenGL_GL_PREFERENCE PROPERTY STRINGS GLVND LEGACY)
find_package(OpenGL)
if(OPENGL_GL_FOUND)
add_definitions(-DHAS_OPENGL)
endif()
if(ENABLE_EGL)
find_package(EGL)
# `find_package(OpenGL OPTIONAL_COMPONENTS EGL)` is broken, the package fails
# to find OpenGL and all the components if we specify any components; it
# also breaks anyone who depends on a previously successful
# `find_package(OpenGL)` call, so we don't use it.

pkg_check_modules(EGL egl IMPORTED_TARGET)
if(EGL_FOUND)
add_library(EGL::EGL ALIAS PkgConfig::EGL)
else()
# https://code.qt.io/cgit/qt/qtbase.git/tree/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake?h=6.7.0
find_package(EGL)
endif()
if(TARGET EGL::EGL)
add_definitions(-DHAVE_EGL=1)
message(STATUS "EGL OpenGL interface enabled")
else()
Expand Down Expand Up @@ -653,11 +669,6 @@ if(ENABLE_VULKAN)
endif()
endif()

if(NOT WIN32 OR (NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")))
# OpenGL is available on all platforms except windows-arm64
add_definitions(-DHAS_OPENGL)
endif()

dolphin_find_optional_system_library(pugixml Externals/pugixml)

dolphin_find_optional_system_library_pkgconfig(ENET libenet>=1.3.18 enet::enet Externals/enet)
Expand Down Expand Up @@ -703,7 +714,9 @@ include_directories(Externals/soundtouch)
dolphin_find_optional_system_library(CUBEB Externals/cubeb)

if(NOT ANDROID)
dolphin_find_optional_system_library(LibUSB Externals/libusb)
dolphin_find_optional_system_library_pkgconfig(
LibUSB libusb-1.0 LibUSB::LibUSB Externals/libusb
)
add_definitions(-D__LIBUSB__)
endif()

Expand Down
2 changes: 1 addition & 1 deletion Externals/hidapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ else()
target_link_libraries(hidapi PRIVATE udev)
else()
target_sources(hidapi PRIVATE hidapi-src/libusb/hid.c)
target_link_libraries(hidapi PRIVATE ${LIBUSB_LIBRARIES})
target_link_libraries(hidapi PRIVATE LibUSB::LibUSB)
endif()
endif()

Expand Down
11 changes: 5 additions & 6 deletions Source/Core/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ target_sources(common PRIVATE
GL/GLExtensions/GLExtensions.h
)

if(ENABLE_EGL AND EGL_FOUND)
if(EGL_FOUND)
target_sources(common PRIVATE
GL/GLInterface/EGL.cpp
GL/GLInterface/EGL.h
Expand All @@ -272,14 +272,13 @@ if(ENABLE_EGL AND EGL_FOUND)
GL/GLInterface/EGLAndroid.cpp
GL/GLInterface/EGLAndroid.h
)
elseif(ENABLE_X11 AND X11_FOUND)
elseif(X11_FOUND)
target_sources(common PRIVATE
GL/GLInterface/EGLX11.cpp
GL/GLInterface/EGLX11.h
)
endif()
target_include_directories(common PRIVATE ${EGL_INCLUDE_DIRS})
target_link_libraries(common PUBLIC ${EGL_LIBRARIES})
target_link_libraries(common PUBLIC OpenGL::GL EGL::EGL)
endif()

if(WIN32)
Expand All @@ -299,7 +298,7 @@ elseif(HAIKU)
GL/GLInterface/BGL.h
GL/GLInterface/BGL.cpp
)
elseif(ENABLE_X11 AND X11_FOUND)
elseif(X11_FOUND)
target_sources(common PRIVATE
GL/GLX11Window.cpp
GL/GLX11Window.h
Expand All @@ -309,7 +308,7 @@ elseif(ENABLE_X11 AND X11_FOUND)

# GLX has a hard dependency on libGL.
# Make sure to link to it if using GLX.
target_link_libraries(common PUBLIC ${OPENGL_LIBRARIES})
target_link_libraries(common PUBLIC OpenGL::GL)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
Expand Down
8 changes: 0 additions & 8 deletions Source/Core/Common/StringUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
constexpr u32 CODEPAGE_SHIFT_JIS = 932;
constexpr u32 CODEPAGE_WINDOWS_1252 = 1252;
#else
#if defined(__NetBSD__)
#define LIBICONV_PLUG
#endif
#include <errno.h>
#include <iconv.h>
#include <locale.h>
Expand Down Expand Up @@ -528,13 +525,8 @@ std::string CodeTo(const char* tocode, const char* fromcode, std::basic_string_v
while (src_bytes != 0)
{
size_t const iconv_result =
#if defined(__NetBSD__)
iconv(conv_desc, reinterpret_cast<const char**>(&src_buffer), &src_bytes, &dst_buffer,
&dst_bytes);
#else
iconv(conv_desc, const_cast<char**>(reinterpret_cast<const char**>(&src_buffer)),
&src_bytes, &dst_buffer, &dst_bytes);
#endif
if ((size_t)-1 == iconv_result)
{
if (EILSEQ == errno || EINVAL == errno)
Expand Down
10 changes: 10 additions & 0 deletions Source/Core/Core/PowerPC/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
#include <string_view>
#include <utility>

// https://github.com/zserge/expr/ is a C program and sorta valid C++.
// When included in a C++ program, it's treated as a C++ code, and it may cause
// issues: <cmath> may already be included, if so, including <math.h> may
// not do anything. <math.h> is obligated to put its functions in the global
// namespace, while <cmath> may or may not. The C code we're interpreting as
// C++ won't call functions by their qualified names. The code may work anyway
// if <cmath> puts its functions in the global namespace, or if the functions
// are actually macros that expand inline, both of which are common.
// NetBSD 10.0 i386 is an exception, and we need `using` there.
using std::isnan; using std::isinf;
#include <expr.h>

#include "Common/BitUtils.h"
Expand Down

0 comments on commit 9c46f9d

Please sign in to comment.