Eyescale/Buildyard — pull request #38 by julitopower (2013-10-16 19:18:54+00:00)
Title: Do not add find_package for packages that contain PkgConfig files.

I agreed with Daniel to submit this code for a pull request mainly so that we can have a conversation about it. There maybe cases that we are forgetting here, so It may be worth thinking about it. By the way I built Equalizer without problems with this modification, so we know big projects are not broken :)

This allows for easy addition of 3rd party libraries. Basically
libraries providing PkgConfig files will be automatically found
as long as they are declared as a dependency of another package.

Example of generated file (notices how I take care of the presence or not of a version number):

include(System)
list(APPEND FIND_PACKAGES_DEFINES ${SYSTEM})
find_package(PkgConfig)
pkg_check_modules(COLLAGE Collage>=1.1.0)

if (NOT COLLAGE_FOUND)
find_package(Collage 1.1.0 REQUIRED)
endif()

pkg_check_modules(LUNCHBOX Lunchbox>=1.9.0)

if (NOT LUNCHBOX_FOUND)
find_package(Lunchbox 1.9.0 REQUIRED)
endif()

pkg_check_modules(BOOST Boost>=1.41.0)

if (NOT BOOST_FOUND)
find_package(Boost 1.41.0 REQUIRED unit_test_framework)
endif()

pkg_check_modules(JSONCPP jsoncpp)

if (NOT JSONCPP_FOUND)
find_package(jsoncpp REQUIRED)
endif()

if(EXISTS ${CMAKE_SOURCE_DIR}/CMake/FindPackagesPost.cmake)
include(${CMAKE_SOURCE_DIR}/CMake/FindPackagesPost.cmake)
endif()

...