terom@6: # - Try to find ClanLib terom@6: # Example usage: find_package(ClanLib 0.8 REQUIRED COMPONENTS Core App Display GL Sound) terom@6: # terom@6: # Once done, this will define terom@6: # terom@6: # ClanLib_FOUND - system has ClanLib (all the components requested) terom@6: # ClanLib_INCLUDE_DIRS - the ClanLib include directories terom@6: # ClanLib_LIBRARIES - link these to use ClanLib terom@6: # terom@6: # See documentation on how to write CMake scripts at terom@6: # http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries terom@6: terom@6: include(LibFindMacros) terom@6: terom@6: if (ClanLib_FIND_VERSION_MAJOR AND ClanLib_FIND_VERSION_MINOR) terom@6: set(ClanLib_VERSION "${ClanLib_FIND_VERSION_MAJOR}.${ClanLib_FIND_VERSION_MINOR}") terom@6: else (ClanLib_FIND_VERSION_MAJOR AND ClanLib_FIND_VERSION_MINOR) terom@6: set(ClanLib_VERSION "0.8") terom@6: endif (ClanLib_FIND_VERSION_MAJOR AND ClanLib_FIND_VERSION_MINOR) terom@6: terom@6: libfind_pkg_check_modules(ClanLib_PKGCONF clanCore-${ClanLib_VERSION}) terom@6: terom@6: find_path(ClanLib_INCLUDE_DIR terom@6: NAMES ClanLib/core.h terom@6: PATH_SUFFIXES ClanLib-${ClanLib_VERSION} saiam@9: HINTS ${ClanLib_PKGCONF_INCLUDE_DIRS} terom@6: ) terom@6: terom@6: # Extract the actual version number terom@6: if (ClanLib_INCLUDE_DIR) terom@6: file(READ "${ClanLib_INCLUDE_DIR}/ClanLib/core.h" _ClanLib_CORE_H_CONTENTS) terom@6: set(_ClanLib_VERSION_REGEX ".*#define CL_VERSION_STRING \"([^\n]*)\".*") terom@6: if ("${_ClanLib_CORE_H_CONTENTS}" MATCHES "${_ClanLib_VERSION_REGEX}") terom@6: string(REGEX REPLACE "${_ClanLib_VERSION_REGEX}" "\\1" ClanLib_VERSION "${_ClanLib_CORE_H_CONTENTS}") terom@6: endif ("${_ClanLib_CORE_H_CONTENTS}" MATCHES "${_ClanLib_VERSION_REGEX}") terom@6: endif (ClanLib_INCLUDE_DIR) terom@6: terom@6: foreach(COMPONENT ${ClanLib_FIND_COMPONENTS}) terom@6: find_library(ClanLib_${COMPONENT}_LIBRARY terom@6: NAMES clan${COMPONENT} terom@6: PATHS ${ClanLib_PKGCONF_LIBRARY_DIRS} terom@6: ) terom@6: set(ClanLib_PROCESS_LIBS ${ClanLib_PROCESS_LIBS} ClanLib_${COMPONENT}_LIBRARY) terom@6: endforeach(COMPONENT) terom@6: terom@6: set(ClanLib_PROCESS_INCLUDES ClanLib_INCLUDE_DIR) terom@6: libfind_process(ClanLib) terom@6: