diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e27b1caf1..67f380bc23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,7 @@ option(USE_SYSTEM_LIBUSB "Use the system libusb (instead of the bundled libusb)" option(USE_SYSTEM_CPP_JWT "Use the system cpp-jwt (instead of the bundled one)" OFF) option(USE_SYSTEM_SOUNDTOUCH "Use the system SoundTouch (instead of the bundled one)" OFF) option(USE_SYSTEM_CPP_HTTPLIB "Use the system cpp-httplib (instead of the bundled one)" OFF) +option(USE_SYSTEM_JSON "Use the system JSON (nlohmann-json3) package (instead of the bundled one)" OFF) if (CITRA_USE_PRECOMPILED_HEADERS) message(STATUS "Using Precompiled Headers.") diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index ca5b4d4c8c..3d14c51e0c 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -175,7 +175,16 @@ endif() # JSON add_library(json-headers INTERFACE) -target_include_directories(json-headers INTERFACE ./json) +if (USE_SYSTEM_JSON) + find_package(nlohmann_json REQUIRED) + target_link_libraries(json-headers INTERFACE nlohmann_json::nlohmann_json) + get_target_property(NLOHMANN_PREFIX nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES) + # The nlohmann-json3 package expects "#include " + # Citra uses "#include " so we have to add this manually + target_include_directories(json-headers SYSTEM INTERFACE "${NLOHMANN_PREFIX}/nlohmann") +else() + target_include_directories(json-headers SYSTEM INTERFACE ./json) +endif() # OpenSSL if (USE_SYSTEM_OPENSSL) @@ -200,8 +209,13 @@ endif() # httplib add_library(httplib INTERFACE) if(USE_SYSTEM_CPP_HTTPLIB) - find_package(CppHttp REQUIRED) - target_link_libraries(httplib SYSTEM INTERFACE cpp-httplib::cpp-httplib) + find_package(CppHttp 0.14.1) + if(CppHttp_FOUND) + target_link_libraries(httplib SYSTEM INTERFACE cpp-httplib::cpp-httplib) + else() + message(STATUS "Cpp-httplib not found or not suitable version! Falling back to bundled...") + target_include_directories(httplib SYSTEM INTERFACE ./httplib) + endif() else() target_include_directories(httplib SYSTEM INTERFACE ./httplib) endif() diff --git a/externals/cmake-modules/FindCppHttp.cmake b/externals/cmake-modules/FindCppHttp.cmake index b91cc9f6e1..fe17c8babf 100644 --- a/externals/cmake-modules/FindCppHttp.cmake +++ b/externals/cmake-modules/FindCppHttp.cmake @@ -14,14 +14,8 @@ if(NOT CppHttp_FOUND) /usr/lib /usr/local/lib ) - - if(CPP-HTTP_INCLUDE_DIR AND CPP-HTTP_LIBRARIES) - set(CppHttp_FOUND TRUE CACHE INTERNAL "cpp-httplib found") - message(STATUS "Found cpp-httplib: ${CPP-HTTP_INCLUDE_DIR}, ${CPP-HTTP_LIBRARIES}") - else() - set(CppHttp_FOUND FALSE CACHE INTERNAL "cpp-httplib found") - message(STATUS "Cpp-httplib not found.") - endif() + + find_package_handle_standard_args(CppHttp REQUIRED_VARS CPP-HTTP_INCLUDE_DIR CPP-HTTP_LIBRARIES VERSION_VAR HTTP_TMP_VERSION) endif() diff --git a/src/video_core/shader/generator/glsl_shader_decompiler.cpp b/src/video_core/shader/generator/glsl_shader_decompiler.cpp index ee012589b0..4c8dffd64b 100644 --- a/src/video_core/shader/generator/glsl_shader_decompiler.cpp +++ b/src/video_core/shader/generator/glsl_shader_decompiler.cpp @@ -828,13 +828,6 @@ private: void Generate() { if (sanitize_mul) { -#ifdef ANDROID - // Use a cheaper sanitize_mul on Android, as mobile GPUs struggle here - // This seems to be sufficient at least for Ocarina of Time and Attack on Titan accurate - // multiplication bugs - shader.AddLine( - "#define sanitize_mul(lhs, rhs) mix(lhs * rhs, vec4(0.0), isnan(lhs * rhs))"); -#else shader.AddLine("vec4 sanitize_mul(vec4 lhs, vec4 rhs) {{"); ++shader.scope; shader.AddLine("vec4 product = lhs * rhs;"); @@ -842,7 +835,6 @@ private: "isnan(lhs)), isnan(product));"); --shader.scope; shader.AddLine("}}\n"); -#endif } shader.AddLine("vec4 get_offset_register(int base_index, int offset) {{");