1 # - Try to find Popt
2 # Once done this will define
3 #
4 # POPT_FOUND - system has Popt
5 # POPT_INCLUDE_DIRS - the Popt include directory
6 # POPT_LIBRARIES - Link these to use Popt
7 # POPT_DEFINITIONS - Compiler switches required for using Popt
8 #
9 # Copyright (c) 2008 Joshua L. Blocher <verbalshadow@gmail.com>
10 #
11 # Redistribution and use is allowed according to the terms of the New
12 # BSD license.
13 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 #
17 if (POPT_LIBRARIES AND POPT_INCLUDE_DIRS)
18 # in cache already
19 set(POPT_FOUND TRUE)
20 else (POPT_LIBRARIES AND POPT_INCLUDE_DIRS)
21 # use pkg-config to get the directories and then use these values
22 # in the FIND_PATH() and FIND_LIBRARY() calls
23 if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
24 include(UsePkgConfig)
25 pkgconfig(popt _POPT_INCLUDEDIR _POPT_LIBDIR _POPT_LDFLAGS _POPT_CFLAGS)
26 else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
27 find_package(PkgConfig)
28 if (PKG_CONFIG_FOUND)
29 pkg_check_modules(_POPT popt)
30 endif (PKG_CONFIG_FOUND)
31 endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
32 find_path(POPT_INCLUDE_DIR
33 NAMES
34 popt.h
35 PATHS
36 ${_POPT_INCLUDEDIR}
37 /usr/include
38 /usr/local/include
39 /opt/local/include
40 /sw/include
41 $ENV{DEVLIBS_PATH}//include//
42 PATH_SUFFIXES
43 popt
44 )
46 find_library(POPT_LIBRARY
47 NAMES
48 popt
49 PATHS
50 ${_POPT_LIBDIR}
51 /usr/lib
52 /usr/local/lib
53 /opt/local/lib
54 /sw/lib
55 )
57 if (POPT_LIBRARY)
58 set(POPT_FOUND TRUE)
59 endif (POPT_LIBRARY)
61 set(POPT_INCLUDE_DIRS
62 ${POPT_INCLUDE_DIR}
63 )
65 if (POPT_FOUND)
66 set(POPT_LIBRARIES
67 ${POPT_LIBRARIES}
68 ${POPT_LIBRARY}
69 )
70 endif (POPT_FOUND)
72 if (POPT_INCLUDE_DIRS AND POPT_LIBRARIES)
73 set(POPT_FOUND TRUE)
74 endif (POPT_INCLUDE_DIRS AND POPT_LIBRARIES)
76 if (POPT_FOUND)
77 if (NOT Popt_FIND_QUIETLY)
78 message(STATUS "Found Popt: ${POPT_LIBRARIES}")
79 endif (NOT Popt_FIND_QUIETLY)
80 else (POPT_FOUND)
81 if (Popt_FIND_REQUIRED)
82 message(FATAL_ERROR "Could not find Popt")
83 endif (Popt_FIND_REQUIRED)
84 endif (POPT_FOUND)
86 # show the POPT_INCLUDE_DIRS and POPT_LIBRARIES variables only in the advanced view
87 mark_as_advanced(POPT_INCLUDE_DIRS POPT_LIBRARIES)
89 endif (POPT_LIBRARIES AND POPT_INCLUDE_DIRS)