1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Fix macOS compilation

This commit is contained in:
vit9696 2018-11-10 17:43:38 +03:00 committed by Ivan
parent 65ca934452
commit 634a5fa31c
7 changed files with 30 additions and 6 deletions

4
.gitignore vendored
View File

@ -93,3 +93,7 @@ CMakeLists.txt.user
# CLion
/.idea/*
/cmake-build-*/
# macOS
.DS_Store

View File

@ -24,9 +24,6 @@ matrix:
osx_image: xcode10
script: "/bin/bash -ex .travis/build-mac.bash"
cache: ccache
# Unfortunately Requires MacOS 10.14 Mojave for latest c++ features, which Travis doesn't use yet
allow_failures:
- os: osx
git:
depth: false # Unshallow clone to obtain proper GIT_VERSION

View File

@ -3,10 +3,14 @@ export CCACHE_SLOPPINESS=pch_defines,time_macros
export CMAKE_PREFIX_PATH=/usr/local/opt/qt5/
export PATH="/usr/local/opt/ccache/libexec:$PATH"
# Allow using optional on 10.13
sudo perl -pi -e 'BEGIN{undef $/;} s/(_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS[ ]+\\\n[^\n]+10)\.14/\1.13/;' \
$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__config
# Setup vulkan and gfx-rs/portability
curl -sLO https://github.com/gfx-rs/portability/releases/download/latest/gfx-portability-macos-latest.zip
unzip -: gfx-portability-macos-latest.zip
curl -sLO https://github.com/KhronosGroup/Vulkan-Headers/archive/sdk-1.1.77.0.zip
curl -sLO https://github.com/KhronosGroup/Vulkan-Headers/archive/sdk-1.1.85.0.zip
unzip -: sdk-*.zip
mkdir vulkan-sdk
ln -s ${PWD}/Vulkan-Headers*/include vulkan-sdk/include

View File

@ -178,6 +178,9 @@ if (WIN32 OR CMAKE_SYSTEM MATCHES "Linux" OR APPLE)
find_library(DISCORD_RPC_LIB discord-rpc-mac PATHS discord-rpc/lib/ NO_DEFAULT_PATH)
endif()
target_link_libraries(3rdparty_discord-rpc INTERFACE ${DISCORD_RPC_LIB})
if(APPLE)
target_link_libraries(3rdparty_discord-rpc INTERFACE "objc" "-framework Foundation" "-framework CoreServices")
endif()
endif()
@ -231,7 +234,7 @@ endif()
# Vulkan
set(VULKAN_TARGET 3rdparty_dummy_lib)
if(NOT APPLE AND USE_VULKAN)
if(USE_VULKAN)
find_package(Vulkan)
if(VULKAN_FOUND)
add_library(3rdparty_vulkan INTERFACE)

View File

@ -49,6 +49,11 @@ if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0602)
endif()
if(APPLE)
include_directories(/opt/local/include)
link_directories(/opt/local/lib)
endif()
add_subdirectory(Vulkan EXCLUDE_FROM_ALL)
add_subdirectory(asmjitsrc EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty)

View File

@ -1783,6 +1783,15 @@ u64 thread_base::get_cycles()
#ifdef _WIN32
if (QueryThreadCycleTime((HANDLE)m_thread.load(), &cycles))
{
#elif __APPLE__
mach_port_name_t port = pthread_mach_thread_np((pthread_t)m_thread.load());
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
thread_basic_info_data_t info;
kern_return_t ret = thread_info(port, THREAD_BASIC_INFO, (thread_info_t)&info, &count);
if (ret == KERN_SUCCESS)
{
cycles = static_cast<u64>(info.user_time.seconds + info.system_time.seconds) * 1'000'000'000 +
static_cast<u64>(info.user_time.microseconds + info.system_time.microseconds) * 1'000;
#else
clockid_t _clock;
struct timespec thread_time;

View File

@ -60,11 +60,13 @@ if (WIN32)
target_sources(rpcs3 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/rpcs3.rc")
endif()
if(UNIX)
if(UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
target_include_directories(rpcs3 PUBLIC ${X11_INCLUDE_DIR})
target_link_libraries(rpcs3 ${X11_LIBRARIES})
endif()
if(UNIX)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
target_link_libraries(rpcs3 Threads::Threads)