cmake.m4 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. dnl ============================================================================
  2. dnl CMake - Cross Platform Makefile Generator
  3. dnl Copyright 2011 Matthias Kretz, [email protected]
  4. dnl
  5. dnl Distributed under the OSI-approved BSD License (the "License");
  6. dnl see accompanying file Copyright.txt for details.
  7. dnl
  8. dnl This software is distributed WITHOUT ANY WARRANTY; without even the
  9. dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. dnl See the License for more information.
  11. dnl ============================================================================
  12. AC_DEFUN([CMAKE_FIND_BINARY],
  13. [AC_ARG_VAR([CMAKE_BINARY], [path to the cmake binary])dnl
  14. if test "x$ac_cv_env_CMAKE_BINARY_set" != "xset"; then
  15. AC_PATH_TOOL([CMAKE_BINARY], [cmake])dnl
  16. fi
  17. ])dnl
  18. # $1: package name
  19. # $2: language (e.g. C/CXX/Fortran)
  20. # $3: The compiler ID, defaults to GNU.
  21. # Possible values are: GNU, Intel, Clang, SunPro, HP, XL, VisualAge, PGI,
  22. # PathScale, Cray, SCO, MIPSpro, MSVC
  23. # $4: optional extra arguments to cmake, e.g. "-DCMAKE_SIZEOF_VOID_P=8"
  24. # $5: optional path to cmake binary
  25. AC_DEFUN([CMAKE_FIND_PACKAGE], [
  26. AC_REQUIRE([CMAKE_FIND_BINARY])dnl
  27. AC_ARG_VAR([$1][_][$2][FLAGS], [$2 compiler flags for $1. This overrides the cmake output])dnl
  28. AC_ARG_VAR([$1][_LIBS], [linker flags for $1. This overrides the cmake output])dnl
  29. failed=false
  30. AC_MSG_CHECKING([for $1])
  31. if test -n "$1[]_$2[]FLAGS"; then
  32. $1[]_$2[]FLAGS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=COMPILE $4` || failed=true
  33. fi
  34. if test -n "$1[]_LIBS"; then
  35. $1[]_LIBS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=LINK $4` || failed=true
  36. fi
  37. if $failed; then
  38. unset $1[]_$2[]FLAGS
  39. unset $1[]_LIBS
  40. AC_MSG_RESULT([no])
  41. $6
  42. else
  43. AC_MSG_RESULT([yes])
  44. $5
  45. fi[]dnl
  46. ])