Make compile with msvc, clang and gcc on Windows

This commit is contained in:
oltolm 2023-07-11 20:40:30 +02:00 committed by GitHub
parent ed75bab7b2
commit 0c94606fcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 519 additions and 4584 deletions

View file

@ -4,6 +4,11 @@ include(CMakeDependentOption)
set(CMAKE_CXX_STANDARD 20)
# Warnings are silenced for 3rdparty code
if(NOT MSVC)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX,C>:-w>")
endif()
# Dummy target to use when lib isn't available
add_library(3rdparty_dummy_lib INTERFACE)
@ -42,16 +47,16 @@ endif()
# libusb
if(CMAKE_SYSTEM MATCHES "DragonFly|FreeBSD")
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD")
pkg_check_modules(LIBUSB REQUIRED IMPORTED_TARGET libusb-1.0>=1.0 )
CMAKE_DEPENDENT_OPTION( USE_SYSTEM_LIBUSB "Use system libusb-1.0 as shared library" ON
cmake_dependent_option(USE_SYSTEM_LIBUSB "Use system libusb-1.0 as shared library" ON
"LIBUSB_FOUND" OFF)
else()
pkg_check_modules(LIBUSB IMPORTED_TARGET libusb-1.0>=1.0 )
CMAKE_DEPENDENT_OPTION( USE_SYSTEM_LIBUSB "Use system libusb-1.0 as shared library" OFF
cmake_dependent_option(USE_SYSTEM_LIBUSB "Use system libusb-1.0 as shared library" OFF
"LIBUSB_FOUND" OFF)
endif()
if(CMAKE_SYSTEM MATCHES "DragonFly|FreeBSD")
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD")
# Always use system libusb as reference implementation isn't supported
add_library(usb-1.0-shared INTERFACE)
target_link_libraries(usb-1.0-shared INTERFACE PkgConfig::LIBUSB)
@ -100,10 +105,6 @@ endif()
# OpenGL
# Prefer GLVND for OpenGL rather than legacy, unless it's been defined elsewhere, in the case of AppImage builds
if(NOT DEFINED OpenGL_GL_PREFERENCE)
set(OpenGL_GL_PREFERENCE GLVND)
endif()
find_package(OpenGL REQUIRED)
add_library(3rdparty_opengl INTERFACE)
@ -111,17 +112,14 @@ target_include_directories(3rdparty_opengl INTERFACE GL)
if (WIN32)
if(NOT MSVC)
target_link_libraries(3rdparty_opengl INTERFACE ${OPENGL_LIBRARIES} opengl32.lib glu32.lib)
target_link_libraries(3rdparty_opengl INTERFACE OpenGL::GL OpenGL::GLU)
else()
target_link_libraries(3rdparty_opengl INTERFACE dxgi.lib d2d1.lib dwrite.lib)
endif()
elseif(APPLE)
target_link_libraries(3rdparty_opengl INTERFACE OpenGL::GL OpenGL::GLU)
else()
target_link_libraries(3rdparty_opengl INTERFACE ${OPENGL_LIBRARIES})
target_compile_definitions(3rdparty_opengl
INTERFACE
-DGL_GLEXT_PROTOTYPES
-DGLX_GLXEXT_PROTOTYPES)
target_link_libraries(3rdparty_opengl INTERFACE OpenGL::GL OpenGL::GLU OpenGL::GLX)
endif()
@ -160,9 +158,9 @@ set(VULKAN_TARGET 3rdparty_dummy_lib)
if(USE_VULKAN)
if(APPLE)
if(USE_SYSTEM_MVK)
message("-- RPCS3: Using system MoltenVK")
message(STATUS "RPCS3: Using system MoltenVK")
else()
message("-- RPCS3: MoltenVK submodule")
message(STATUS "RPCS3: MoltenVK submodule")
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK"
@ -204,9 +202,9 @@ if(USE_VULKAN)
set(VULKAN_TARGET 3rdparty_vulkan)
else()
message("WARNING! USE_VULKAN was enabled, but libvulkan was not found. RPCS3 will be compiled without Vulkan support.")
message(WARNING "USE_VULKAN was enabled, but libvulkan was not found. RPCS3 will be compiled without Vulkan support.")
if(APPLE)
message( FATAL_ERROR "ERROR! To build without Vulkan support on macOS, please disable USE_VULKAN.")
message(FATAL_ERROR "To build without Vulkan support on macOS, please disable USE_VULKAN.")
endif()
endif()
endif()
@ -225,7 +223,7 @@ if(USE_FAUDIO)
if (USE_SYSTEM_FAUDIO)
if (NOT SDL2_FOUND OR SDL2_VERSION VERSION_LESS 2.0.12)
message(WARNING
"-- RPCS3: System FAudio requires SDL 2.0.9 or newer. Please note, this warning"
"RPCS3: FAudio requires SDL 2.0.9 or newer. Please note, this warning"
"can also be displayed with SDL2 versions between 2.0.9-2.0.12, as the"
"CMake config files are not correctly installed. Since a valid SDL2"
">=2.0.9 version cannot be found, building with FAudio will be skipped.")
@ -262,36 +260,36 @@ add_library(3rdparty_ffmpeg INTERFACE)
# Select the version of ffmpeg to use, default is builtin
if(USE_SYSTEM_FFMPEG)
message("-- RPCS3: using shared ffmpeg")
message(STATUS "RPCS3: using shared ffmpeg")
find_package(FFMPEG REQUIRED)
target_include_directories(3rdparty_ffmpeg INTERFACE ${FFMPEG_INCLUDE_DIR})
target_link_libraries(3rdparty_ffmpeg INTERFACE ${FFMPEG_LIBRARIES})
else()
if (NOT MSVC AND WIN32)
message("-- RPCS3: building ffmpeg submodule")
message(STATUS "RPCS3: building ffmpeg submodule")
include(ProcessorCount)
ProcessorCount(N)
ExternalProject_Add(ffmpeg-mingw
DOWNLOAD_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ffmpeg
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg/configure --prefix=./windows/x86_64 --arch=x86_64 --disable-avdevice --disable-programs --disable-avfilter --disable-postproc --disable-doc --disable-pthreads --enable-w32threads --disable-network --disable-everything --disable-encoders --disable-muxers --disable-hwaccels --disable-parsers --disable-protocols --enable-dxva2 --enable-static --disable-shared --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-decoder=mp3 --enable-decoder=pcm_s16le --enable-decoder=pcm_s8 --enable-decoder=h264 --enable-decoder=mpeg4 --enable-decoder=mpeg2video --enable-decoder=mjpeg --enable-decoder=mjpegb --enable-encoder=pcm_s16le --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=mjpeg --enable-parser=aac --enable-parser=aac_latm --enable-muxer=avi --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mp3 --enable-demuxer=mpegvideo --enable-demuxer=mpegps --enable-demuxer=mjpeg --enable-demuxer=avi --enable-demuxer=aac --enable-demuxer=pmp --enable-demuxer=oma --enable-demuxer=pcm_s16le --enable-demuxer=pcm_s8 --enable-demuxer=wav --enable-hwaccel=h264_dxva2 --enable-indev=dshow --enable-protocol=file
BUILD_COMMAND make -j 4
CONFIGURE_COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg/configure --prefix=./windows/x86_64 --arch=x86_64 --disable-avdevice --disable-programs --disable-avfilter --disable-postproc --disable-doc --disable-pthreads --enable-w32threads --disable-network --disable-everything --disable-encoders --disable-muxers --disable-hwaccels --disable-parsers --disable-protocols --enable-dxva2 --enable-static --disable-shared --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-decoder=mp3 --enable-decoder=pcm_s16le --enable-decoder=pcm_s8 --enable-decoder=h264 --enable-decoder=mpeg4 --enable-decoder=mpeg2video --enable-decoder=mjpeg --enable-decoder=mjpegb --enable-encoder=pcm_s16le --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=mjpeg --enable-parser=aac --enable-parser=aac_latm --enable-muxer=avi --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mp3 --enable-demuxer=mpegvideo --enable-demuxer=mpegps --enable-demuxer=mjpeg --enable-demuxer=avi --enable-demuxer=aac --enable-demuxer=pmp --enable-demuxer=oma --enable-demuxer=pcm_s16le --enable-demuxer=pcm_s8 --enable-demuxer=wav --enable-hwaccel=h264_dxva2 --enable-indev=dshow --enable-protocol=file
BUILD_COMMAND make -j ${N}
INSTALL_COMMAND make install
)
set(FFMPEG_LIB_AVFORMAT "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/windows/x86_64/lib/libavformat.a")
set(FFMPEG_LIB_AVCODEC "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/windows/x86_64/lib/libavcodec.a")
set(FFMPEG_LIB_AVUTIL "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/windows/x86_64/lib/libavutil.a")
set(FFMPEG_LIB_SWSCALE "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/windows/x86_64/lib/libswscale.a")
set(FFMPEG_LIB_SWRESAMPLE "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/windows/x86_64/lib/libswresample.a")
target_link_directories(3rdparty_ffmpeg INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/windows/x86_64/lib")
target_link_libraries(3rdparty_ffmpeg INTERFACE avformat avcodec avutil swscale swresample iconv)
else()
message("-- RPCS3: using builtin ffmpeg")
message(STATUS "RPCS3: using builtin ffmpeg")
if (WIN32)
set(FFMPEG_LIB_DIR "ffmpeg/windows/x86_64")
target_link_libraries(3rdparty_ffmpeg INTERFACE "Bcrypt.lib")
elseif(CMAKE_SYSTEM MATCHES "Linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(FFMPEG_LIB_DIR "ffmpeg/linux/x86_64")
elseif(APPLE)
set(FFMPEG_LIB_DIR "ffmpeg/macos/x86_64")
@ -304,31 +302,31 @@ else()
find_library(FFMPEG_LIB_AVUTIL avutil PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH)
find_library(FFMPEG_LIB_SWSCALE swscale PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH)
find_library(FFMPEG_LIB_SWRESAMPLE swresample PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH)
endif()
target_include_directories(3rdparty_ffmpeg INTERFACE "ffmpeg/include")
target_link_libraries(3rdparty_ffmpeg
target_link_libraries(3rdparty_ffmpeg
INTERFACE
${FFMPEG_LIB_AVFORMAT}
${FFMPEG_LIB_AVCODEC}
${FFMPEG_LIB_AVUTIL}
${FFMPEG_LIB_SWSCALE}
${FFMPEG_LIB_SWRESAMPLE}
)
)
endif()
target_include_directories(3rdparty_ffmpeg INTERFACE "ffmpeg/include")
endif()
# GLEW
add_library(3rdparty_glew INTERFACE)
if(NOT MSVC)
find_package(GLEW 1.13.0 REQUIRED)
find_package(GLEW REQUIRED)
target_link_libraries(3rdparty_glew INTERFACE GLEW::GLEW)
endif()
# LLVM
include(llvm.cmake)
add_subdirectory(llvm EXCLUDE_FROM_ALL)
# WOLFSSL
add_subdirectory(wolfssl EXCLUDE_FROM_ALL)

View file

@ -1,5 +1,5 @@
# OpenAL
if (MSVC)
if (WIN32)
find_path(OPENAL_INCLUDE_DIR al.h PATHS include/)
find_library(OPENAL_LIBRARY OpenAL32 PATHS libs/Win64/)
else()

View file

@ -1,24 +1,36 @@
# CURL
if(USE_SYSTEM_CURL)
message("-- RPCS3: using shared libcurl")
message(STATUS "RPCS3: using shared libcurl")
find_package(CURL REQUIRED)
add_library(libcurl INTERFACE)
target_link_libraries(libcurl INTERFACE CURL::libcurl)
else()
message("-- RPCS3: building libcurl + wolfssl submodules")
add_compile_definitions(HAVE_SNI OPENSSL_EXTRA)
option(BUILD_CURL_EXE "Set to ON to build curl executable." OFF)
option(CURL_USE_WOLFSSL "enable wolfSSL for SSL/TLS" ON)
option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" ON)
option(CURL_ZLIB "Set to ON to enable building curl with zlib support." OFF)
option(USE_LIBIDN2 "Use libidn2 for IDN support" OFF) # Disabled because MacOs CI doesn't work otherwise
message(STATUS "RPCS3: building libcurl + wolfssl submodules")
set(BUILD_CURL_EXE OFF CACHE BOOL "Set to ON to build curl executable.")
# If set to ON then CURL can not find our wolfssl
set(CURL_USE_WOLFSSL OFF CACHE BOOL "enable wolfSSL for SSL/TLS")
set(CURL_USE_OPENSSL OFF CACHE BOOL "Use OpenSSL code. Experimental")
set(HTTP_ONLY ON CACHE BOOL "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)")
set(USE_LIBIDN2 OFF CACHE BOOL "Use libidn2 for IDN support") # Disabled because MacOS CI doesn't work otherwise
set(CURL_CA_PATH "none" CACHE STRING "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
if(USE_MSVC_STATIC_CRT)
set(CURL_STATIC_CRT ON CACHE BOOL "Use static crt to build curl" FORCE)
set(CURL_STATIC_CRT ON CACHE BOOL "Use static crt to build curl")
endif()
if(WIN32)
set(ENABLE_UNICODE ON CACHE BOOL "enable Unicode")
endif()
set(CURL_USE_LIBSSH2 OFF CACHE BOOL "Use libSSH2")
set(CURL_USE_LIBPSL OFF CACHE BOOL "Use libPSL")
set(SSL_ENABLED ON)
set(USE_WOLFSSL ON)
add_subdirectory(curl EXCLUDE_FROM_ALL)
set_property(TARGET libcurl PROPERTY FOLDER "3rdparty/")
target_link_libraries(libcurl PRIVATE wolfssl)
if(MSVC)
target_compile_definitions(libcurl PRIVATE HAVE_SSIZE_T)
endif()
endif()

View file

@ -14,7 +14,7 @@ if(APPLE)
elseif(CMAKE_SYSTEM MATCHES "Linux")
target_link_libraries(3rdparty_hidapi INTERFACE hidapi-hidraw udev)
elseif(WIN32)
target_link_libraries(3rdparty_hidapi INTERFACE hidapi-hid Shlwapi.lib)
target_link_libraries(3rdparty_hidapi INTERFACE hidapi::hidapi hidapi::include Shlwapi.lib)
else()
target_link_libraries(3rdparty_hidapi INTERFACE hidapi-libusb usb)
endif()

View file

@ -2,14 +2,15 @@
# Select the version of libpng to use, default is builtin
if (NOT USE_SYSTEM_LIBPNG)
# We use libpng's static library and don't need to build the shared library and run the tests
set(PNG_SHARED OFF CACHE BOOL "Build shared lib" FORCE)
set(PNG_TESTS OFF CACHE BOOL "Build libpng tests" FORCE)
set(PNG_BUILD_ZLIB ON CACHE BOOL "ZLIB is already build or package is found" FORCE)
set(PNG_SHARED OFF CACHE BOOL "Build shared lib")
set(PNG_TESTS OFF CACHE BOOL "Build libpng tests")
set(PNG_BUILD_ZLIB ON CACHE BOOL "ZLIB is already build or package is found")
set(SKIP_INSTALL_ALL ON)
add_subdirectory(libpng EXCLUDE_FROM_ALL)
target_include_directories(png_static INTERFACE "${libpng_BINARY_DIR}" "${libpng_SOURCE_DIR}")
target_link_libraries(png_static 3rdparty::zlib)
set(LIBPNG_TARGET png_static PARENT_SCOPE)
set(LIBPNG_TARGET png_static PARENT_SCOPE)
else()
find_package(PNG REQUIRED)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.4)
cmake_minimum_required(VERSION 3.0)
project(libusb)

View file

@ -89,7 +89,11 @@ set(PACKAGE_URL "http://www.libusb.org" CACHE INTERNAL "package url" FORCE)
set(PACKAGE_TARNAME "libusb" CACHE INTERNAL "tarball name" FORCE)
set(VERSION "${PACKAGE_VERSION}" CACHE INTERNAL "version" FORCE)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
if(MSVC)
file(COPY libusb/msvc/config.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
else()
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
endif()
message(STATUS "Generated configuration file in ${CMAKE_CURRENT_BINARY_DIR}/config.h")
# for generated config.h

View file

@ -3,22 +3,6 @@ include(os.cmake)
include(config.cmake)
include(FindThreads)
set (LIBUSB_COMMON
core.c
descriptor.c
io.c
sync.c
hotplug.c
strerror.c
libusb-1.0.rc
libusb-1.0.def
)
foreach(SRC IN LISTS LIBUSB_COMMON)
list(APPEND LIBUSB_COMMON_FINAL ${LIBUSB_SOURCE_DIR}/libusb/${SRC})
endforeach()
include_directories(${LIBUSB_SOURCE_DIR}/libusb)
include_directories(${LIBUSB_SOURCE_DIR}/libusb/os)
@ -28,7 +12,14 @@ endif()
add_library(usb-1.0-static
STATIC
${LIBUSB_COMMON_FINAL}
libusb/libusb/core.c
libusb/libusb/descriptor.c
libusb/libusb/io.c
libusb/libusb/sync.c
libusb/libusb/hotplug.c
libusb/libusb/strerror.c
libusb/libusb/libusb-1.0.rc
libusb/libusb/libusb-1.0.def
${LIBUSB_PLATFORM}
)

View file

@ -5,42 +5,43 @@ if (CMAKE_USE_PTHREADS_INIT)
set(PTHREADS_ENABLED TRUE)
endif()
if (WIN32 OR "${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
if (CYGWIN)
add_compile_definitions(PLATFORM_WINDOWS=1)
set(OS_WINDOWS 1 CACHE INTERNAL "controls config.h macro definition" FORCE)
set(OS_WINDOWS 1)
# Enable MingW support for RC language (for CMake pre-2.8)
if (MINGW)
set(CMAKE_RC_COMPILER_INIT windres)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
endif()
enable_language(RC)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
message(STATUS "Detected cygwin")
set(PTHREADS_ENABLED TRUE)
set(WITHOUT_POLL_H TRUE CACHE INTERNAL "Disable using poll.h even if it's available - use windows poll instead fo cygwin's" FORCE)
endif()
message(STATUS "Detected Cygwin")
set(PTHREADS_ENABLED TRUE)
set(WITHOUT_POLL_H TRUE)
list(APPEND PLATFORM_SRC
events_windows.c
windows_usbdk.c
windows_common.c
windows_winusb.c
threads_windows.c
)
if (PTHREADS_ENABLED AND NOT WITHOUT_PTHREADS)
list(APPEND PLATFORM_SRC threads_posix)
else()
list(APPEND PLATFORM_SRC threads_windows.c)
endif()
elseif(WIN32)
add_compile_definitions(PLATFORM_WINDOWS=1)
set(OS_WINDOWS 1)
set(PTHREADS_ENABLED FALSE)
list(APPEND PLATFORM_SRC
events_windows.c
windows_usbdk.c
windows_common.c
windows_winusb.c
)
list(APPEND PLATFORM_SRC threads_windows.c)
elseif (APPLE)
# Apple != OSX alone
add_compile_definitions(PLATFORM_POSIX=1 HAVE_CLOCK_GETTIME)
set(OS_DARWIN 1 CACHE INTERNAL "controls config.h macro definition" FORCE)
set(OS_DARWIN 1)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(PLATFORM_SRC
darwin_usb.c
threads_posix.c
@ -77,7 +78,7 @@ elseif (UNIX)
# Unix is for all *NIX systems including OSX
add_compile_definitions(PLATFORM_POSIX=1 HAVE_CLOCK_GETTIME)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(OS_LINUX 1 CACHE INTERNAL "controls config.h macro definition" FORCE)
set(OS_LINUX 1)
set(PLATFORM_SRC
linux_usbfs.c
@ -108,4 +109,4 @@ set(LIBUSB_LIBRARIES ${LIBUSB_LIBRARIES} PARENT_SCOPE)
if (WITHOUT_PTHREADS)
set(PTHREADS_ENABLED FALSE)
endif()
set(THREADS_POSIX ${PTHREADS_ENABLED} CACHE INTERNAL "use pthreads" FORCE)
set(THREADS_POSIX ${PTHREADS_ENABLED})

View file

@ -1,6 +1,6 @@
if(WITH_LLVM)
CHECK_CXX_COMPILER_FLAG("-msse -msse2 -mcx16" COMPILER_X86)
CHECK_CXX_COMPILER_FLAG("-march=armv8-a+lse" COMPILER_ARM)
check_cxx_compiler_flag("-msse -msse2 -mcx16" COMPILER_X86)
check_cxx_compiler_flag("-march=armv8-a+lse" COMPILER_ARM)
if(BUILD_LLVM)
message(STATUS "LLVM will be built from the submodule.")
@ -14,28 +14,26 @@ if(WITH_LLVM)
option(LLVM_INCLUDE_TESTS OFF)
option(LLVM_INCLUDE_TOOLS OFF)
option(LLVM_INCLUDE_UTILS OFF)
option(LLVM_CCACHE_BUILD ON)
# we globally enable ccache
set(LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
if(WIN32)
set(LLVM_USE_INTEL_JITEVENTS ON)
endif()
if(CMAKE_SYSTEM MATCHES "Linux")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(LLVM_USE_INTEL_JITEVENTS ON)
set(LLVM_USE_PERF ON)
endif()
set(CXX_FLAGS_OLD ${CMAKE_CXX_FLAGS})
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS")
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS>")
endif()
# LLVM needs to be built out-of-tree
add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/llvm/llvm/llvm ${CMAKE_BINARY_DIR}/3rdparty/llvm/llvm_build EXCLUDE_FROM_ALL)
set(LLVM_DIR "${CMAKE_BINARY_DIR}/3rdparty/llvm/llvm_build/lib/cmake/llvm/")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/llvm/llvm ${CMAKE_CURRENT_BINARY_DIR}/llvm_build EXCLUDE_FROM_ALL)
set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm_build/lib/cmake/llvm/")
set(CMAKE_CXX_FLAGS ${CXX_FLAGS_OLD})
set(STATIC_LINK_LLVM ON CACHE BOOL "Link against LLVM statically. This will get set to ON if you build LLVM from the submodule." FORCE)
# now tries to find LLVM again
@ -72,11 +70,11 @@ if(WITH_LLVM)
set(LLVM_TARGETS_TO_BUILD "X86" CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
endif()
endif()
if(WIN32 OR CMAKE_SYSTEM MATCHES "Linux")
set (LLVM_ADDITIONAL_LIBS ${LLVM_ADDITIONAL_LIBS} IntelJITEvents)
if((WIN32 AND BUILD_LLVM) OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
list (APPEND LLVM_ADDITIONAL_LIBS IntelJITEvents)
endif()
if(CMAKE_SYSTEM MATCHES "Linux")
set (LLVM_ADDITIONAL_LIBS ${LLVM_ADDITIONAL_LIBS} PerfJITEvents)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list (APPEND LLVM_ADDITIONAL_LIBS PerfJITEvents)
endif()
llvm_map_components_to_libnames(LLVM_LIBS
${LLVM_TARGETS_TO_BUILD}
@ -92,7 +90,8 @@ if(WITH_LLVM)
add_library(3rdparty_llvm INTERFACE)
target_link_libraries(3rdparty_llvm INTERFACE ${LLVM_LIBS})
target_include_directories(3rdparty_llvm INTERFACE ${LLVM_INCLUDE_DIRS})
target_compile_definitions(3rdparty_llvm INTERFACE ${LLVM_DEFINITIONS} -DLLVM_AVAILABLE)
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
target_compile_definitions(3rdparty_llvm INTERFACE ${LLVM_DEFINITIONS_LIST} LLVM_AVAILABLE)
add_library(3rdparty::llvm ALIAS 3rdparty_llvm)
else()

View file

@ -32,6 +32,12 @@
#endif
#endif
#ifdef _WIN32
constexpr SOCKET invalid_socket = INVALID_SOCKET;
#else
constexpr int invalid_socket = -1;
#endif
namespace pine
{
/**
@ -381,7 +387,7 @@ namespace pine
m_msgsock = accept(m_sock, 0, 0);
if (m_msgsock == -1)
if (m_msgsock == invalid_socket)
{
// everything else is non recoverable in our scope
// we also mark as recoverable socket errors where it would block a
@ -541,7 +547,7 @@ namespace pine
}
server.sin_port = htons(Impl::get_port());
if (bind(m_sock, (struct sockaddr*)&server, sizeof(server)) == SOCKET_ERROR)
if (bind(m_sock, reinterpret_cast<struct sockaddr*>(&server), sizeof(server)) == SOCKET_ERROR)
{
Impl::error("IPC: Error while binding to socket! Shutting down...");
return;

4
3rdparty/qt5.cmake vendored
View file

@ -20,7 +20,7 @@ endif()
if(NOT Qt5Widgets_FOUND)
if(Qt5Widgets_VERSION VERSION_LESS ${QT_MIN_VER})
message("Minimum supported Qt5 version is ${QT_MIN_VER}! You have version ${Qt5Widgets_VERSION} installed, please upgrade!")
if(CMAKE_SYSTEM MATCHES "Linux")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(FATAL_ERROR "Most distros do not provide an up-to-date version of Qt.
If you're on Ubuntu or Linux Mint, there are PPAs you can use to install one of the latest qt5 versions.
Find the correct ppa at https://launchpad.net/~beineri and follow the instructions.")
@ -35,7 +35,7 @@ Find the correct ppa at https://launchpad.net/~beineri and follow the instructio
if(WIN32)
message(FATAL_ERROR "Make sure the QTDIR env variable has been set properly. (for example C:\\Qt\\${QT_MIN_VER}\\msvc2019_64\\)
You can also try setting the Qt5_DIR preprocessor definiton.")
elseif(CMAKE_SYSTEM MATCHES "Linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(FATAL_ERROR "Make sure to install your distro's qt5 package!")
else()
message(FATAL_ERROR "You need to have Qt5 installed, look online for instructions on installing Qt5 on ${CMAKE_SYSTEM}.")

View file

@ -1,40 +1,26 @@
if(USE_SYSTEM_WOLFSSL)
message("-- RPCS3: using shared wolfssl")
message(STATUS "RPCS3: using shared wolfssl")
pkg_check_modules(WolfSSL REQUIRED IMPORTED_TARGET wolfssl>=4.7.0)
add_library(wolfssl INTERFACE)
target_link_libraries(wolfssl INTERFACE PkgConfig::WolfSSL)
else()
# TODO(cjj19970505@live.cn)
# OPENSSL_EXTRA, and HAVE_SNI are unconfigurable from CMake cache.
# but they do have it in a TODO list (wolfssl/CMakeList, 1021)
add_compile_definitions(OPENSSL_EXTRA WOLFSSL_DES_ECB HAVE_SNI HAVE_WRITE_DUP)
add_compile_definitions(FP_MAX_BITS=8192)
set(WOLFSSL_TLS13 "no" CACHE INTERNAL "")
set(WOLFSSL_SHA224 "yes" CACHE INTERNAL "")
set(WOLFSSL_SHA3 "yes" CACHE INTERNAL "")
set(WOLFSSL_SHAKE256 "yes" CACHE INTERNAL "")
set(WOLFSSL_BASE64_ENCODE "no" CACHE INTERNAL "")
set(WOLFSSL_DES3 "yes" CACHE INTERNAL "")
set(WOLFSSL_POLY1305 "yes" CACHE INTERNAL "")
set(WOLFSSL_CHACHA "yes" CACHE INTERNAL "")
set(WOLFSSL_FILESYSTEM "yes" CACHE INTERNAL "")
set(WOLFSSL_PWDBASED "yes" CACHE INTERNAL "")
set(WOLFSSL_FAST_MATH "yes" CACHE INTERNAL "")
set(WOLFSSL_EXAMPLES "no" CACHE INTERNAL "")
set(WOLFSSL_CRYPT_TESTS "no" CACHE INTERNAL "")
set(WOLFSSL_ASYNC_THREADS "no" CACHE INTERNAL "")
set(WOLFSSL_CONFIG_H "no" CACHE INTERNAL "")
set(WOLFSSL_TLS13 OFF CACHE STRING "Enable wolfSSL TLS v1.3 (default: enabled)")
set(WOLFSSL_SHA3 ON CACHE STRING "Enable wolfSSL SHA-3 support (default: enabled on x86_64/aarch64)")
set(WOLFSSL_SHAKE256 ON CACHE STRING "Enable wolfSSL SHAKE256 support (default: enabled on x86_64/aarch64)")
set(WOLFSSL_BASE64_ENCODE OFF CACHE STRING "Enable Base64 encoding (default: enabled on x86_64)")
set(WOLFSSL_DES3 ON CACHE STRING "Enable DES3 (default: disabled)")
set(WOLFSSL_PWDBASED ON CACHE STRING "Enable PWDBASED (default: disabled)")
set(WOLFSSL_FAST_MATH ON CACHE STRING "Enable fast math ops (default: disabled)")
set(WOLFSSL_EXAMPLES OFF CACHE STRING "Enable examples (default: enabled)")
set(WOLFSSL_CRYPT_TESTS OFF CACHE STRING "Enable Crypt Bench/Test (default: enabled)")
set(WOLFSSL_ASYNC_THREADS OFF CACHE STRING "Enable Asynchronous Threading (default: enabled)")
set(WOLFSSL_BUILD_OUT_OF_TREE ON CACHE STRING "Don't generate files in the source tree (default: no)")
set(WOLFSSL_SNI ON CACHE STRING "Enable SNI (default: disabled)")
set(WOLFSSL_OPENSSLEXTRA ON CACHE STRING "Enable extra OpenSSL API, size+ (default: disabled)")
set(WOLFSSL_HARDEN OFF CACHE STRING "Enable Hardened build, Enables Timing Resistance and Blinding (default: enabled)")
add_subdirectory(wolfssl EXCLUDE_FROM_ALL)
set(WolfSSL_LIBRARY "$<TARGET_FILE:wolfssl>" CACHE INTERNAL "")
# "${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/wolfssl/" provides openssl headers
# So that curl can be built on an environment where openssl headers are not provided
set(WolfSSL_INCLUDE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/"
"${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/wolfssl/"
"${CMAKE_CURRENT_BINARY_DIR}/wolfssl/"
CACHE INTERNAL "")
target_compile_definitions(wolfssl PUBLIC WOLFSSL_DES_ECB HAVE_WRITE_DUP)
target_compile_definitions(wolfssl PUBLIC FP_MAX_BITS=8192)
endif()

View file

@ -1,14 +1,16 @@
if (USE_SYSTEM_ZLIB)
message(STATUS "-- RPCS3: Using syztem ZLIB")
find_package(ZLIB QUIET)
message(STATUS "RPCS3: Using system ZLIB")
find_package(ZLIB QUIET)
add_library(3rdparty_zlib INTERFACE)
target_link_libraries(3rdparty_zlib INTERFACE ${ZLIB_LIBRARIES})
target_include_directories(3rdparty_zlib INTERFACE ${ZLIB_INCLUDE_DIRS})
else()
message(STATUS "-- RPCS3: Using builtin ZLIB")
message(STATUS "RPCS3: Using builtin ZLIB")
set(SKIP_INSTALL_ALL ON)
add_subdirectory(zlib EXCLUDE_FROM_ALL)
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib" "${CMAKE_CURRENT_BINARY_DIR}/zlib")
set(ZLIB_LIBRARY zlibstatic)
endif()
add_library(3rdparty_zlib INTERFACE)
target_link_libraries(3rdparty_zlib INTERFACE ${ZLIB_LIBRARY})
target_include_directories(3rdparty_zlib INTERFACE ${ZLIB_INCLUDE_DIR})
add_library(3rdparty_zlib INTERFACE)
target_link_libraries(3rdparty_zlib INTERFACE zlibstatic)
target_include_directories(3rdparty_zlib INTERFACE zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib)
endif()