Moar cmake stuff.
[sdlpango.git] / cmake / FindClanLib.cmake
blob8cb7e8cc50be08453c3f92b4ff3e1a40bef100c7
1 # - Try to find ClanLib
2 # Example usage: find_package(ClanLib 0.8 REQUIRED COMPONENTS Core App Display GL Sound)
4 # Once done, this will define
6 #  ClanLib_FOUND - system has ClanLib (all the components requested)
7 #  ClanLib_INCLUDE_DIRS - the ClanLib include directories
8 #  ClanLib_LIBRARIES - link these to use ClanLib
10 # See documentation on how to write CMake scripts at
11 # http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
13 include(LibFindMacros)
15 if (ClanLib_FIND_VERSION_MAJOR AND ClanLib_FIND_VERSION_MINOR)
16   set(ClanLib_VERSION "${ClanLib_FIND_VERSION_MAJOR}.${ClanLib_FIND_VERSION_MINOR}")
17 else (ClanLib_FIND_VERSION_MAJOR AND ClanLib_FIND_VERSION_MINOR)
18   set(ClanLib_VERSION "0.8")
19 endif (ClanLib_FIND_VERSION_MAJOR AND ClanLib_FIND_VERSION_MINOR)
21 libfind_pkg_check_modules(ClanLib_PKGCONF clanCore-${ClanLib_VERSION})
23 find_path(ClanLib_INCLUDE_DIR
24   NAMES ClanLib/core.h
25   PATH_SUFFIXES ClanLib-${ClanLib_VERSION}
26   HINTS ${ClanLib_PKGCONF_INCLUDE_DIRS}
29 # Extract the actual version number
30 if (ClanLib_INCLUDE_DIR)
31   file(READ "${ClanLib_INCLUDE_DIR}/ClanLib/core.h" _ClanLib_CORE_H_CONTENTS)
32   set(_ClanLib_VERSION_REGEX ".*#define CL_VERSION_STRING \"([^\n]*)\".*")
33   if ("${_ClanLib_CORE_H_CONTENTS}" MATCHES "${_ClanLib_VERSION_REGEX}")
34     string(REGEX REPLACE "${_ClanLib_VERSION_REGEX}" "\\1" ClanLib_VERSION "${_ClanLib_CORE_H_CONTENTS}")
35   endif ("${_ClanLib_CORE_H_CONTENTS}" MATCHES "${_ClanLib_VERSION_REGEX}")
36 endif (ClanLib_INCLUDE_DIR)
38 foreach(COMPONENT ${ClanLib_FIND_COMPONENTS})
39   find_library(ClanLib_${COMPONENT}_LIBRARY
40     NAMES clan${COMPONENT}
41     PATHS ${ClanLib_PKGCONF_LIBRARY_DIRS}
42   )
43   set(ClanLib_PROCESS_LIBS ${ClanLib_PROCESS_LIBS} ClanLib_${COMPONENT}_LIBRARY)
44 endforeach(COMPONENT)
46 set(ClanLib_PROCESS_INCLUDES ClanLib_INCLUDE_DIR)
47 libfind_process(ClanLib)