blob: 796c3dfa6ed24bd9df4146680aa933ffd0c1f787 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FindFLEX &mdash; CMake 3.23.1 Documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/cmake.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="shortcut icon" href="../_static/cmake-favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="FindFLTK" href="FindFLTK.html" />
<link rel="prev" title="FindEXPAT" href="FindEXPAT.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="FindFLTK.html" title="FindFLTK"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="FindEXPAT.html" title="FindEXPAT"
accesskey="P">previous</a> |</li>
<li>
<img src="../_static/cmake-logo-16.png" alt=""
style="vertical-align: middle; margin-top: -2px" />
</li>
<li>
<a href="https://cmake.org/">CMake</a> &#187;
</li>
<li>
<a href="../index.html">3.23.1 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">FindFLEX</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="findflex">
<span id="module:FindFLEX"></span><h1>FindFLEX<a class="headerlink" href="#findflex" title="Permalink to this headline">ΒΆ</a></h1>
<p>Find Fast Lexical Analyzer (Flex) executable and provides a macro
to generate custom build rules</p>
<p>The module defines the following variables:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>FLEX_FOUND - True is flex executable is found
FLEX_EXECUTABLE - the path to the flex executable
FLEX_VERSION - the version of flex
FLEX_LIBRARIES - The flex libraries
FLEX_INCLUDE_DIRS - The path to the flex headers
</pre></div>
</div>
<p>The minimum required version of flex can be specified using the
standard syntax, e.g. <span class="target" id="index-0-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_package(FLEX</span> <span class="pre">2.5.13)</span></code></a></p>
<p>If flex is found on the system, the module provides the macro:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>FLEX_TARGET(Name FlexInput FlexOutput
[COMPILE_FLAGS &lt;string&gt;]
[DEFINES_FILE &lt;string&gt;]
)
</pre></div>
</div>
<p>which creates a custom command to generate the <code class="docutils literal notranslate"><span class="pre">FlexOutput</span></code> file from
the <code class="docutils literal notranslate"><span class="pre">FlexInput</span></code> file. Name is an alias used to get details of this custom
command. If <code class="docutils literal notranslate"><span class="pre">COMPILE_FLAGS</span></code> option is specified, the next
parameter is added to the flex command line.</p>
<div class="versionadded">
<p><span class="versionmodified added">New in version 3.5: </span>If flex is configured to
output a header file, the <code class="docutils literal notranslate"><span class="pre">DEFINES_FILE</span></code> option may be used to specify its
name.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.17: </span>When <span class="target" id="index-0-policy:CMP0098"></span><a class="reference internal" href="../policy/CMP0098.html#policy:CMP0098" title="CMP0098"><code class="xref cmake cmake-policy docutils literal notranslate"><span class="pre">CMP0098</span></code></a> is set to <code class="docutils literal notranslate"><span class="pre">NEW</span></code>, <code class="docutils literal notranslate"><span class="pre">flex</span></code> runs in the
<span class="target" id="index-0-variable:CMAKE_CURRENT_BINARY_DIR"></span><a class="reference internal" href="../variable/CMAKE_CURRENT_BINARY_DIR.html#variable:CMAKE_CURRENT_BINARY_DIR" title="CMAKE_CURRENT_BINARY_DIR"><code class="xref cmake cmake-variable docutils literal notranslate"><span class="pre">CMAKE_CURRENT_BINARY_DIR</span></code></a> directory.</p>
</div>
<p>The macro defines the following variables:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>FLEX_${Name}_DEFINED - true is the macro ran successfully
FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
alias for FlexOutput
FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any.
</pre></div>
</div>
<p>Flex scanners often use tokens defined by Bison: the code generated
by Flex depends of the header generated by Bison. This module also
defines a macro:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget)
</pre></div>
</div>
<p>which adds the required dependency between a scanner and a parser
where <code class="docutils literal notranslate"><span class="pre">FlexTarget</span></code> and <code class="docutils literal notranslate"><span class="pre">BisonTarget</span></code> are the first parameters of
respectively <code class="docutils literal notranslate"><span class="pre">FLEX_TARGET</span></code> and <code class="docutils literal notranslate"><span class="pre">BISON_TARGET</span></code> macros.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>====================================================================
Example:
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>find_package(BISON)
find_package(FLEX)
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
FLEX_TARGET(MyScanner lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp)
ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(Foo
Foo.cc
${BISON_MyParser_OUTPUTS}
${FLEX_MyScanner_OUTPUTS}
)
target_link_libraries(Foo ${FLEX_LIBRARIES})
====================================================================
</pre></div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="FindEXPAT.html"
title="previous chapter">FindEXPAT</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="FindFLTK.html"
title="next chapter">FindFLTK</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/module/FindFLEX.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="FindFLTK.html" title="FindFLTK"
>next</a> |</li>
<li class="right" >
<a href="FindEXPAT.html" title="FindEXPAT"
>previous</a> |</li>
<li>
<img src="../_static/cmake-logo-16.png" alt=""
style="vertical-align: middle; margin-top: -2px" />
</li>
<li>
<a href="https://cmake.org/">CMake</a> &#187;
</li>
<li>
<a href="../index.html">3.23.1 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">FindFLEX</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2000-2022 Kitware, Inc. and Contributors.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
</div>
</body>
</html>