[waffle] [PATCH] RFC: add FindWAFFLE.cmake

Chad Versace chad.versace at linux.intel.com
Wed Oct 17 12:04:22 PDT 2012


By the way, in addition to Android, MS Windows will also require a FindWaffle
module.

Problems:
  - There's a lot of cruft left from the original FindPNG.cmake. All references
    to png and "WAFFLE images" and zlib need to be removed.

  - PNG is an acronym, Waffle is not. The module should be named
    FindWaffle.cmake. Exported variable names, however, should remain ALL CAPS,
    because that's the common CMake convention.

  - This file is not copyright KitWare. It's copyright Intel. Use the copyright
    header found in the Waffle's toplevel CMakeLists.txt.

  - Don't define WAFFLE_INCLUDE_DIR "for backwards compatibility". This module
    has nothing to be backwards compatible with.

  - Likewise, don't define WAFFLE_LIBRARY.

  - Don't define WAFFLE_WAFFLE_INCLUDE_DIR. The only CMake modules that define
    sub-variables for include dirs and libraries are for projects that contain
    multiple components, such as FindQt4.cmake. Defining only
    WAFFLE_INCLUDE_DIRW is sufficient.

  - Use the style in Waffle's other CMake files. That is: 4-space indent;
    `if(...)`, not `if (...)`.

  - More problems below inline.

On 10/17/2012 10:31 AM, groleo at gmail.com wrote:
> From: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
> 
> Problem:
> piglit searches waffle by using pkg_check_modules.
> If one tried to use cmake and android toghether,
> waffle won't be found, since pkg_check_modules relies on
> pkg-config(missing on android)
> 
> Proposed fix:
> add a Module file so that find_package can be used
> instead of pkg_check_modules.
> 
> Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
> ---
>  cmake/Modules/FindWAFFLE.cmake | 48 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 cmake/Modules/FindWAFFLE.cmake
> 
> diff --git a/cmake/Modules/FindWAFFLE.cmake b/cmake/Modules/FindWAFFLE.cmake
> new file mode 100644
> index 0000000..91c9332
> --- /dev/null
> +++ b/cmake/Modules/FindWAFFLE.cmake
> @@ -0,0 +1,48 @@
> +# - Find the native WAFFLE includes and library
> +#
> +# This module searches libpng, the library for working with WAFFLE images.
> +#
> +# It defines the following variables
> +#  WAFFLE_INCLUDE_DIRS, where to find png.h, etc.
> +#  WAFFLE_LIBRARIES, the libraries to link against to use WAFFLE.
> +#  WAFFLE_DEFINITIONS - You should add_definitons(${WAFFLE_DEFINITIONS}) before compiling code that includes png library files.
> +#  WAFFLE_FOUND, If false, do not try to use WAFFLE.
> +# Also defined, but not for general use are
> +#  WAFFLE_LIBRARY, where to find the WAFFLE library.

Please format the block above so that is readable. All the lines bleed
together. For a good example, see FindQt4.cmake. Use one of the forms below:

(1)

# WAFFLE_INCLUDE_DIRS
#     This variable does stuff.
#
# WAFFLE_DEFINITIONS
#     Do more stuff.

(2)

# WAFFLE_INCLUDE_DIRS      This variable does stuff.
# WAFFLE_DEFINITONS        Do more stuff.

> +# For backward compatiblity the variable WAFFLE_INCLUDE_DIR is also set. It has the same value as WAFFLE_INCLUDE_DIRS.
> +#
> +# Since WAFFLE depends on the ZLib compression library, none of the above will be
> +# defined unless ZLib can be found.
> +
> +#=============================================================================
> +# Copyright 2002-2009 Kitware, Inc.
> +#
> +# Distributed under the OSI-approved BSD License (the "License");
> +# see accompanying file Copyright.txt for details.
> +#
> +# This software is distributed WITHOUT ANY WARRANTY; without even the
> +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> +# See the License for more information.
> +#=============================================================================
> +# (To distribute this file outside of CMake, substitute the full
> +#  License text for the above reference.)
> +
> +  find_path(WAFFLE_WAFFLE_INCLUDE_DIR waffle.h)
> +
> +  set(WAFFLE_NAMES ${WAFFLE_NAMES} waffle)
> +  find_library(WAFFLE_LIBRARY NAMES ${WAFFLE_NAMES} )
> +
> +  if (WAFFLE_LIBRARY AND WAFFLE_WAFFLE_INCLUDE_DIR)
> +      SET(WAFFLE_INCLUDE_DIRS ${WAFFLE_WAFFLE_INCLUDE_DIR})
> +      SET(WAFFLE_INCLUDE_DIR ${WAFFLE_INCLUDE_DIRS} ) # for backward compatiblity
> +      SET(WAFFLE_LIBRARIES ${WAFFLE_LIBRARY})
> +
> +  endif (WAFFLE_LIBRARY AND WAFFLE_WAFFLE_INCLUDE_DIR)

The outer block of the code above needs to have no leading space. Again, see
Waffle's toplevel CMakeLists for how the style should look.

> +
> +
> +# handle the QUIETLY and REQUIRED arguments and set WAFFLE_FOUND to TRUE if
> +# all listed variables are TRUE
> +include(/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake)
> +find_package_handle_standard_args(WAFFLE  DEFAULT_MSG  WAFFLE_LIBRARY WAFFLE_WAFFLE_INCLUDE_DIR)
> +
> +mark_as_advanced(WAFFLE_WAFFLE_INCLUDE_DIR WAFFLE_LIBRARY )
> 



More information about the waffle mailing list