File: FindGDB.cmake

package info (click to toggle)
freespace2 25.0.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 47,232 kB
  • sloc: cpp: 657,500; ansic: 22,305; sh: 293; python: 200; makefile: 198; xml: 181
file content (77 lines) | stat: -rw-r--r-- 1,609 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# - Try to find GDB
#
# Once done, this will define:
#  GDB_FOUND - system has GDB
#  GDB_COMMAND - the command to run
#  GDB_VERSION - version
#  GDB_HAS_RETURN_CHILD_RESULT - if the --return-child-result flag is supported
#
# Useful configuration variables you might want to add to your cache:
#  GDB_ROOT_DIR - A directory prefix to search
#
# Original Author:
# 2009-2010 Rylie Pavlik <rylie@ryliepavlik.com>
# https://ryliepavlik.com/
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright 2009-2010, Iowa State University
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# SPDX-License-Identifier: BSL-1.0


set(GDB_ROOT_DIR
	"${GDB_ROOT_DIR}"
	CACHE
	PATH
	"Directory to start our search in")

find_program(GDB_COMMAND
	NAMES
	gdb
	HINTS
	"${GDB_ROOT_DIR}"
	PATH_SUFFIXES
	bin
	libexec)

if(GDB_COMMAND)
	execute_process(COMMAND
		gdb
		--version
		COMMAND
		head
		-n
		1
		OUTPUT_VARIABLE
		GDB_VERSION
		OUTPUT_STRIP_TRAILING_WHITESPACE)
	string(REGEX
		REPLACE
		"[^0-9]*([0-9]+[0-9.]*).*"
		"\\1"
		GDB_VERSION
		"${GDB_VERSION}")
endif()

# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GDB
	DEFAULT_MSG
	GDB_COMMAND
	GDB_VERSION)

if(GDB_FOUND)
	mark_as_advanced(GDB_ROOT_DIR)
	if(GDB_VERSION VERSION_LESS 6.4)
		set(GDB_HAS_RETURN_CHILD_RESULT FALSE)
	else()
		set(GDB_HAS_RETURN_CHILD_RESULT TRUE)
	endif()
endif()

mark_as_advanced(GDB_COMMAND)