FindPkgConfig and find_package are not really related: some scripts for find_package do use pkg-config to help them, but you shouldn&#39;t need to check for it yourself.<div><br></div><div>Also, find scripts shouldn&#39;t be used with &quot;include&quot;.</div>
<div><br></div><div>It looks a bit like build system overkill: this should do roughly the same thing, but simpler and more reliably.  Though I&#39;m sure you probably have more libraries (otherwise I&#39;m really confused by your use of a foreach loop), something like this is clearer, and at least in my eyes, the tradeoff of small code duplication (which isn&#39;t always wrong because some find modules work differently) for the clarity (versus all those nested variable evaluations) is definitely worth it.</div>
<div><br></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br>
</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">project(test CXX C)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">find_package(flann)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">if(FLANN_FOUND)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>set(HAVE_FLANN YES)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>include_directories(${FLANN_INCLUDE_DIRS})</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>list(APPEND LIBS ${FLANN_LIBRARIES})</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">endif()</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">find_package(Doxygen)</font></div>
<div><br></div><br><div class="gmail_quote">On Thu, Jan 6, 2011 at 11:39 AM, Nizar Khalifa Sallem <span dir="ltr">&lt;<a href="mailto:nksallem@laas.fr">nksallem@laas.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi all,<br>
<br>
I am getting in trouble with the FindPkgConfig module. Here is a piece<br>
of rather bigger CMakeLists.txt file that doesn&#39;t success to find<br>
Doxygen although installed on the machine(ubuntu 10.4, cmake 2.8.3)<br>
<br>
<br># $Id$ #<br>
# ----------------------------------------------------------------------------<br>
# A CMakeLists.txt file to test FindPkgConfig<br>
# ----------------------------------------------------------------------------<br>
<br>
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)<br>
<br>
# it MUST go before PROJECT(Jafar) in order to work<br>
if (NOT CMAKE_INSTALL_PREFIX)<br>
  set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE INTERNAL &quot;&quot; FORCE)<br>
endif()<br>
<br>
cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)<br>
<br>
project(test CXX C)<br>
<br>
include(CheckIncludeFile)<br>
<br>
macro(FIND_PACKAGE package_name)<br>
                string(TOUPPER &quot;${package_name}&quot; PACKAGE_NAME)<br>
#               string(TOUPPER &quot;${package_name}_FOUND&quot; PACKAGE_NAME_FOUND)<br>
                pkg_check_modules(${PACKAGE_NAME} ${package_name})<br>
#               message(STATUS &quot;finding ${package_name} ${${PACKAGE_NAME_FOUND}}&quot;)<br>
endmacro(FIND_PACKAGE package_name)<br>
<br>
include(FindPkgConfig)<br>
if(PKG_CONFIG_FOUND)<br>
        foreach(package<br>
                        flann)<br>
                string(TOUPPER &quot;${package}&quot; PACKAGE)<br>
                string(TOUPPER &quot;HAVE_${package}&quot; HAVE_PACKAGE)<br>
                string(TOUPPER &quot;${package}_FOUND&quot; PACKAGE_FOUND)<br>
                find_package(${package})<br>
                set(${HAVE_PACKAGE} ${${PACKAGE_FOUND}})<br>
                if(${PACKAGE_FOUND})<br>
                        string(TOUPPER &quot;LIBS_MAP_${package}&quot; LIBS_MAP_PACKAGE)<br>
                        set(${LIBS_MAP_PACKAGE} &quot;${PACKAGE}&quot;)<br>
                        set(LIBS ${LIBS} ${${PACKAGE}_LIBRARIES})<br>
                        include_directories(${${PACKAGE}_INCLUDE_DIRS})<br>
                endif(${PACKAGE_FOUND})<br>
        endforeach(package)<br>
else(PKG_CONFIG_FOUND)<br>
  message(ERROR &quot; pkgconfig not found you won&#39;t be able to build some modules&quot;)<br>
endif(PKG_CONFIG_FOUND)<br>
<br>
find_package(Doxygen)<br>
<br>
==================================================================<br>
It says :<br>
Running CMake to regenerate build system...<br>
-- checking for module &#39;Doxygen&#39;<br>
-- package &#39;Doxygen&#39; not found<br>
<br>
I get it work by putting find_package(Doxygen) before<br>
include(FindPkgConfig) statement. Can someone explain me this strange<br>
behaviour please ?<br>
<br>
Cheers,<br>
--<br>
Nizar<br>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br><br clear="all"><br>-- <br>Ryan Pavlik<br>HCI Graduate Student<br>Virtual Reality Applications Center<br>
Iowa State University<br><br><a href="mailto:rpavlik@iastate.edu">rpavlik@iastate.edu</a><br><a href="http://academic.cleardefinition.com">http://academic.cleardefinition.com</a><br>Internal VRAC/HCI Site: <a href="http://tinyurl.com/rpavlik">http://tinyurl.com/rpavlik</a><br>

</div>