Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

FindREGEX.cmake 1.9 KB

You have to be logged in to leave a comment. Sign In
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
78
  1. #
  2. # $Id$
  3. #
  4. # - Find regex
  5. # Find the native REGEX includes and library
  6. #
  7. # REGEX_INCLUDE_DIR - where to find regex.h, etc.
  8. # REGEX_LIBRARY - List of libraries when using regex.
  9. # REGEX_FOUND - True if regex found.
  10. #
  11. # - Locate a C-style regex library
  12. # This module defines
  13. # REGEX_LIBRARY, the library to link against, if needed
  14. # REGEX_FOUND, if false, do not try to link to regex
  15. # REGEX_INCLUDE_DIR, where to find regex.h
  16. #
  17. set (REGEX_FOUND "NO")
  18. include (CheckCSourceCompiles)
  19. set (REGEX_LIBRARY)
  20. find_path (REGEX_INCLUDE_DIR
  21. NAMES regex.h
  22. PATH_SUFFIXES include include/awk
  23. PATHS
  24. $ENV{REGEXDIR}
  25. /usr
  26. /sw
  27. /opt/local
  28. /opt/csw
  29. /opt
  30. /usr/local
  31. )
  32. #try compiling, even if not found
  33. check_c_source_compiles ("int main() {(void)regcomp();}" REGCOMP_IN_LIBC)
  34. if (REGEX_INCLUDE_DIR)
  35. if (NOT REGCOMP_IN_LIBC)
  36. # we need to link some library
  37. find_library (REGEX_LIBRARY_TEMP
  38. NAMES regex
  39. PATH_SUFFIXES lib
  40. PATHS
  41. $ENV{REGEXDIR}
  42. /usr
  43. /sw
  44. /opt/local
  45. /opt/csw
  46. /opt
  47. /usr/local
  48. )
  49. if (REGEX_LIBRARY_TEMP)
  50. set (CMAKE_REQUIRED_LIBRARIES ${REGEX_LIBRARY_TEMP})
  51. check_c_source_compiles ("int main() {(void)regcomp();}" REGCOMP_IN_REGEX)
  52. if (REGCOMP_IN_REGEX)
  53. set (REGEX_LIBRARY ${REGEX_LIBRARY_TEMP})
  54. set (REGEX_FOUND "YES")
  55. else (REGCOMP_IN_REGEX)
  56. message ("I found regex.h and a libregex but couldn't get regcomp() to compile")
  57. endif (REGCOMP_IN_REGEX)
  58. else (REGEX_LIBRARY_TEMP)
  59. message ("I found regex.h but regcomp() is not in libc or libregex")
  60. endif (REGEX_LIBRARY_TEMP)
  61. else (NOT REGCOMP_IN_LIBC)
  62. set (REGEX_FOUND "YES")
  63. endif (NOT REGCOMP_IN_LIBC)
  64. else (REGEX_INCLUDE_DIR)
  65. if (REGCOMP_IN_LIBC)
  66. message ("regcomp() exists in libc, but I can't locate regex.h")
  67. endif (REGCOMP_IN_LIBC)
  68. endif (REGEX_INCLUDE_DIR)
  69. mark_as_advanced (REGEX_LIBRARY_TEMP REGCOMP_IN_LIBC REGCOMP_IN_REGEX)
  70. # vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...