The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

274 lines
9.9 KiB

2 months ago
  1. #!/bin/sh
  2. # These variables are automatically filled in by the configure script.
  3. name="@PACKAGE_TARNAME@"
  4. version="@PACKAGE_VERSION@"
  5. show_usage()
  6. {
  7. echo "Usage: gtest-config [OPTIONS...]"
  8. }
  9. show_help()
  10. {
  11. show_usage
  12. cat <<\EOF
  13. The `gtest-config' script provides access to the necessary compile and linking
  14. flags to connect with Google C++ Testing Framework, both in a build prior to
  15. installation, and on the system proper after installation. The installation
  16. overrides may be issued in combination with any other queries, but will only
  17. affect installation queries if called on a built but not installed gtest. The
  18. installation queries may not be issued with any other types of queries, and
  19. only one installation query may be made at a time. The version queries and
  20. compiler flag queries may be combined as desired but not mixed. Different
  21. version queries are always combined with logical "and" semantics, and only the
  22. last of any particular query is used while all previous ones ignored. All
  23. versions must be specified as a sequence of numbers separated by periods.
  24. Compiler flag queries output the union of the sets of flags when combined.
  25. Examples:
  26. gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
  27. g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp
  28. g++ $(gtest-config --ldflags --libs) -o foo foo.o
  29. # When using a built but not installed Google Test:
  30. g++ $(../../my_gtest_build/scripts/gtest-config ...) ...
  31. # When using an installed Google Test, but with installation overrides:
  32. export GTEST_PREFIX="/opt"
  33. g++ $(gtest-config --libdir="/opt/lib64" ...) ...
  34. Help:
  35. --usage brief usage information
  36. --help display this help message
  37. Installation Overrides:
  38. --prefix=<dir> overrides the installation prefix
  39. --exec-prefix=<dir> overrides the executable installation prefix
  40. --libdir=<dir> overrides the library installation prefix
  41. --includedir=<dir> overrides the header file installation prefix
  42. Installation Queries:
  43. --prefix installation prefix
  44. --exec-prefix executable installation prefix
  45. --libdir library installation directory
  46. --includedir header file installation directory
  47. --version the version of the Google Test installation
  48. Version Queries:
  49. --min-version=VERSION return 0 if the version is at least VERSION
  50. --exact-version=VERSION return 0 if the version is exactly VERSION
  51. --max-version=VERSION return 0 if the version is at most VERSION
  52. Compilation Flag Queries:
  53. --cppflags compile flags specific to the C-like preprocessors
  54. --cxxflags compile flags appropriate for C++ programs
  55. --ldflags linker flags
  56. --libs libraries for linking
  57. EOF
  58. }
  59. # This function bounds our version with a min and a max. It uses some clever
  60. # POSIX-compliant variable expansion to portably do all the work in the shell
  61. # and avoid any dependency on a particular "sed" or "awk" implementation.
  62. # Notable is that it will only ever compare the first 3 components of versions.
  63. # Further components will be cleanly stripped off. All versions must be
  64. # unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and
  65. # the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should
  66. # investigate expanding this via autom4te from AS_VERSION_COMPARE rather than
  67. # continuing to maintain our own shell version.
  68. check_versions()
  69. {
  70. major_version=${version%%.*}
  71. minor_version="0"
  72. point_version="0"
  73. if test "${version#*.}" != "${version}"; then
  74. minor_version=${version#*.}
  75. minor_version=${minor_version%%.*}
  76. fi
  77. if test "${version#*.*.}" != "${version}"; then
  78. point_version=${version#*.*.}
  79. point_version=${point_version%%.*}
  80. fi
  81. min_version="$1"
  82. min_major_version=${min_version%%.*}
  83. min_minor_version="0"
  84. min_point_version="0"
  85. if test "${min_version#*.}" != "${min_version}"; then
  86. min_minor_version=${min_version#*.}
  87. min_minor_version=${min_minor_version%%.*}
  88. fi
  89. if test "${min_version#*.*.}" != "${min_version}"; then
  90. min_point_version=${min_version#*.*.}
  91. min_point_version=${min_point_version%%.*}
  92. fi
  93. max_version="$2"
  94. max_major_version=${max_version%%.*}
  95. max_minor_version="0"
  96. max_point_version="0"
  97. if test "${max_version#*.}" != "${max_version}"; then
  98. max_minor_version=${max_version#*.}
  99. max_minor_version=${max_minor_version%%.*}
  100. fi
  101. if test "${max_version#*.*.}" != "${max_version}"; then
  102. max_point_version=${max_version#*.*.}
  103. max_point_version=${max_point_version%%.*}
  104. fi
  105. test $(($major_version)) -lt $(($min_major_version)) && exit 1
  106. if test $(($major_version)) -eq $(($min_major_version)); then
  107. test $(($minor_version)) -lt $(($min_minor_version)) && exit 1
  108. if test $(($minor_version)) -eq $(($min_minor_version)); then
  109. test $(($point_version)) -lt $(($min_point_version)) && exit 1
  110. fi
  111. fi
  112. test $(($major_version)) -gt $(($max_major_version)) && exit 1
  113. if test $(($major_version)) -eq $(($max_major_version)); then
  114. test $(($minor_version)) -gt $(($max_minor_version)) && exit 1
  115. if test $(($minor_version)) -eq $(($max_minor_version)); then
  116. test $(($point_version)) -gt $(($max_point_version)) && exit 1
  117. fi
  118. fi
  119. exit 0
  120. }
  121. # Show the usage line when no arguments are specified.
  122. if test $# -eq 0; then
  123. show_usage
  124. exit 1
  125. fi
  126. while test $# -gt 0; do
  127. case $1 in
  128. --usage) show_usage; exit 0;;
  129. --help) show_help; exit 0;;
  130. # Installation overrides
  131. --prefix=*) GTEST_PREFIX=${1#--prefix=};;
  132. --exec-prefix=*) GTEST_EXEC_PREFIX=${1#--exec-prefix=};;
  133. --libdir=*) GTEST_LIBDIR=${1#--libdir=};;
  134. --includedir=*) GTEST_INCLUDEDIR=${1#--includedir=};;
  135. # Installation queries
  136. --prefix|--exec-prefix|--libdir|--includedir|--version)
  137. if test -n "${do_query}"; then
  138. show_usage
  139. exit 1
  140. fi
  141. do_query=${1#--}
  142. ;;
  143. # Version checking
  144. --min-version=*)
  145. do_check_versions=yes
  146. min_version=${1#--min-version=}
  147. ;;
  148. --max-version=*)
  149. do_check_versions=yes
  150. max_version=${1#--max-version=}
  151. ;;
  152. --exact-version=*)
  153. do_check_versions=yes
  154. exact_version=${1#--exact-version=}
  155. ;;
  156. # Compiler flag output
  157. --cppflags) echo_cppflags=yes;;
  158. --cxxflags) echo_cxxflags=yes;;
  159. --ldflags) echo_ldflags=yes;;
  160. --libs) echo_libs=yes;;
  161. # Everything else is an error
  162. *) show_usage; exit 1;;
  163. esac
  164. shift
  165. done
  166. # These have defaults filled in by the configure script but can also be
  167. # overridden by environment variables or command line parameters.
  168. prefix="${GTEST_PREFIX:-@prefix@}"
  169. exec_prefix="${GTEST_EXEC_PREFIX:-@exec_prefix@}"
  170. libdir="${GTEST_LIBDIR:-@libdir@}"
  171. includedir="${GTEST_INCLUDEDIR:-@includedir@}"
  172. # We try and detect if our binary is not located at its installed location. If
  173. # it's not, we provide variables pointing to the source and build tree rather
  174. # than to the install tree. This allows building against a just-built gtest
  175. # rather than an installed gtest.
  176. bindir="@bindir@"
  177. this_relative_bindir=`dirname $0`
  178. this_bindir=`cd ${this_relative_bindir}; pwd -P`
  179. if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
  180. # The path to the script doesn't end in the bindir sequence from Autoconf,
  181. # assume that we are in a build tree.
  182. build_dir=`dirname ${this_bindir}`
  183. src_dir=`cd ${this_bindir}; cd @top_srcdir@; pwd -P`
  184. # TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
  185. # should work to remove it, and/or remove libtool altogether, replacing it
  186. # with direct references to the library and a link path.
  187. gtest_libs="${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
  188. gtest_ldflags=""
  189. # We provide hooks to include from either the source or build dir, where the
  190. # build dir is always preferred. This will potentially allow us to write
  191. # build rules for generated headers and have them automatically be preferred
  192. # over provided versions.
  193. gtest_cppflags="-I${build_dir}/include -I${src_dir}/include"
  194. gtest_cxxflags="@PTHREAD_CFLAGS@"
  195. else
  196. # We're using an installed gtest, although it may be staged under some
  197. # prefix. Assume (as our own libraries do) that we can resolve the prefix,
  198. # and are present in the dynamic link paths.
  199. gtest_ldflags="-L${libdir}"
  200. gtest_libs="-l${name} @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
  201. gtest_cppflags="-I${includedir}"
  202. gtest_cxxflags="@PTHREAD_CFLAGS@"
  203. fi
  204. # Do an installation query if requested.
  205. if test -n "$do_query"; then
  206. case $do_query in
  207. prefix) echo $prefix; exit 0;;
  208. exec-prefix) echo $exec_prefix; exit 0;;
  209. libdir) echo $libdir; exit 0;;
  210. includedir) echo $includedir; exit 0;;
  211. version) echo $version; exit 0;;
  212. *) show_usage; exit 1;;
  213. esac
  214. fi
  215. # Do a version check if requested.
  216. if test "$do_check_versions" = "yes"; then
  217. # Make sure we didn't receive a bad combination of parameters.
  218. test "$echo_cppflags" = "yes" && show_usage && exit 1
  219. test "$echo_cxxflags" = "yes" && show_usage && exit 1
  220. test "$echo_ldflags" = "yes" && show_usage && exit 1
  221. test "$echo_libs" = "yes" && show_usage && exit 1
  222. if test "$exact_version" != ""; then
  223. check_versions $exact_version $exact_version
  224. # unreachable
  225. else
  226. check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999}
  227. # unreachable
  228. fi
  229. fi
  230. # Do the output in the correct order so that these can be used in-line of
  231. # a compiler invocation.
  232. output=""
  233. test "$echo_cppflags" = "yes" && output="$output $gtest_cppflags"
  234. test "$echo_cxxflags" = "yes" && output="$output $gtest_cxxflags"
  235. test "$echo_ldflags" = "yes" && output="$output $gtest_ldflags"
  236. test "$echo_libs" = "yes" && output="$output $gtest_libs"
  237. echo $output
  238. exit 0