Bug 85857 - [CMake] Rewrite FindGStreamer.cmake.
Summary: [CMake] Rewrite FindGStreamer.cmake.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Raphael Kubo da Costa (:rakuco)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-07 21:33 PDT by Raphael Kubo da Costa (:rakuco)
Modified: 2012-05-08 13:32 PDT (History)
7 users (show)

See Also:


Attachments
Patch (29.15 KB, patch)
2012-05-07 21:41 PDT, Raphael Kubo da Costa (:rakuco)
no flags Details | Formatted Diff | Diff
Use a better name for _pc_name (29.16 KB, patch)
2012-05-08 07:37 PDT, Raphael Kubo da Costa (:rakuco)
dbates: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael Kubo da Costa (:rakuco) 2012-05-07 21:33:40 PDT
We are currently kind of duplicating the same FindGStreamer-Foo.cmake file whenever a new GStreamer plugin needs to be found. Besides this approach not scaling very well, it relies on pkg-config for version checking, uses the LibFindMacros package that we should deprecate and all the find files could be merged into one, with users using the COMPONENTS feature of the FIND_PACKAGE() call to find the desired plugins.
Comment 1 Raphael Kubo da Costa (:rakuco) 2012-05-07 21:41:11 PDT
Created attachment 140667 [details]
Patch
Comment 2 Daniel Bates 2012-05-07 21:55:00 PDT
Comment on attachment 140667 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=140667&action=review

> Source/cmake/FindGStreamer.cmake:50
> +#   _pc_name is the component's pkg-config name (eg. "gstreamer-0.10", or "gstreamer-video-0.10").

Maybe _pkgconfig_name is a more descriptive name for this argument?

> Source/cmake/FindGStreamer.cmake:92
> +IF (GSTREAMER_INCLUDE_DIRS)
> +    IF (EXISTS "${GSTREAMER_INCLUDE_DIRS}/gst/gstversion.h")
> +        FILE (READ "${GSTREAMER_INCLUDE_DIRS}/gst/gstversion.h" GSTREAMER_VERSION_CONTENTS)
> +
> +        STRING(REGEX MATCH "#define +GST_VERSION_MAJOR +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
> +        SET(GSTREAMER_VERSION_MAJOR "${CMAKE_MATCH_1}")
> +
> +        STRING(REGEX MATCH "#define +GST_VERSION_MINOR +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
> +        SET(GSTREAMER_VERSION_MINOR "${CMAKE_MATCH_1}")
> +
> +        STRING(REGEX MATCH "#define +GST_VERSION_MICRO +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
> +        SET(GSTREAMER_VERSION_MICRO "${CMAKE_MATCH_1}")
> +
> +        SET(GSTREAMER_VERSION "${GSTREAMER_VERSION_MAJOR}.${GSTREAMER_VERSION_MINOR}.${GSTREAMER_VERSION_MICRO}")
> +    ENDIF ()
> +ENDIF ()

This code is almost identical to code in FindCairo.cmake. Can we extract the common code into a shared function?
Comment 3 Raphael Kubo da Costa (:rakuco) 2012-05-08 07:32:49 PDT
Comment on attachment 140667 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=140667&action=review

>> Source/cmake/FindGStreamer.cmake:92
>> +ENDIF ()
> 
> This code is almost identical to code in FindCairo.cmake. Can we extract the common code into a shared function?

I'm unsure about how to do that -- the regular expressions here and in FindCairo.cmake are slightly different, for example (gstreamer uses "#define FOO_MAJOR (0)" and cairo uses "#define FOO_MAJOR 0", and making the ()s optional might not be very future-proof).
Comment 4 Raphael Kubo da Costa (:rakuco) 2012-05-08 07:37:04 PDT
Created attachment 140718 [details]
Use a better name for _pc_name
Comment 5 Daniel Bates 2012-05-08 13:14:49 PDT
(In reply to comment #3)
> (From update of attachment 140667 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=140667&action=review
> 
> >> Source/cmake/FindGStreamer.cmake:92
> >> +ENDIF ()
> > 
> > This code is almost identical to code in FindCairo.cmake. Can we extract the common code into a shared function?
> 
> I'm unsure about how to do that -- the regular expressions here and in FindCairo.cmake are slightly different, for example (gstreamer uses "#define FOO_MAJOR (0)" and cairo uses "#define FOO_MAJOR 0", and making the ()s optional might not be very future-proof).

Thanks for taking a look. The code you have in this patch is sufficient.
Comment 6 Raphael Kubo da Costa (:rakuco) 2012-05-08 13:32:14 PDT
Committed r116453: <http://trac.webkit.org/changeset/116453>