Skip to content

Commit 9c46f9d

Browse files
committed
port to NetBSD
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.
1 parent e618085 commit 9c46f9d

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

CMakeLists.txt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
375375
find_library(FOUNDATION_LIBRARY Foundation)
376376
find_library(IOB_LIBRARY IOBluetooth)
377377
find_library(IOK_LIBRARY IOKit)
378-
find_library(OPENGL_LIBRARY OpenGL)
379378
endif()
380379

381380
if(ENABLE_LTO)
@@ -518,9 +517,26 @@ if(ENABLE_X11)
518517
endif()
519518
endif()
520519

520+
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)")
521+
set_property(CACHE OpenGL_GL_PREFERENCE PROPERTY STRINGS GLVND LEGACY)
522+
find_package(OpenGL)
523+
if(OPENGL_GL_FOUND)
524+
add_definitions(-DHAS_OPENGL)
525+
endif()
521526
if(ENABLE_EGL)
522-
find_package(EGL)
527+
# `find_package(OpenGL OPTIONAL_COMPONENTS EGL)` is broken, the package fails
528+
# to find OpenGL and all the components if we specify any components; it
529+
# also breaks anyone who depends on a previously successful
530+
# `find_package(OpenGL)` call, so we don't use it.
531+
532+
pkg_check_modules(EGL egl IMPORTED_TARGET)
523533
if(EGL_FOUND)
534+
add_library(EGL::EGL ALIAS PkgConfig::EGL)
535+
else()
536+
# https://code.qt.io/cgit/qt/qtbase.git/tree/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake?h=6.7.0
537+
find_package(EGL)
538+
endif()
539+
if(TARGET EGL::EGL)
524540
add_definitions(-DHAVE_EGL=1)
525541
message(STATUS "EGL OpenGL interface enabled")
526542
else()
@@ -653,11 +669,6 @@ if(ENABLE_VULKAN)
653669
endif()
654670
endif()
655671

656-
if(NOT WIN32 OR (NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")))
657-
# OpenGL is available on all platforms except windows-arm64
658-
add_definitions(-DHAS_OPENGL)
659-
endif()
660-
661672
dolphin_find_optional_system_library(pugixml Externals/pugixml)
662673

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

705716
if(NOT ANDROID)
706-
dolphin_find_optional_system_library(LibUSB Externals/libusb)
717+
dolphin_find_optional_system_library_pkgconfig(
718+
LibUSB libusb-1.0 LibUSB::LibUSB Externals/libusb
719+
)
707720
add_definitions(-D__LIBUSB__)
708721
endif()
709722

Externals/hidapi/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ else()
1515
target_link_libraries(hidapi PRIVATE udev)
1616
else()
1717
target_sources(hidapi PRIVATE hidapi-src/libusb/hid.c)
18-
target_link_libraries(hidapi PRIVATE ${LIBUSB_LIBRARIES})
18+
target_link_libraries(hidapi PRIVATE LibUSB::LibUSB)
1919
endif()
2020
endif()
2121

Source/Core/Common/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ target_sources(common PRIVATE
262262
GL/GLExtensions/GLExtensions.h
263263
)
264264

265-
if(ENABLE_EGL AND EGL_FOUND)
265+
if(EGL_FOUND)
266266
target_sources(common PRIVATE
267267
GL/GLInterface/EGL.cpp
268268
GL/GLInterface/EGL.h
@@ -272,14 +272,13 @@ if(ENABLE_EGL AND EGL_FOUND)
272272
GL/GLInterface/EGLAndroid.cpp
273273
GL/GLInterface/EGLAndroid.h
274274
)
275-
elseif(ENABLE_X11 AND X11_FOUND)
275+
elseif(X11_FOUND)
276276
target_sources(common PRIVATE
277277
GL/GLInterface/EGLX11.cpp
278278
GL/GLInterface/EGLX11.h
279279
)
280280
endif()
281-
target_include_directories(common PRIVATE ${EGL_INCLUDE_DIRS})
282-
target_link_libraries(common PUBLIC ${EGL_LIBRARIES})
281+
target_link_libraries(common PUBLIC OpenGL::GL EGL::EGL)
283282
endif()
284283

285284
if(WIN32)
@@ -299,7 +298,7 @@ elseif(HAIKU)
299298
GL/GLInterface/BGL.h
300299
GL/GLInterface/BGL.cpp
301300
)
302-
elseif(ENABLE_X11 AND X11_FOUND)
301+
elseif(X11_FOUND)
303302
target_sources(common PRIVATE
304303
GL/GLX11Window.cpp
305304
GL/GLX11Window.h
@@ -309,7 +308,7 @@ elseif(ENABLE_X11 AND X11_FOUND)
309308

310309
# GLX has a hard dependency on libGL.
311310
# Make sure to link to it if using GLX.
312-
target_link_libraries(common PUBLIC ${OPENGL_LIBRARIES})
311+
target_link_libraries(common PUBLIC OpenGL::GL)
313312
endif()
314313

315314
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")

Source/Core/Common/StringUtil.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
constexpr u32 CODEPAGE_SHIFT_JIS = 932;
3636
constexpr u32 CODEPAGE_WINDOWS_1252 = 1252;
3737
#else
38-
#if defined(__NetBSD__)
39-
#define LIBICONV_PLUG
40-
#endif
4138
#include <errno.h>
4239
#include <iconv.h>
4340
#include <locale.h>
@@ -528,13 +525,8 @@ std::string CodeTo(const char* tocode, const char* fromcode, std::basic_string_v
528525
while (src_bytes != 0)
529526
{
530527
size_t const iconv_result =
531-
#if defined(__NetBSD__)
532-
iconv(conv_desc, reinterpret_cast<const char**>(&src_buffer), &src_bytes, &dst_buffer,
533-
&dst_bytes);
534-
#else
535528
iconv(conv_desc, const_cast<char**>(reinterpret_cast<const char**>(&src_buffer)),
536529
&src_bytes, &dst_buffer, &dst_bytes);
537-
#endif
538530
if ((size_t)-1 == iconv_result)
539531
{
540532
if (EILSEQ == errno || EINVAL == errno)

Source/Core/Core/PowerPC/Expression.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
#include <string_view>
1212
#include <utility>
1313

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

1626
#include "Common/BitUtils.h"

0 commit comments

Comments
 (0)