<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:"DejaVu Sans Mono";
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.pre
{mso-style-name:pre;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">I thought that the find script itself was responsible for checking the required flag?
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">Our own find scripts do something along the lines of (note that we named ours sqlite, not sqlite3!)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">if(NOT sqlite_FIND_QUIETLY)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"> MESSAGE(STATUS "Looking for sqlite...")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">endif()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">… look for package here<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">… if not found and required, signal fatal error:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"> if(sqlite_FIND_REQUIRED)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"> message(FATAL_ERROR "Looking for sqlite... - Not found")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"> endif()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">From the CMake documentation on find_package:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:justify;line-height:15.6pt;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444">When loading a find module or package configuration file </span><span style="font-size:11.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3">find_package</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444"> defines
variables to provide information about the call arguments (and restores their original state before returning):<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:justify;line-height:15.6pt;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444">…<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:22.5pt;background:white"><span style="font-size:11.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3"><package>_FIND_REQUIRED</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:2.25pt;margin-right:0cm;margin-bottom:7.5pt;margin-left:36.0pt;text-align:justify;line-height:15.6pt;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444">true if </span><span style="font-size:11.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3">REQUIRED</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444"> option
was given<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:45.0pt;background:white"><span style="font-size:11.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3"><package>_FIND_QUIETLY</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:2.25pt;margin-right:0cm;margin-bottom:7.5pt;margin-left:36.0pt;text-align:justify;line-height:15.6pt;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444">true if </span><span style="font-size:11.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3">QUIET</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444"> option
was given<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444;background:yellow;mso-highlight:yellow">In Module mode the loaded find module is responsible to honor the request detailed by these variables</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444;background:white">;
see the find module for details. In Config mode </span><span class="pre"><span style="font-size:10.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3">find_package</span></span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444;background:white"> handles </span><span class="pre"><span style="font-size:10.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3">REQUIRED</span></span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444;background:white">, </span><span class="pre"><span style="font-size:10.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3">QUIET</span></span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444;background:white">,
and </span><span class="pre"><span style="font-size:10.5pt;font-family:"Courier New";color:#444444;background:#ECF0F3">[version]</span></span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#444444;background:white"> options automatically </span><span style="color:windowtext;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">Mark<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="color:windowtext">From:</span></b><span lang="EN-US" style="color:windowtext"> CMake <cmake-bounces@cmake.org>
<b>On Behalf Of </b>Quaquaraquà<br>
<b>Sent:</b> 08 July 2018 22:35<br>
<b>To:</b> Cmake Mailing List <cmake@cmake.org><br>
<b>Subject:</b> [CMake] find_package: keyword REQUIRED ignored<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hi there,<o:p></o:p></p>
<p>I'm using a custom script [1] to look for the library sqlite3. However, the keyword "REQUIRED" (as quietly) is ignored by find_package. That is even if the library is not found, the script continues is processing:<o:p></o:p></p>
<p>// CMakeLists.txt<o:p></o:p></p>
<pre style="background:white"><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">cmake_minimum_required(</span><b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif;color:green">VERSION 3.10</span></b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">)</span><i><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif;color:gray"><o:p></o:p></span></i></pre>
<pre style="background:white"><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">project(</span><b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif;color:green">hello_world</span></b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">)</span><i><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif;color:gray"><o:p></o:p></span></i></pre>
<pre style="background:white"><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">list(</span><b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif;color:green">APPEND CMAKE_MODULE_PATH </span></b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">"</span><b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif;color:green">${CMAKE_SOURCE_DIR}/build-aux/</span></b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">")<o:p></o:p></span></pre>
<pre style="background:white"><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">find_package(</span><b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif;color:green">SQLite3 REQUIRED</span></b><span style="font-size:11.5pt;font-family:"DejaVu Sans Mono",serif">)<o:p></o:p></span></pre>
<p>// output:<o:p></o:p></p>
<p>cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G "CodeBlocks - Unix Makefiles" ../<br>
-- Could NOT find SQLITE3 (missing: SQLITE3_LIBRARY) <br>
-- Configuring done<br>
-- Generating done<br>
-- Build files have been written to: ...<o:p></o:p></p>
<p><o:p> </o:p></p>
<p>Any idea what is wrong here?<o:p></o:p></p>
<p><o:p> </o:p></p>
<p>[1] <a href="https://github.com/LuaDist/libsqlite3/blob/master/cmake/FindSQLite3.cmake">
https://github.com/LuaDist/libsqlite3/blob/master/cmake/FindSQLite3.cmake</a><o:p></o:p></p>
</div>
</body>
</html>