1# - try to find the argp library/component of glibc
2#
3# Users may optionally supply:
4#  ARGP_ROOT_DIR - a prefix to start searching.
5#
6# Cache Variables: (probably not for direct use in your scripts)
7#  ARGP_INCLUDE_DIR
8#  ARGP_LIBRARY, only defined if linking to an extra library is required
9#
10# Non-cache variables you might use in your CMakeLists.txt:
11#  ARGP_FOUND
12#  ARGP_INCLUDE_DIRS
13#  ARGP_LIBRARIES
14#
15# Requires these CMake modules:
16#  FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
17#
18# Original Author:
19# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
20# http://academic.cleardefinition.com
21# Iowa State University HCI Graduate Program/VRAC
22#
23# Copyright Iowa State University 2009-2010.
24# Distributed under the Boost Software License, Version 1.0.
25# (See accompanying file LICENSE_1_0.txt or copy at
26# http://www.boost.org/LICENSE_1_0.txt)
27
28set(ARGP_ROOT_DIR
29	"${ARGP_ROOT_DIR}"
30	CACHE
31	PATH
32	"Path to search for ARGP library")
33
34###
35# Configure ARGP
36###
37set(_check ARGP_INCLUDE_DIR)
38
39find_path(ARGP_INCLUDE_DIR
40	NAMES
41	argp.h
42	HINTS
43	"${ARGP_ROOT_DIR}"
44	PATHS
45	/usr/local
46	/opt/local
47	/sw)
48mark_as_advanced(ARGP_INCLUDE_DIR)
49
50include(CheckFunctionExists)
51check_function_exists(argp_parse ARGP_BUILTIN)
52
53if(NOT ARGP_BUILTIN)
54	find_library(ARGP_LIBRARY
55		NAMES
56		argp
57		HINTS
58		"${ARGP_ROOT_DIR}"
59		PATH_SUFFIXES
60		lib
61		lib64
62		PATHS
63		/usr/local
64		/opt/local
65		/sw)
66	list(APPEND _check ARGP_LIBRARY)
67	mark_as_advanced(ARGP_LIBRARY)
68endif()
69
70# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
71# all listed variables are TRUE
72include(FindPackageHandleStandardArgs)
73find_package_handle_standard_args(argp
74	DEFAULT_MSG
75	${_check})
76
77if(ARGP_FOUND)
78	set(ARGP_INCLUDE_DIRS "${ARGP_INCLUDE_DIR}")
79	set(ARGP_LIBRARIES "${ARGP_LIBRARY}")
80	mark_as_advanced(ARGP_ROOT_DIR)
81endif()
82