1. Flann uses CMake, so it should install a FlannConfig.cmake (possibly in addition to the currently installed flann.pc). This would obsolete all issues below.
2. Since Flann only comes with a pkg-config module and there's no FindFlann.cmake module in CMake, the OP could either write his own (refer to the docs on the find_package command and read the ${CMAKE_ROOT}/Modules/readme.txt file). 3. The OP could use the FindPkgConfig.cmake module, but then he should do so correctly: # find FLANN with pkg-config find_package(PkgConfig REQUIRED) pkg_check_modules(FLANN REQUIRED flann) # find Doxygen find_package(Doxygen) # later on, when FLANN is needed for compiling link_directories(${FLANN_LIBRARY_DIRS}) include_directories(${FLANN_INCLUDE_DIRS}) if(FLANN_CFLAGS) add_definitions(${FLANN_CFLAGS}) endif(FLANN_CFLAGS) # and even later, when FLANN is needed for linking target_link_libraries(SomeTarget ${FLANN_LIBRARIES}) 4. The OP should note that pkg-config is fundamentally flawed and he really should consider item 2 of this list. 5. The code shown by the OP is broken on so many levels, it should be purged from the archives of this mailing list. I'm sure some beginner will find it with google and then it will start spreading like a virus, resulting in gazillions of users flooding this mailing list venting their frustration with CMake ;-) Seriously, though: **NEVER**, **EVER**, define macros/functions with names of existing built-in commands (unless you actually know exactly what you are doing, that is. The OP clearly didn't). FIND_PACKAGE is a _very_ important built-in CMake command and by defining a macro with that name, the OP effectively broke CMake for his purposes, which is why the find_package(Doxygen) call failed. For completeness: If you redefine a built-in command with a macro/function, the original command is renamed by appending an underscore (_) to its name. So find_package_(Doxygen) should work in the posted code. I hope this helps a bit Michael On 01/07/2011 12:27 AM, Ryan Pavlik wrote: > 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. > > Also, find scripts shouldn't be used with "include". > > 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. > > cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR) > > project(test CXX C) > > find_package(flann) > if(FLANN_FOUND) > set(HAVE_FLANN YES) > include_directories(${FLANN_INCLUDE_DIRS}) > list(APPEND LIBS ${FLANN_LIBRARIES}) > endif() > > find_package(Doxygen) > > > On Thu, Jan 6, 2011 at 11:39 AM, Nizar Khalifa Sallem <nksal...@laas.fr>wrote: > >> Hi all, >> >> I am getting in trouble with the FindPkgConfig module. Here is a piece >> of rather bigger CMakeLists.txt file that doesn't success to find >> Doxygen although installed on the machine(ubuntu 10.4, cmake 2.8.3) >> >> >> # $Id$ # >> # >> ---------------------------------------------------------------------------- >> # A CMakeLists.txt file to test FindPkgConfig >> # >> ---------------------------------------------------------------------------- >> >> set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) >> >> # it MUST go before PROJECT(Jafar) in order to work >> if (NOT CMAKE_INSTALL_PREFIX) >> set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE INTERNAL "" FORCE) >> endif() >> >> cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR) >> >> project(test CXX C) >> >> include(CheckIncludeFile) >> >> macro(FIND_PACKAGE package_name) >> string(TOUPPER "${package_name}" PACKAGE_NAME) >> # string(TOUPPER "${package_name}_FOUND" PACKAGE_NAME_FOUND) >> pkg_check_modules(${PACKAGE_NAME} ${package_name}) >> # message(STATUS "finding ${package_name} >> ${${PACKAGE_NAME_FOUND}}") >> endmacro(FIND_PACKAGE package_name) >> >> include(FindPkgConfig) >> if(PKG_CONFIG_FOUND) >> foreach(package >> flann) >> string(TOUPPER "${package}" PACKAGE) >> string(TOUPPER "HAVE_${package}" HAVE_PACKAGE) >> string(TOUPPER "${package}_FOUND" PACKAGE_FOUND) >> find_package(${package}) >> set(${HAVE_PACKAGE} ${${PACKAGE_FOUND}}) >> if(${PACKAGE_FOUND}) >> string(TOUPPER "LIBS_MAP_${package}" >> LIBS_MAP_PACKAGE) >> set(${LIBS_MAP_PACKAGE} "${PACKAGE}") >> set(LIBS ${LIBS} ${${PACKAGE}_LIBRARIES}) >> include_directories(${${PACKAGE}_INCLUDE_DIRS}) >> endif(${PACKAGE_FOUND}) >> endforeach(package) >> else(PKG_CONFIG_FOUND) >> message(ERROR " pkgconfig not found you won't be able to build some >> modules") >> endif(PKG_CONFIG_FOUND) >> >> find_package(Doxygen) >> >> ================================================================== >> It says : >> Running CMake to regenerate build system... >> -- checking for module 'Doxygen' >> -- package 'Doxygen' not found >> >> I get it work by putting find_package(Doxygen) before >> include(FindPkgConfig) statement. Can someone explain me this strange >> behaviour please ? >> >> Cheers, >> -- >> Nizar _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake