Only use date library on macOS.

This commit is contained in:
squidbus 2024-07-17 01:56:07 -07:00 committed by TheTurtle
parent b557de2c62
commit 426d82d07b
3 changed files with 17 additions and 4 deletions

View File

@ -67,7 +67,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Boost 1.84.0 CONFIG) find_package(Boost 1.84.0 CONFIG)
find_package(cryptopp 8.9.0 MODULE) find_package(cryptopp 8.9.0 MODULE)
find_package(date 3.0.1 CONFIG)
find_package(fmt 10.2.1 CONFIG) find_package(fmt 10.2.1 CONFIG)
find_package(glslang 14.2.0 CONFIG) find_package(glslang 14.2.0 CONFIG)
find_package(magic_enum 0.9.6 CONFIG) find_package(magic_enum 0.9.6 CONFIG)
@ -81,6 +80,10 @@ find_package(xxHash 0.8.2 MODULE)
find_package(zlib-ng 2.2.0 MODULE) find_package(zlib-ng 2.2.0 MODULE)
find_package(Zydis 4.1.0 CONFIG) find_package(Zydis 4.1.0 CONFIG)
if (APPLE)
find_package(date 3.0.1 CONFIG)
endif()
include(CheckSymbolExists) include(CheckSymbolExists)
check_symbol_exists(pthread_mutex_timedlock "pthread.h" HAVE_PTHREAD_MUTEX_TIMEDLOCK) check_symbol_exists(pthread_mutex_timedlock "pthread.h" HAVE_PTHREAD_MUTEX_TIMEDLOCK)
# Windows always has the function through winpthreads # Windows always has the function through winpthreads
@ -554,7 +557,7 @@ endif()
create_target_directory_groups(shadps4) create_target_directory_groups(shadps4)
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient date::date-tz) target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient)
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3) target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3)
if (APPLE) if (APPLE)
@ -564,6 +567,9 @@ if (APPLE)
# Link MoltenVK for Vulkan support # Link MoltenVK for Vulkan support
find_library(MOLTENVK MoltenVK REQUIRED) find_library(MOLTENVK MoltenVK REQUIRED)
target_link_libraries(shadps4 PRIVATE ${MOLTENVK}) target_link_libraries(shadps4 PRIVATE ${MOLTENVK})
# Replacement for std::chrono::time_zone
target_link_libraries(shadps4 PRIVATE date::date-tz)
endif() endif()
if (NOT ENABLE_QT_GUI) if (NOT ENABLE_QT_GUI)

View File

@ -135,7 +135,7 @@ if (WIN32)
endif() endif()
# date # date
if (NOT TARGET date::date-tz) if (APPLE AND NOT TARGET date::date-tz)
option(BUILD_TZ_LIB "" ON) option(BUILD_TZ_LIB "" ON)
option(USE_SYSTEM_TZ_DB "" ON) option(USE_SYSTEM_TZ_DB "" ON)
add_subdirectory(date) add_subdirectory(date)

View File

@ -3,7 +3,6 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <date/tz.h>
#include <boost/asio/io_context.hpp> #include <boost/asio/io_context.hpp>
@ -33,6 +32,9 @@
#include <windows.h> #include <windows.h>
#else #else
#include <sys/mman.h> #include <sys/mman.h>
#ifdef __APPLE__
#include <date/tz.h>
#endif
#endif #endif
namespace Libraries::Kernel { namespace Libraries::Kernel {
@ -182,7 +184,12 @@ s64 PS4_SYSV_ABI ps4__write(int d, const void* buf, std::size_t nbytes) {
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time, int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time,
struct OrbisTimesec* st, unsigned long* dst_sec) { struct OrbisTimesec* st, unsigned long* dst_sec) {
LOG_TRACE(Kernel, "Called"); LOG_TRACE(Kernel, "Called");
#ifdef __APPLE__
// std::chrono::current_zone() not available yet.
const auto* time_zone = date::current_zone(); const auto* time_zone = date::current_zone();
#else
const auto* time_zone = std::chrono::current_zone();
#endif
auto info = time_zone->get_info(std::chrono::system_clock::now()); auto info = time_zone->get_info(std::chrono::system_clock::now());
*local_time = info.offset.count() + info.save.count() * 60 + time; *local_time = info.offset.count() + info.save.count() * 60 + time;