<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="font-family: Times; "><h1 class="title" style="text-align: center; ">according to</h1><h1 class="title" style="text-align: center; ">Notes to authors of FindXXX.cmake files</h1><p>We would like all <em>FindXXX.cmake</em> files to produce consistent variable names.</p><p>Please use the following consistent variable names for general use.</p><dl class="docutils"><dt>XXX_FOUND :</dt><dd style="margin-bottom: 0.5em; ">Set to false, or undefined, if we haven't found, or don't want to use XXX.</dd><dt>XXX_YYY_FOUND :</dt><dd style="margin-bottom: 0.5em; ">If False, optional YYY part of XXX sytem is not available.</dd><dt>XXX_INCLUDE_DIRS :</dt><dd style="margin-bottom: 0.5em; ">The final set of include directories listed in one variable for use by client code. <strong>This should not be a cache entry</strong>!</dd><dt>XXX_LIBRARIES :</dt><dd style="margin-bottom: 0.5em; ">The libraries to link against to use XXX. These should include full paths. <strong>This should not be a cache entry</strong>!</dd><dt>XXX_LIBRARY_DIRS <span class="classifier-delimiter" style="font-family: sans-serif; font-weight: bold; ">:</span> <span class="classifier" style="font-family: sans-serif; font-style: oblique; ">Optionally</span></dt><dd style="margin-bottom: 0.5em; ">The final set of library directories listed in one variable for use by client code. <strong>This should not be a cache entry</strong>!</dd><dt>XXX_DEFINITIONS :</dt><dd style="margin-bottom: 0.5em; ">Definitions to use when compiling code that uses XXX.</dd></dl><div class="note" style="margin-top: 2em; margin-right: 2em; margin-bottom: 2em; margin-left: 2em; border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; border-color: initial; padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; "><p class="first admonition-title" style="margin-top: 0px !important; font-weight: bold; font-family: sans-serif; ">Note</p><p class="last" style="margin-bottom: 0px !important; ">This really shouldn't include options such as (<cite>-DHAS_JPEG</cite>) that a client source-code file uses to decide whether to <cite>#include <jpeg.h></cite>. Too, it <strong>must not</strong> include any compiler flags like <cite>-O3 -Wall</cite> to be tool independent!</p></div><dl class="docutils"></dl></span></div><div><span class="Apple-style-span" style="font-family: Times; "><p>A <em>FindXXX.cmake</em> module will typically be loaded by the command:</p><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">FIND_PACKAGE(XXX [major[.minor[.patch[.tweak]]]] [EXACT]
[QUIET] [[REQUIRED|COMPONENTS] [components...]])
</pre><p>If any version numbers are given to the command it will set the following variables before loading the module:</p><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">XXX_FIND_VERSION = full requested version string
XXX_FIND_VERSION_MAJOR = major version if requested, else 0
XXX_FIND_VERSION_MINOR = minor version if requested, else 0
XXX_FIND_VERSION_PATCH = patch version if requested, else 0
XXX_FIND_VERSION_TWEAK = tweak version if requested, else 0
XXX_FIND_VERSION_COUNT = number of version components, 0 to 4
XXX_FIND_VERSION_EXACT = true if EXACT option was given
</pre><p>If the find module supports versioning it should locate a version of the package that is compatible with the version requested. <em>If a compatible version of the package cannot be found the module should not report success.</em> The version of the package found should be stored in "XXX_VERSION..." version variables documented by the module.</p><p>If the <strong>QUIET</strong> option is given to the command it will set the variable <strong>XXX_FIND_QUIETLY</strong> to true before loading the <em>FindXXX.cmake</em> module. <em>If this variable is set the module should not complain about not being able to find the package</em>.</p><p>If the <strong>REQUIRED</strong> option is given to the command it will set the variable <strong>XXX_FIND_REQUIRED</strong> to true before loading the <em>FindXXX.cmake</em> module. If this variable is set the module should issue a <strong>FATAL_ERROR</strong> if the package cannot be found. For each package-specific component, say YYY, listed after the <strong>REQUIRED</strong> option a variable<strong>XXX_FIND_REQUIRED_YYY</strong> to true.</p><p>The set of components listed after either the <strong>REQUIRED</strong> option or the <strong>COMPONENTS</strong> option will be specified in a <strong>XXX_FIND_COMPONENTS</strong> variable. This can be used by the<em>FindXXX.cmake</em> module to determine which sub-components of the package must be found.</p><p>If neither the <strong>QUIET</strong> nor <strong>REQUIRED</strong> options are given then the <em>FindXXX.cmake</em> module should look for the package and <em>complain without error if the module is not found</em>.</p><div class="tip" style="margin-top: 2em; margin-right: 2em; margin-bottom: 2em; margin-left: 2em; border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; border-color: initial; padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; position: static; z-index: auto; "><p class="first admonition-title" style="margin-top: 0px !important; font-weight: bold; font-family: sans-serif; ">Tip</p><p class="last" style="margin-bottom: 0px !important; ">To get this behaviour you can use the <strong>FIND_PACKAGE_HANDLE_STANDARD_ARGS()</strong> macro, as an example see <a class="reference external" href="file:///Users/clausklein/Workspace/cmake/Tutorials/cmake/FindLibSmi.cmake">FindLibSmi.cmake</a>.</p></div><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; "># - Find LIBSMI
# Find the native LIBSMI includes and library
# This module defines
# LIBSMI_INCLUDE_DIR, where to find smi.h, etc.
# LIBSMI_LIBRARY, the LIBSMI library with full path.
# LIBSMI_FOUND, If false, do not try to use LIBSMI.
# also defined, but not for general use are
# LIBSMI_LIBRARIES, The libraries needed to use LIBSMI.
# LIBSMI_LIBRARY_DIRS, where to find the LIBSMI library.
# LIBSMI_DEFINITIONS - You should add_definitons(${LIBSMI_DEFINITIONS}) before
# compiling code that includes netsnmp library files.
INCLUDE(FindPkgConfig)
IF (PKG_CONFIG_FOUND)
IF (LIBSMI_FIND_REQUIRED AND LIBSMI_FIND_VERSION)
SET(_PACKAGE_ARGS libsmi>=${LIBSMI_FIND_VERSION} REQUIRED)
else ()
SET(_PACKAGE_ARGS libsmi)
ENDIF ()
PKG_CHECK_MODULES(LIBSMI ${_PACKAGE_ARGS})
ENDIF (PKG_CONFIG_FOUND)
SET(LIBSMI_DEFINITIONS ${LIBSMI_CFLAGS_OTHER})
FIND_PATH(LIBSMI_INCLUDE_DIR smi.h HINTS ${LIBSMI_INCLUDE_DIRS})
FIND_LIBRARY(LIBSMI_LIBRARY NAMES smi HINTS ${LIBSMI_LIBRARY_DIRS})
IF (NOT PKG_CONFIG_FOUND)
SET(LIBSMI_LIBRARIES smi)
GET_FILENAME_COMPONENT(LIBSMI_LIBRARY_DIRS ${LIBSMI_LIBRARY} PATH)
ENDIF (NOT PKG_CONFIG_FOUND)
# handle the QUIETLY and REQUIRED arguments and set LIBSMI_FOUND to TRUE if all
# listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSMI DEFAULT_MSG LIBSMI_LIBRARY LIBSMI_INCLUDE_DIR
LIBSMI_LIBRARIES LIBSMI_LIBRARY_DIRS)
MARK_AS_ADVANCED(LIBSMI_LIBRARY LIBSMI_INCLUDE_DIR
LIBSMI_LIBRARIES LIBSMI_LIBRARY_DIRS LIBSMI_DEFINITIONS)
</pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; "><br></pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">--------------------------------------------------------------------</pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">I have tried to get the most of the information available from the system.</pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">This example is trivial, more important would be FindLibXml2.cmake, which does not work in this way!</pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">-- LIBXML2_PREFIX /opt/local
-- LIBXML2_VERSION 2.7.6
-- LIBXML2_INCLUDE_DIR: /usr/include/libxml2
-- LIBXML2_LIBRARY:
-- LIBXML2_LIBRARIES: xml2;pthread;z;iconv;m
-- LIBXML2_LIBRARY_DIRS: /opt/local/lib
-- LIBXML2_DEFINITIONS:
-- LIBXML2_CFLAGS: -I/opt/local/include/libxml2
-- LIBXML2_LDFLAGS: -L/opt/local/lib;-lxml2;-lpthread;-lz;-liconv;-lm
--
-- LIBXSLT_PREFIX /opt/local
-- LIBXSLT_VERSION 1.1.26
-- LIBXSLT_INCLUDE_DIR: /opt/local/include/libxml2
-- LIBXSLT_LIBRARY: /usr/lib/libxslt.dylib
-- LIBXSLT_LIBRARIES: xslt;xml2;pthread;z;iconv;m
-- LIBXSLT_LIBRARY_DIRS: /opt/local/lib
-- LIBXSLT_DEFINITIONS:
-- LIBXSLT_CFLAGS: -I/opt/local/include;-I/opt/local/include/libxml2
-- LIBXSLT_LDFLAGS: -L/opt/local/lib;-lxslt;-lxml2;-lpthread;-lz;-liconv;-lm
--
-- LIBSMI_PREFIX /opt/local
-- LIBSMI_VERSION 0.4.8
-- LIBSMI_INCLUDE_DIR: /opt/local/include
-- LIBSMI_LIBRARY: /opt/local/lib/libsmi.dylib
-- LIBSMI_LIBRARIES: smi
-- LIBSMI_LIBRARY_DIRS: /opt/local/lib
-- LIBSMI_DEFINITIONS:
-- LIBSMI_CFLAGS: -I/opt/local/include
-- LIBSMI_LDFLAGS: -L/opt/local/lib;-lsmi
</pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; "><br></pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">I can send you a patch to get this behavior, if you are interested.</pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">//regards</pre><pre class="literal-block" style="margin-left: 2em; margin-right: 2em; ">Claus Klein</pre></span></div></body></html>