From 52721a41ff1681fa4f2334d4ce9ae70c647da73d Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Wed, 4 May 2016 11:51:13 -0500 Subject: [PATCH] fix sfml cmake version parser and ffmpeg test --- CMakeLists.txt | 2 +- cmake/modules/FindSFML.cmake | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b119b52cc..d9aabd997 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,7 @@ endif() # FFmpeg if(NOT NO_MOVIE) find_package(FFmpeg COMPONENTS avformat avcodec avutil swscale swresample) - if(NOT FFMPEG_FOUND) + if(NOT FFMPEG_SWRESAMPLE_FOUND) find_package(FFmpeg COMPONENTS avformat avcodec avutil swscale avresample REQUIRED) endif() endif() diff --git a/cmake/modules/FindSFML.cmake b/cmake/modules/FindSFML.cmake index 09dabbffa..083c065e5 100644 --- a/cmake/modules/FindSFML.cmake +++ b/cmake/modules/FindSFML.cmake @@ -89,11 +89,19 @@ if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR) set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp") endif() FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS) - STRING(REGEX MATCH ".*#define SFML_VERSION_MAJOR ([0-9]+).*#define SFML_VERSION_MINOR ([0-9]+).*#define SFML_VERSION_PATCH ([0-9]+).*" SFML_CONFIG_HPP_CONTENTS "${SFML_CONFIG_HPP_CONTENTS}") - STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}") - STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}") - STRING(REGEX REPLACE ".*#define SFML_VERSION_PATCH ([0-9]+).*" "\\1" SFML_VERSION_PATCH "${SFML_CONFIG_HPP_CONTENTS}") - math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10000 + ${SFML_FIND_VERSION_MINOR} * 100 + ${SFML_FIND_VERSION_PATCH}") + STRING(REGEX MATCHALL "#define SFML_VERSION_(MAJOR|MINOR|PATCH) ([0-9]+)" matches "${SFML_CONFIG_HPP_CONTENTS}") + STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${matches}") + if(NOT SFML_VERSION_MAJOR MATCHES "^[0-9]+$") + unset(SFML_VERSION_MAJOR) + endif() + STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${matches}") + if(NOT SFML_VERSION_MINOR MATCHES "^[0-9]+$") + set(SFML_VERSION_MINOR 0) + endif() + STRING(REGEX REPLACE ".*#define SFML_VERSION_PATCH ([0-9]+).*" "\\1" SFML_VERSION_PATCH "${matches}") + if(NOT SFML_VERSION_PATCH MATCHES "^[0-9]+$") + set(SFML_VERSION_PATCH 0) + endif() # if we could extract them, compare with the requested version number if (SFML_VERSION_MAJOR)