source: trunk/m4/yat_check_func.m4 @ 4102

Last change on this file since 4102 was 4102, checked in by Peter, 2 years ago

add wrapper function that calls std::string::contains, ::starts_with, and ::ends_with, if available; otherwise use home-brewed code. Add autoconf tests that check if these functions are available in CXX.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 1.5 KB
Line 
1## $Id: yat_check_func.m4 4102 2021-09-22 07:50:18Z peter $
2#
3# Copyright (C) 2021 Peter Johansson
4#
5# This file is part of the yat library, https://dev.thep.lu.se/yat
6#
7# The yat library is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 3 of the
10# License, or (at your option) any later version.
11#
12# The yat library is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with yat. If not, see <https://www.gnu.org/licenses/>.
19#
20
21#
22# serial 1 (yat 0.20)
23#
24
25# YAT_CHECK_FUNC(function, [prologue], [body], [action-if-found],
26#                [action-if-not-found])
27# ==========================================================
28# Wrapper around AC_CACHE_CHECK and AC_COMPILE_IFELSE. Try to compile
29# program with prologue 'prologue' and body 'body'. If successful, run
30# shell commands action-if-found, otherwise
31# action-if-not-found. Result is cached in variable
32# $yat_cv_func_<function>
33AC_DEFUN([YAT_CHECK_FUNC],
34[
35  AS_VAR_PUSHDEF([yat_CACHE], [AS_TR_SH([yat_cv_func_$1])])dnl
36  AC_CACHE_CHECK([if $CXX supports $1], [yat_CACHE], [
37    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2], [$3])],
38                      [yat_CACHE=yes],
39                      [yat_CACHE=no])
40  ])
41  AS_VAR_IF([yat_CACHE], [yes], [$4], [$5])
42  AS_VAR_POPDEF([yat_CACHE])dnl
43])
Note: See TracBrowser for help on using the repository browser.