port to OpenBSD

This commit is contained in:
Guilherme Janczak 2024-04-18 10:58:08 +00:00
parent e69486d2cb
commit 50dc0ffbce
No known key found for this signature in database
GPG Key ID: 9F1927DAAC7F9DCD
8 changed files with 55 additions and 30 deletions

View File

@ -504,14 +504,14 @@ if (OPENGL_GL)
endif() endif()
if(ENABLE_X11) if(ENABLE_X11)
find_package(X11) pkg_check_modules(X11 x11 IMPORTED_TARGET)
if(X11_FOUND) if(X11_FOUND)
add_definitions(-DHAVE_X11=1) add_definitions(-DHAVE_X11=1)
check_lib(XRANDR xrandr Xrandr) pkg_check_modules(XRANDR xrandr IMPORTED_TARGET)
if(XRANDR_FOUND) if(XRANDR_FOUND)
add_definitions(-DHAVE_XRANDR=1) add_definitions(-DHAVE_XRANDR=1)
endif() endif()
pkg_check_modules(X11_INPUT REQUIRED xi>=1.5.0) pkg_check_modules(X11_INPUT REQUIRED xi>=1.5.0 IMPORTED_TARGET)
message(STATUS "X11 support enabled") message(STATUS "X11 support enabled")
else() else()
message(WARNING "X11 support enabled but not found. This build will not support X11.") message(WARNING "X11 support enabled but not found. This build will not support X11.")
@ -802,15 +802,16 @@ include_directories("${PROJECT_BINARY_DIR}/Source/Core")
# Unit testing. # Unit testing.
# #
if(ENABLE_TESTS) if(ENABLE_TESTS)
find_package(GTest) dolphin_find_optional_system_library_pkgconfig(GTEST
if (GTEST_FOUND) gtest gtest::gtest Externals/gtest
message(STATUS "Using the system gtest") )
include_directories(${GTEST_INCLUDE_DIRS}) # dolphin_find_optional_system_library_pkgconfig() doesn't add an alias if it
else() # uses the bundled libraries, so we add one ourselves.
message(STATUS "Using static gtest from Externals") if (NOT TARGET gtest::gtest)
add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL) add_library(gtest::gtest ALIAS gtest)
endif() endif()
# Force gtest to link the C runtime dynamically on Windows in order to avoid runtime mismatches. # Force gtest to link the C runtime dynamically on Windows in order to avoid
# runtime mismatches.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
else() else()
message(STATUS "Unit tests are disabled") message(STATUS "Unit tests are disabled")

View File

@ -751,6 +751,12 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
endif() endif()
endif() endif()
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
# OpenBSD doesn't allow memory to be both writable and executable by default.
# The JIT currently needs this.
target_link_options(core PUBLIC -Wl,-zwxneeded)
endif()
if(TARGET Hidapi::Hidapi) if(TARGET Hidapi::Hidapi)
target_sources(core PRIVATE target_sources(core PRIVATE
HW/WiimoteReal/IOhidapi.cpp HW/WiimoteReal/IOhidapi.cpp

View File

@ -41,6 +41,13 @@ namespace WiimoteReal
{ {
WiimoteScannerHidapi::WiimoteScannerHidapi() WiimoteScannerHidapi::WiimoteScannerHidapi()
{ {
#ifdef __OpenBSD__
// OpenBSD renamed libhidapi's hidapi_init function because the system has its own USB library
// which contains a symbol with the same name. See:
// https://cvsweb.openbsd.org/ports/comms/libhidapi/patches/patch-hidapi_hidapi_h?rev=1.3&content-type=text/x-cvsweb-markup
// https://man.openbsd.org/usbhid.3
#define hid_init hidapi_hid_init
#endif
int ret = hid_init(); int ret = hid_init();
ASSERT_MSG(WIIMOTE, ret == 0, "Couldn't initialise hidapi."); ASSERT_MSG(WIIMOTE, ret == 0, "Couldn't initialise hidapi.");
} }

View File

@ -5,8 +5,9 @@ add_executable(dolphin-nogui
MainNoGUI.cpp MainNoGUI.cpp
) )
if(ENABLE_X11 AND X11_FOUND) if(X11_FOUND)
target_sources(dolphin-nogui PRIVATE PlatformX11.cpp) target_sources(dolphin-nogui PRIVATE PlatformX11.cpp)
target_link_libraries(dolphin-nogui PRIVATE PkgConfig::XRANDR PkgConfig::X11)
endif() endif()
if(WIN32) if(WIN32)

View File

@ -125,14 +125,12 @@ elseif(APPLE)
-fobjc-arc -fobjc-arc
) )
elseif(X11_FOUND) elseif(X11_FOUND)
target_include_directories(inputcommon PUBLIC ${X11_INPUT_INCLUDE_DIRS})
target_sources(inputcommon PRIVATE target_sources(inputcommon PRIVATE
ControllerInterface/Xlib/XInput2.cpp ControllerInterface/Xlib/XInput2.cpp
ControllerInterface/Xlib/XInput2.h ControllerInterface/Xlib/XInput2.h
) )
target_link_libraries(inputcommon PUBLIC target_link_libraries(inputcommon PRIVATE PkgConfig::X11_INPUT)
${X11_LIBRARIES}
${X11_INPUT_LIBRARIES}
)
elseif(ANDROID) elseif(ANDROID)
target_compile_definitions(inputcommon PRIVATE -DCIFACE_USE_ANDROID) target_compile_definitions(inputcommon PRIVATE -DCIFACE_USE_ANDROID)
target_sources(inputcommon PRIVATE target_sources(inputcommon PRIVATE

View File

@ -42,10 +42,9 @@ if ((DEFINED CMAKE_ANDROID_ARCH_ABI AND CMAKE_ANDROID_ARCH_ABI MATCHES "x86|x86_
target_link_libraries(uicommon PRIVATE bdisasm) target_link_libraries(uicommon PRIVATE bdisasm)
endif() endif()
if(ENABLE_X11 AND X11_FOUND) if(X11_FOUND)
target_include_directories(uicommon PRIVATE ${X11_INCLUDE_DIR})
target_sources(uicommon PRIVATE X11Utils.cpp) target_sources(uicommon PRIVATE X11Utils.cpp)
target_link_libraries(uicommon PUBLIC ${XRANDR_LIBRARIES}) target_link_libraries(uicommon PUBLIC PkgConfig::XRANDR PkgConfig::X11)
endif() endif()
if(TARGET LibUSB::LibUSB) if(TARGET LibUSB::LibUSB)
@ -56,8 +55,24 @@ if(ENABLE_LLVM)
find_package(LLVM CONFIG QUIET) find_package(LLVM CONFIG QUIET)
if(LLVM_FOUND AND TARGET LLVM) if(LLVM_FOUND AND TARGET LLVM)
message(STATUS "LLVM found, enabling LLVM support in disassembler") message(STATUS "LLVM found, enabling LLVM support in disassembler")
target_compile_definitions(uicommon PRIVATE HAVE_LLVM) # Minimal documentation about LLVM's CMake functions is available here:
target_link_libraries(uicommon PRIVATE LLVM) # https://releases.llvm.org/16.0.0/docs/CMake.html#embedding-llvm-in-your-project
#
# However, you have to read the source code in any case.
# Look for LLVM-Config.cmake in your (Unix) system:
# $ find /usr -name LLVM-Config\\.cmake 2>/dev/null
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
target_compile_definitions(uicommon
PRIVATE HAVE_LLVM ${LLVM_DEFINITIONS_LIST}
)
target_link_directories(uicommon PRIVATE ${LLVM_LIBRARY_DIRS})
llvm_expand_pseudo_components(LLVM_EXPAND_COMPONENTS
AllTargetsInfos AllTargetsDisassemblers AllTargetsCodeGens
)
llvm_map_components_to_libnames(LLVM_LIBRARIES
mcdisassembler target ${LLVM_EXPAND_COMPONENTS}
)
target_link_libraries(uicommon PRIVATE ${LLVM_LIBRARIES})
target_include_directories(uicommon PRIVATE ${LLVM_INCLUDE_DIRS}) target_include_directories(uicommon PRIVATE ${LLVM_INCLUDE_DIRS})
endif() endif()
endif() endif()

View File

@ -27,14 +27,10 @@ add_library(videoogl
VideoBackend.h VideoBackend.h
) )
target_link_libraries(videoogl target_link_libraries(videoogl PUBLIC common videocommon)
PUBLIC if(X11_FOUND)
common target_link_libraries(videoogl PRIVATE PkgConfig::X11)
videocommon endif()
PRIVATE
${X11_LIBRARIES}
)
if(MSVC) if(MSVC)
# Add precompiled header # Add precompiled header

View File

@ -5,7 +5,8 @@ add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND} "-
string(APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY "/Tests") string(APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY "/Tests")
add_library(unittests_main OBJECT UnitTestsMain.cpp) add_library(unittests_main OBJECT UnitTestsMain.cpp)
target_link_libraries(unittests_main PUBLIC fmt::fmt gtest)
target_link_libraries(unittests_main PUBLIC fmt::fmt gtest::gtest)
# Since this is a Core dependency, it can't be linked as a normal library. # Since this is a Core dependency, it can't be linked as a normal library.
# Otherwise CMake inserts the library after core, but before other core # Otherwise CMake inserts the library after core, but before other core
# dependencies like videocommon which also use Host_ functions, which makes the # dependencies like videocommon which also use Host_ functions, which makes the