FindPkgConfig and find_package are not really related: some scripts for find_package do use pkg-config to help them, but you shouldn't need to check for it yourself.<div><br></div><div>Also, find scripts shouldn't be used with "include".</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'm sure you probably have more libraries (otherwise I'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'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="'courier new', monospace">cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><font class="Apple-style-span" face="'courier new', monospace">project(test CXX C)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">find_package(flann)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">if(FLANN_FOUND)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>set(HAVE_FLANN YES)</font></div>
<div><font class="Apple-style-span" face="'courier new', 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="'courier new', 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="'courier new', monospace">endif()</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', 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"><<a href="mailto:nksallem@laas.fr">nksallem@laas.fr</a>></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'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 "" 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 "${package_name}" PACKAGE_NAME)<br>
# string(TOUPPER "${package_name}_FOUND" PACKAGE_NAME_FOUND)<br>
pkg_check_modules(${PACKAGE_NAME} ${package_name})<br>
# message(STATUS "finding ${package_name} ${${PACKAGE_NAME_FOUND}}")<br>
endmacro(FIND_PACKAGE package_name)<br>
<br>
include(FindPkgConfig)<br>
if(PKG_CONFIG_FOUND)<br>
foreach(package<br>
flann)<br>
string(TOUPPER "${package}" PACKAGE)<br>
string(TOUPPER "HAVE_${package}" HAVE_PACKAGE)<br>
string(TOUPPER "${package}_FOUND" PACKAGE_FOUND)<br>
find_package(${package})<br>
set(${HAVE_PACKAGE} ${${PACKAGE_FOUND}})<br>
if(${PACKAGE_FOUND})<br>
string(TOUPPER "LIBS_MAP_${package}" LIBS_MAP_PACKAGE)<br>
set(${LIBS_MAP_PACKAGE} "${PACKAGE}")<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 " pkgconfig not found you won't be able to build some modules")<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 'Doxygen'<br>
-- package 'Doxygen' 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>