<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/112151/">http://git.reviewboard.kde.org/r/112151/</a>
     </td>
    </tr>
   </table>
   <br />











<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/112151/diff/3/?file=186906#file186906line65" style="color: black; font-weight: bold; text-decoration: underline;">find-modules/FindXCB.cmake</a>
    <span style="font-weight: normal;">

     (Diff revision 3)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">65</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="nb">foreach</span><span class="p">(</span><span class="s">comp</span> <span class="o">${</span><span class="nv">XCB_FIND_COMPONENTS</span><span class="o">}</span><span class="p">)</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">If I don't specify any components, what should happen? Currently there is a fatal error from cmake and several warnings from pkg-config.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/112151/diff/3/?file=186906#file186906line186" style="color: black; font-weight: bold; text-decoration: underline;">find-modules/FindXCB.cmake</a>
    <span style="font-weight: normal;">

     (Diff revision 3)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">186</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="nb">find_path</span><span class="p">(</span><span class="s">XCB_</span><span class="o">${</span><span class="nv">_comp</span><span class="o">}</span><span class="s">_INCLUDE_DIR</span> <span class="s">NAMES</span> <span class="s">xcb/</span><span class="o">${</span><span class="nv">header</span><span class="o">}</span> <span class="s">HINTS</span> <span class="o">${</span><span class="nv">PKG_XCB_INCLUDE_DIRS</span><span class="o">}</span><span class="p">)</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Typo. Should be ${_header}. Otherwise you're not actually looking for the file specified above.

Note that the xcb/ part here should be removed because it is already part of the _header variable set above. Either remove it here, or remove it N times above.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/112151/diff/3/?file=186906#file186906line189" style="color: black; font-weight: bold; text-decoration: underline;">find-modules/FindXCB.cmake</a>
    <span style="font-weight: normal;">

     (Diff revision 3)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">189</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="nb">if</span><span class="p">(</span><span class="s">NOT</span> <span class="s">XCB_FIND_QUIETLY</span><span class="p">)</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This is printing the message even if the component is not found.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/112151/diff/3/?file=186906#file186906line193" style="color: black; font-weight: bold; text-decoration: underline;">find-modules/FindXCB.cmake</a>
    <span style="font-weight: normal;">

     (Diff revision 3)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">193</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="nb">list</span><span class="p">(</span><span class="s">APPEND</span> <span class="s">XCB_INCLUDE_DIRS</span> <span class="o">${</span><span class="nv">XCB_${_comp</span><span class="o">}</span><span class="s">_INCLUDE_DIR}</span><span class="p">)</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Should only be appended if defined.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/112151/diff/3/?file=186906#file186906line279" style="color: black; font-weight: bold; text-decoration: underline;">find-modules/FindXCB.cmake</a>
    <span style="font-weight: normal;">

     (Diff revision 3)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">108</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">  <span class="nb">list</span><span class="p">(</span><span class="s">REMOVE_DUPLICATES</span> <span class="s">XCB_INCLUDE_DIR</span><span class="p">)</span></pre></td>
    <th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">222</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="nb">list</span><span class="p">(</span><span class="s">REMOVE_DUPLICATES</span> <span class="s">XCB_INCLUDE_DIR<span class="hl">S</span></span><span class="p">)</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">If XCB_INCLUDE_DIRS is not defined you get a fatal error from CMake here. It would not be defined if I do this:

 # I don't have xcb-ewmh-dev on my system.
 find_package(XCB OPTIONAL_COMPONENTS EWMH)

Wrap this in if(XCB_INCLUDE_DIRS)
</pre>
</div>
<br />



 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Here's a diff fixing the issues:

diff --git a/find-modules/FindXCB.cmake b/find-modules/FindXCB.cmake
index 2684ed0..823d167 100644
--- a/find-modules/FindXCB.cmake
+++ b/find-modules/FindXCB.cmake
@@ -60,9 +60,15 @@ unset(unknownComponents)
 set(pkgConfigModules)
 set(requiredComponents)
 
+if (XCB_FIND_COMPONENTS)
+  set(comps ${XCB_FIND_COMPONENTS})
+else()
+  set(comps ${knownComponents})
+endif()
+
 # iterate through the list of requested components, and check that we know them all.
 # If not, fail.
-foreach(comp ${XCB_FIND_COMPONENTS})
+foreach(comp ${comps})
     list(FIND knownComponents ${comp} index )
     if("${index}" STREQUAL "-1")
         list(APPEND unknownComponents "${comp}")
@@ -183,16 +189,17 @@ macro(_XCB_HANDLE_COMPONENT _comp)
         set(_lib "xcb-xv")
     endif()
 
-    find_path(XCB_${_comp}_INCLUDE_DIR NAMES xcb/${header} HINTS ${PKG_XCB_INCLUDE_DIRS})
+    find_path(XCB_${_comp}_INCLUDE_DIR NAMES ${_header} HINTS ${PKG_XCB_INCLUDE_DIRS})
     find_library(XCB_${_comp}_LIBRARY NAMES ${_lib} HINTS ${PKG_XCB_LIBRARY_DIRS})
 
-    if(NOT XCB_FIND_QUIETLY)
-        message(STATUS "XCB[${_comp}]: Found component ${_comp}")
+    if(XCB_${_comp}_INCLUDE_DIR AND XCB_${_comp}_LIBRARY)
+        list(APPEND XCB_INCLUDE_DIRS ${XCB_${_comp}_INCLUDE_DIR})
+        list(APPEND XCB_LIBRARIES ${XCB_${_comp}_LIBRARY})
+        if (NOT XCB_FIND_QUIETLY)
+            message(STATUS "XCB[${_comp}]: Found component ${_comp}")
+        endif()
     endif()
 
-    list(APPEND XCB_INCLUDE_DIRS ${XCB_${_comp}_INCLUDE_DIR})
-    list(APPEND XCB_LIBRARIES ${XCB_${_comp}_LIBRARY})
-
     if(XCB_FIND_REQUIRED_${_comp})
         list(APPEND requiredComponents XCB_${_comp}_FOUND)
     endif()
@@ -210,16 +217,18 @@ IF (NOT WIN32)
     include(FindPackageHandleStandardArgs)
     # Use pkg-config to get the directories and then use these values
     # in the FIND_PATH() and FIND_LIBRARY() calls
-    FIND_PACKAGE(PkgConfig)
-    PKG_CHECK_MODULES(PKG_XCB QUIET ${pkgConfigModules})
+    find_package(PkgConfig)
+    pkg_check_modules(PKG_XCB QUIET ${pkgConfigModules})
 
-    SET(XCB_DEFINITIONS ${PKG_XCB_CFLAGS})
+    set(XCB_DEFINITIONS ${PKG_XCB_CFLAGS})
 
-    foreach(comp ${XCB_FIND_COMPONENTS})
+    foreach(comp ${comps})
         _xcb_handle_component(${comp})
     endforeach()
 
-    list(REMOVE_DUPLICATES XCB_INCLUDE_DIRS)
+    if(XCB_INCLUDE_DIRS)
+        list(REMOVE_DUPLICATES XCB_INCLUDE_DIRS)
+    endif()
 
     find_package_handle_standard_args(XCB DEFAULT_MSG XCB_LIBRARIES XCB_INCLUDE_DIRS ${requiredComponents})
 
</pre>

<p>- Stephen</p>


<br />
<p>On September 4th, 2013, 4:57 a.m. UTC, Martin Gräßlin wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for KDE Frameworks, Alexander Neundorf and Stephen Kelly.</div>
<div>By Martin Gräßlin.</div>


<p style="color: grey;"><i>Updated Sept. 4, 2013, 4:57 a.m.</i></p>






<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Instead of finding all or nothing from XCB it becomes components aware. So a user can just specify which XCB components it needs and compilation doesn't fail if a not-needed unrelated component is not found. It also allows to have some components as required and some as optional.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">tested in kde-workspace</pre>
  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>find-modules/FindXCB.cmake <span style="color: grey">(7e7e701)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/112151/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>