[CMake] suspicious behaviour of FindPkgConfig

Nizar Khalifa Sallem nksallem at laas.fr
Thu Jan 6 12:39:01 EST 2011


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)

-------------- next part --------------
# $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


More information about the CMake mailing list