diff options
Diffstat (limited to 'cmake/modules/FindPCRE.cmake')
| -rw-r--r-- | cmake/modules/FindPCRE.cmake | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/cmake/modules/FindPCRE.cmake b/cmake/modules/FindPCRE.cmake new file mode 100644 index 0000000..8babed3 --- /dev/null +++ b/cmake/modules/FindPCRE.cmake | |||
| @@ -0,0 +1,87 @@ | |||
| 1 | #.rst: | ||
| 2 | # FindPCRE | ||
| 3 | # -------- | ||
| 4 | # Finds the PCRECPP library | ||
| 5 | # | ||
| 6 | # This will will define the following variables:: | ||
| 7 | # | ||
| 8 | # PCRE_FOUND - system has libpcrecpp | ||
| 9 | # PCRE_INCLUDE_DIRS - the libpcrecpp include directory | ||
| 10 | # PCRE_LIBRARIES - the libpcrecpp libraries | ||
| 11 | # PCRE_DEFINITIONS - the libpcrecpp definitions | ||
| 12 | # | ||
| 13 | # and the following imported targets:: | ||
| 14 | # | ||
| 15 | # PCRE::PCRECPP - The PCRECPP library | ||
| 16 | # PCRE::PCRE - The PCRE library | ||
| 17 | |||
| 18 | if(PKG_CONFIG_FOUND) | ||
| 19 | pkg_check_modules(PC_PCRE libpcrecpp QUIET) | ||
| 20 | endif() | ||
| 21 | |||
| 22 | find_path(PCRE_INCLUDE_DIR pcrecpp.h | ||
| 23 | PATHS ${PC_PCRE_INCLUDEDIR}) | ||
| 24 | find_library(PCRECPP_LIBRARY_RELEASE NAMES pcrecpp | ||
| 25 | PATHS ${PC_PCRE_LIBDIR}) | ||
| 26 | find_library(PCRE_LIBRARY_RELEASE NAMES pcre | ||
| 27 | PATHS ${PC_PCRE_LIBDIR}) | ||
| 28 | find_library(PCRECPP_LIBRARY_DEBUG NAMES pcrecppd | ||
| 29 | PATHS ${PC_PCRE_LIBDIR}) | ||
| 30 | find_library(PCRE_LIBRARY_DEBUG NAMES pcred | ||
| 31 | PATHS ${PC_PCRE_LIBDIR}) | ||
| 32 | set(PCRE_VERSION ${PC_PCRE_VERSION}) | ||
| 33 | |||
| 34 | include(SelectLibraryConfigurations) | ||
| 35 | select_library_configurations(PCRECPP) | ||
| 36 | select_library_configurations(PCRE) | ||
| 37 | |||
| 38 | include(FindPackageHandleStandardArgs) | ||
| 39 | find_package_handle_standard_args(PCRE | ||
| 40 | REQUIRED_VARS PCRECPP_LIBRARY PCRE_LIBRARY PCRE_INCLUDE_DIR | ||
| 41 | VERSION_VAR PCRE_VERSION) | ||
| 42 | |||
| 43 | if(PCRE_FOUND) | ||
| 44 | set(PCRE_LIBRARIES ${PCRECPP_LIBRARY} ${PCRE_LIBRARY}) | ||
| 45 | set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) | ||
| 46 | if(WIN32) | ||
| 47 | set(PCRE_DEFINITIONS -DPCRE_STATIC=1) | ||
| 48 | endif() | ||
| 49 | |||
| 50 | if(NOT TARGET PCRE::PCRE) | ||
| 51 | add_library(PCRE::PCRE UNKNOWN IMPORTED) | ||
| 52 | if(PCRE_LIBRARY_RELEASE) | ||
| 53 | set_target_properties(PCRE::PCRE PROPERTIES | ||
| 54 | IMPORTED_CONFIGURATIONS RELEASE | ||
| 55 | IMPORTED_LOCATION "${PCRE_LIBRARY_RELEASE}") | ||
| 56 | endif() | ||
| 57 | if(PCRE_LIBRARY_DEBUG) | ||
| 58 | set_target_properties(PCRE::PCRE PROPERTIES | ||
| 59 | IMPORTED_CONFIGURATIONS DEBUG | ||
| 60 | IMPORTED_LOCATION "${PCRE_LIBRARY_DEBUG}") | ||
| 61 | endif() | ||
| 62 | set_target_properties(PCRE::PCRE PROPERTIES | ||
| 63 | INTERFACE_INCLUDE_DIRECTORIES "${PCRE_INCLUDE_DIR}") | ||
| 64 | if(WIN32) | ||
| 65 | set_target_properties(PCRE::PCRE PROPERTIES | ||
| 66 | INTERFACE_COMPILE_DEFINITIONS PCRE_STATIC=1) | ||
| 67 | endif() | ||
| 68 | |||
| 69 | endif() | ||
| 70 | if(NOT TARGET PCRE::PCRECPP) | ||
| 71 | add_library(PCRE::PCRECPP UNKNOWN IMPORTED) | ||
| 72 | if(PCRE_LIBRARY_RELEASE) | ||
| 73 | set_target_properties(PCRE::PCRECPP PROPERTIES | ||
| 74 | IMPORTED_CONFIGURATIONS RELEASE | ||
| 75 | IMPORTED_LOCATION "${PCRECPP_LIBRARY_RELEASE}") | ||
| 76 | endif() | ||
| 77 | if(PCRE_LIBRARY_DEBUG) | ||
| 78 | set_target_properties(PCRE::PCRECPP PROPERTIES | ||
| 79 | IMPORTED_CONFIGURATIONS DEBUG | ||
| 80 | IMPORTED_LOCATION "${PCRECPP_LIBRARY_DEBUG}") | ||
| 81 | endif() | ||
| 82 | set_target_properties(PCRE::PCRECPP PROPERTIES | ||
| 83 | INTERFACE_LINK_LIBRARIES PCRE::PCRE) | ||
| 84 | endif() | ||
| 85 | endif() | ||
| 86 | |||
| 87 | mark_as_advanced(PCRE_INCLUDE_DIR PCRECPP_LIBRARY PCRE_LIBRARY) | ||
