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()
if(ENABLE_X11)
find_package(X11)
pkg_check_modules(X11 x11 IMPORTED_TARGET)
if(X11_FOUND)
add_definitions(-DHAVE_X11=1)
check_lib(XRANDR xrandr Xrandr)
pkg_check_modules(XRANDR xrandr IMPORTED_TARGET)
if(XRANDR_FOUND)
add_definitions(-DHAVE_XRANDR=1)
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")
else()
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.
#
if(ENABLE_TESTS)
find_package(GTest)
if (GTEST_FOUND)
message(STATUS "Using the system gtest")
include_directories(${GTEST_INCLUDE_DIRS})
else()
message(STATUS "Using static gtest from Externals")
add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL)
dolphin_find_optional_system_library_pkgconfig(GTEST
gtest gtest::gtest Externals/gtest
)
# dolphin_find_optional_system_library_pkgconfig() doesn't add an alias if it
# uses the bundled libraries, so we add one ourselves.
if (NOT TARGET gtest::gtest)
add_library(gtest::gtest ALIAS gtest)
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)
else()
message(STATUS "Unit tests are disabled")

View File

@ -751,6 +751,12 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
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)
target_sources(core PRIVATE
HW/WiimoteReal/IOhidapi.cpp

View File

@ -41,6 +41,13 @@ namespace WiimoteReal
{
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();
ASSERT_MSG(WIIMOTE, ret == 0, "Couldn't initialise hidapi.");
}

View File

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

View File

@ -125,14 +125,12 @@ elseif(APPLE)
-fobjc-arc
)
elseif(X11_FOUND)
target_include_directories(inputcommon PUBLIC ${X11_INPUT_INCLUDE_DIRS})
target_sources(inputcommon PRIVATE
ControllerInterface/Xlib/XInput2.cpp
ControllerInterface/Xlib/XInput2.h
)
target_link_libraries(inputcommon PUBLIC
${X11_LIBRARIES}
${X11_INPUT_LIBRARIES}
)
target_link_libraries(inputcommon PRIVATE PkgConfig::X11_INPUT)
elseif(ANDROID)
target_compile_definitions(inputcommon PRIVATE -DCIFACE_USE_ANDROID)
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)
endif()
if(ENABLE_X11 AND X11_FOUND)
target_include_directories(uicommon PRIVATE ${X11_INCLUDE_DIR})
if(X11_FOUND)
target_sources(uicommon PRIVATE X11Utils.cpp)
target_link_libraries(uicommon PUBLIC ${XRANDR_LIBRARIES})
target_link_libraries(uicommon PUBLIC PkgConfig::XRANDR PkgConfig::X11)
endif()
if(TARGET LibUSB::LibUSB)
@ -56,8 +55,24 @@ if(ENABLE_LLVM)
find_package(LLVM CONFIG QUIET)
if(LLVM_FOUND AND TARGET LLVM)
message(STATUS "LLVM found, enabling LLVM support in disassembler")
target_compile_definitions(uicommon PRIVATE HAVE_LLVM)
target_link_libraries(uicommon PRIVATE LLVM)
# Minimal documentation about LLVM's CMake functions is available here:
# 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})
endif()
endif()

View File

@ -27,14 +27,10 @@ add_library(videoogl
VideoBackend.h
)
target_link_libraries(videoogl
PUBLIC
common
videocommon
PRIVATE
${X11_LIBRARIES}
)
target_link_libraries(videoogl PUBLIC common videocommon)
if(X11_FOUND)
target_link_libraries(videoogl PRIVATE PkgConfig::X11)
endif()
if(MSVC)
# 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")
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.
# Otherwise CMake inserts the library after core, but before other core
# dependencies like videocommon which also use Host_ functions, which makes the