File: cmake.m4

package info (click to toggle)
cmake 4.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,456 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (68 lines) | stat: -rw-r--r-- 2,229 bytes parent folder | download | duplicates (3)
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
dnl Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
dnl file LICENSE.rst or https://cmake.org/licensing for details.

# CMAKE_FIND_BINARY
# -----------------
# Finds the cmake command-line binary and sets its absolute path in the
# CMAKE_BINARY variable.
AC_DEFUN([CMAKE_FIND_BINARY],
[AC_ARG_VAR([CMAKE_BINARY], [path to the cmake binary])dnl

if test "x$ac_cv_env_CMAKE_BINARY_set" != "xset"; then
    AC_PATH_TOOL([CMAKE_BINARY], [cmake])dnl
fi
])dnl

# CMAKE_FIND_PACKAGE(package, lang, [compiler-id], [cmake-args],
#   [action-if-found], [action-if-not-found])
# --------------------------------------------------------------
# Finds a package with CMake.
#
# package:
#   The name of the package as called in CMake with find_package(package).
#
# lang:
#   The programming language to use (e.g., C, CXX, Fortran).
#   See https://cmake.org/cmake/help/latest/command/enable_language.html
#   for a complete list of supported languages.
#
# compiler-id:
#   (Optional) The compiler ID to use. Defaults to GNU.
#   See https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html
#   for possible values.
#
# cmake-args:
#   (Optional) Additional arguments to pass to cmake command, e.g.,
#   -DCMAKE_SIZEOF_VOID_P=8.
#
# action-if-found:
#   (Optional) Commands to execute if the package is found.
#
# action-if-not-found:
#   (Optional) Commands to execute if the package is not found.
AC_DEFUN([CMAKE_FIND_PACKAGE], [
AC_REQUIRE([CMAKE_FIND_BINARY])dnl

AC_ARG_VAR([$1][_][$2][FLAGS], [$2 compiler flags for $1. This overrides the cmake output])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1. This overrides the cmake output])dnl

failed=false
AC_MSG_CHECKING([for $1])
if test -z "${$1[]_$2[]FLAGS}"; then
    $1[]_$2[]FLAGS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=COMPILE $4` || failed=true
fi
if test -z "${$1[]_LIBS}"; then
    $1[]_LIBS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=LINK $4` || failed=true
fi

if $failed; then
    unset $1[]_$2[]FLAGS
    unset $1[]_LIBS

    AC_MSG_RESULT([no])
    $6
else
    AC_MSG_RESULT([yes])
    $5
fi[]dnl
])