From c5c60e04ddae03165dc05b7f4a53969662b28cc3 Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Sat, 9 May 2020 11:11:18 +0200 Subject: [PATCH 1/6] Check for the zstd version --- externals/find-modules/Findzstd.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/externals/find-modules/Findzstd.cmake b/externals/find-modules/Findzstd.cmake index cd0158b0c..539abbafc 100644 --- a/externals/find-modules/Findzstd.cmake +++ b/externals/find-modules/Findzstd.cmake @@ -11,12 +11,26 @@ find_library(zstd_LIBRARY PATHS ${PC_zstd_LIBRARY_DIRS} ) +if(zstd_INCLUDE_DIR) + file(STRINGS "${zstd_INCLUDE_DIR}/zstd.h" _zstd_version_lines + REGEX "#define[ \t]+ZSTD_VERSION_(MAJOR|MINOR|RELEASE)") + string(REGEX REPLACE ".*ZSTD_VERSION_MAJOR *\([0-9]*\).*" "\\1" _zstd_version_major "${_zstd_version_lines}") + string(REGEX REPLACE ".*ZSTD_VERSION_MINOR *\([0-9]*\).*" "\\1" _zstd_version_minor "${_zstd_version_lines}") + string(REGEX REPLACE ".*ZSTD_VERSION_RELEASE *\([0-9]*\).*" "\\1" _zstd_version_release "${_zstd_version_lines}") + set(zstd_VERSION "${_zstd_version_major}.${_zstd_version_minor}.${_zstd_version_release}") + unset(_zstd_version_major) + unset(_zstd_version_minor) + unset(_zstd_version_release) + unset(_zstd_version_lines) +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(zstd FOUND_VAR zstd_FOUND REQUIRED_VARS zstd_LIBRARY zstd_INCLUDE_DIR + zstd_VERSION VERSION_VAR zstd_VERSION ) From ef1f59659552f516b3d3255af66f9c9151966611 Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Sat, 9 May 2020 11:14:47 +0200 Subject: [PATCH 2/6] Fix libzip version check --- externals/find-modules/FindLibzip.cmake | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/externals/find-modules/FindLibzip.cmake b/externals/find-modules/FindLibzip.cmake index 0b5148856..f36b1687a 100644 --- a/externals/find-modules/FindLibzip.cmake +++ b/externals/find-modules/FindLibzip.cmake @@ -28,6 +28,16 @@ find_library(LIBZIP_LIBRARY "$ENV{LIB_DIR}/lib" "$ENV{LIB}" /usr/local/lib /usr/lib ) +if (LIBZIP_INCLUDE_DIR_ZIPCONF) + FILE(READ "${LIBZIP_INCLUDE_DIR_ZIPCONF}/zipconf.h" _LIBZIP_VERSION_CONTENTS) + if (_LIBZIP_VERSION_CONTENTS) + STRING(REGEX REPLACE ".*#define LIBZIP_VERSION \"([0-9.]+)\".*" "\\1" LIBZIP_VERSION "${_LIBZIP_VERSION_CONTENTS}") + endif() + unset(_LIBZIP_VERSION_CONTENTS) +endif() + +set(LIBZIP_VERSION ${LIBZIP_VERSION} CACHE STRING "Version number of libzip") + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Libzip FOUND_VAR LIBZIP_FOUND @@ -35,19 +45,10 @@ find_package_handle_standard_args(Libzip LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR LIBZIP_INCLUDE_DIR_ZIPCONF + LIBZIP_VERSION + VERSION_VAR LIBZIP_VERSION ) -set(LIBZIP_VERSION 0) - -if (LIBZIP_INCLUDE_DIR_ZIPCONF) - FILE(READ "${LIBZIP_INCLUDE_DIR_ZIPCONF}/zipconf.h" _LIBZIP_VERSION_CONTENTS) - if (_LIBZIP_VERSION_CONTENTS) - STRING(REGEX REPLACE ".*#define LIBZIP_VERSION \"([0-9.]+)\".*" "\\1" LIBZIP_VERSION "${_LIBZIP_VERSION_CONTENTS}") - endif() -endif() - -set(LIBZIP_VERSION ${LIBZIP_VERSION} CACHE STRING "Version number of libzip") - if(LIBZIP_FOUND) set(LIBZIP_LIBRARIES ${LIBZIP_LIBRARY}) set(LIBZIP_INCLUDE_DIRS ${LIBZIP_INCLUDE_DIR}) @@ -65,5 +66,7 @@ endif() mark_as_advanced( LIBZIP_INCLUDE_DIR + LIBZIP_INCLUDE_DIR_ZIPCONF LIBZIP_LIBRARY + LIBZIP_VERSION ) From 0e2a7ca91b23fa35fdd9e55879f4b7ba4f70d2b6 Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Sat, 9 May 2020 11:32:52 +0200 Subject: [PATCH 3/6] Add version check to Findfmt --- externals/find-modules/Findfmt.cmake | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/externals/find-modules/Findfmt.cmake b/externals/find-modules/Findfmt.cmake index e0a04a344..8ba51cbea 100644 --- a/externals/find-modules/Findfmt.cmake +++ b/externals/find-modules/Findfmt.cmake @@ -13,12 +13,38 @@ find_library(fmt_LIBRARY PATHS ${PC_fmt_LIBRARY_DIRS} ${CONAN_LIB_DIRS_fmt} ) +if(fmt_INCLUDE_DIR) + set(_fmt_version_file "${fmt_INCLUDE_DIR}/core.h") + if(NOT EXISTS "${_fmt_version_file}") + set(_fmt_version_file "${fmt_INCLUDE_DIR}/format.h") + endif() + if(EXISTS "${_fmt_version_file}") + # parse "#define FMT_VERSION 60200" to 6.2.0 + file(STRINGS "${_fmt_version_file}" fmt_VERSION_LINE + REGEX "^#define[ \t]+FMT_VERSION[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+FMT_VERSION[ \t]+([0-9]+)$" + "\\1" fmt_VERSION "${fmt_VERSION_LINE}") + foreach(ver "fmt_VERSION_PATCH" "fmt_VERSION_MINOR" "fmt_VERSION_MAJOR") + math(EXPR ${ver} "${fmt_VERSION} % 100") + math(EXPR fmt_VERSION "(${fmt_VERSION} - ${${ver}}) / 100") + endforeach() + set(fmt_VERSION + "${fmt_VERSION_MAJOR}.${fmt_VERSION_MINOR}.${fmt_VERSION_PATCH}") + endif() + unset(_fmt_version_file) + unset(fmt_VERSION_LINE) + unset(fmt_VERSION_MAJOR) + unset(fmt_VERSION_MINOR) + unset(fmt_VERSION_PATCH) +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(fmt FOUND_VAR fmt_FOUND REQUIRED_VARS fmt_LIBRARY fmt_INCLUDE_DIR + fmt_VERSION VERSION_VAR fmt_VERSION ) From c96a8867f01ed2c454196629f032ae0a837c1cd3 Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Sat, 9 May 2020 11:42:56 +0200 Subject: [PATCH 4/6] Add version check for catch2 --- externals/find-modules/FindCatch2.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/externals/find-modules/FindCatch2.cmake b/externals/find-modules/FindCatch2.cmake index a83c668bf..ce1d40bae 100644 --- a/externals/find-modules/FindCatch2.cmake +++ b/externals/find-modules/FindCatch2.cmake @@ -8,11 +8,25 @@ find_path(Catch2_INCLUDE_DIR PATH_SUFFIXES catch2 ) +if(Catch2_INCLUDE_DIR) + file(STRINGS "${Catch2_INCLUDE_DIR}/catch.hpp" _Catch2_version_lines + REGEX "#define[ \t]+CATCH_VERSION_(MAJOR|MINOR|PATCH)") + string(REGEX REPLACE ".*CATCH_VERSION_MAJOR +\([0-9]+\).*" "\\1" _Catch2_version_major "${_Catch2_version_lines}") + string(REGEX REPLACE ".*CATCH_VERSION_MINOR +\([0-9]+\).*" "\\1" _Catch2_version_minor "${_Catch2_version_lines}") + string(REGEX REPLACE ".*CATCH_VERSION_PATCH +\([0-9]+\).*" "\\1" _Catch2_version_patch "${_Catch2_version_lines}") + set(Catch2_VERSION "${_Catch2_version_major}.${_Catch2_version_minor}.${_Catch2_version_patch}") + unset(_Catch2_version_major) + unset(_Catch2_version_minor) + unset(_Catch2_version_patch) + unset(_Catch2_version_lines) +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Catch2 FOUND_VAR Catch2_FOUND REQUIRED_VARS Catch2_INCLUDE_DIR + Catch2_VERSION VERSION_VAR Catch2_VERSION ) From 290bc20e7985cbf75780d7f6033d64fa5e70cf45 Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Sat, 9 May 2020 11:46:03 +0200 Subject: [PATCH 5/6] Add version check to Findnlohmann_json.cmake --- externals/find-modules/Findnlohmann_json.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/externals/find-modules/Findnlohmann_json.cmake b/externals/find-modules/Findnlohmann_json.cmake index a3bf1d774..b0c5b3e4e 100644 --- a/externals/find-modules/Findnlohmann_json.cmake +++ b/externals/find-modules/Findnlohmann_json.cmake @@ -8,11 +8,25 @@ find_path(nlohmann_json_INCLUDE_DIR PATH_SUFFIXES nlohmann ) +if(nlohmann_json_INCLUDE_DIR) + file(STRINGS "${nlohmann_json_INCLUDE_DIR}/json.hpp" _nlohmann_json_version_lines + REGEX "#define[ \t]+NLOHMANN_JSON_VERSION_(MAJOR|MINOR|PATCH)") + string(REGEX REPLACE ".*NLOHMANN_JSON_VERSION_MAJOR +\([0-9]+\).*" "\\1" _nlohmann_json_version_major "${_nlohmann_json_version_lines}") + string(REGEX REPLACE ".*NLOHMANN_JSON_VERSION_MINOR +\([0-9]+\).*" "\\1" _nlohmann_json_version_minor "${_nlohmann_json_version_lines}") + string(REGEX REPLACE ".*NLOHMANN_JSON_VERSION_PATCH +\([0-9]+\).*" "\\1" _nlohmann_json_version_patch "${_nlohmann_json_version_lines}") + set(nlohmann_json_VERSION "${_nlohmann_json_version_major}.${_nlohmann_json_version_minor}.${_nlohmann_json_version_patch}") + unset(_nlohmann_json_version_major) + unset(_nlohmann_json_version_minor) + unset(_nlohmann_json_version_patch) + unset(_nlohmann_json_version_lines) +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(nlohmann_json FOUND_VAR nlohmann_json_FOUND REQUIRED_VARS nlohmann_json_INCLUDE_DIR + nlohmann_json_VERSION VERSION_VAR nlohmann_json_VERSION ) From e8baf07136645a9b17875967f24375db1c68c059 Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Sat, 9 May 2020 11:49:21 +0200 Subject: [PATCH 6/6] Mark the opus version check as broken. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0381e4af7..61321bf0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,7 @@ macro(yuzu_find_packages) #"libzip 1.5 libzip/1.5.2@bincrafters/stable" "lz4 1.8 lz4/1.9.2" "nlohmann_json 3.7 nlohmann_json/3.7.3" + # we need to be careful as the version check might be broken https://github.com/xiph/opus/issues/110 "opus 1.3 opus/1.3.1" "ZLIB 1.2 zlib/1.2.11" "zstd 1.4 zstd/1.4.4"