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
|
#
#
# - Find regex
# Find the native REGEX includes and library
#
# REGEX_INCLUDE_DIR - where to find regex.h, etc.
# REGEX_LIBRARY - List of libraries when using regex.
# REGEX_FOUND - True if regex found.
#
# - Locate a C-style regex library
# This module defines
# REGEX_LIBRARY, the library to link against, if needed
# REGEX_FOUND, if false, do not try to link to regex
# REGEX_INCLUDE_DIR, where to find regex.h
#
set (REGEX_FOUND "NO")
include (CheckCSourceCompiles)
set (REGEX_LIBRARY)
find_path (REGEX_INCLUDE_DIR
NAMES regex.h
PATH_SUFFIXES include include/awk
PATHS
$ENV{REGEXDIR}
/usr
/sw
/opt/local
/opt/csw
/opt
/usr/local
)
#try compiling, even if not found
check_c_source_compiles ("int main() {(void)regcomp();}" REGCOMP_IN_LIBC)
if (REGEX_INCLUDE_DIR)
if (NOT REGCOMP_IN_LIBC)
# we need to link some library
find_library (REGEX_LIBRARY_TEMP
NAMES regex
PATH_SUFFIXES lib
PATHS
$ENV{REGEXDIR}
/usr
/sw
/opt/local
/opt/csw
/opt
/usr/local
)
if (REGEX_LIBRARY_TEMP)
set (CMAKE_REQUIRED_LIBRARIES ${REGEX_LIBRARY_TEMP})
check_c_source_compiles ("int main() {(void)regcomp();}" REGCOMP_IN_REGEX)
if (REGCOMP_IN_REGEX)
set (REGEX_LIBRARY ${REGEX_LIBRARY_TEMP})
set (REGEX_FOUND "YES")
else (REGCOMP_IN_REGEX)
message ("I found regex.h and a libregex but couldn't get regcomp() to compile")
endif (REGCOMP_IN_REGEX)
else (REGEX_LIBRARY_TEMP)
message ("I found regex.h but regcomp() is not in libc or libregex")
endif (REGEX_LIBRARY_TEMP)
else (NOT REGCOMP_IN_LIBC)
set (REGEX_FOUND "YES")
endif (NOT REGCOMP_IN_LIBC)
else (REGEX_INCLUDE_DIR)
if (REGCOMP_IN_LIBC)
message ("regcomp() exists in libc, but I can't locate regex.h")
endif (REGCOMP_IN_LIBC)
endif (REGEX_INCLUDE_DIR)
mark_as_advanced (REGEX_LIBRARY_TEMP REGCOMP_IN_LIBC REGCOMP_IN_REGEX)
|