diff options
Diffstat (limited to 'project/cmake/modules/FindPCRE.cmake')
| -rw-r--r-- | project/cmake/modules/FindPCRE.cmake | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/project/cmake/modules/FindPCRE.cmake b/project/cmake/modules/FindPCRE.cmake new file mode 100644 index 0000000..54c4ab4 --- /dev/null +++ b/project/cmake/modules/FindPCRE.cmake | |||
| @@ -0,0 +1,91 @@ | |||
| 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 | PATH_SUFFIXES ${CONFIGURATION_LIBDIR_RELEASE} | ||
| 26 | PATHS ${PC_PCRE_LIBDIR}) | ||
| 27 | find_library(PCRE_LIBRARY_RELEASE NAMES pcre | ||
| 28 | PATH_SUFFIXES ${CONFIGURATION_LIBDIR_RELEASE} | ||
| 29 | PATHS ${PC_PCRE_LIBDIR}) | ||
| 30 | find_library(PCRECPP_LIBRARY_DEBUG NAMES pcrecppd | ||
| 31 | PATH_SUFFIXES ${CONFIGURATION_LIBDIR_DEBUG} | ||
| 32 | PATHS ${PC_PCRE_LIBDIR}) | ||
| 33 | find_library(PCRE_LIBRARY_DEBUG NAMES pcred | ||
| 34 | PATH_SUFFIXES ${CONFIGURATION_LIBDIR_DEBUG} | ||
| 35 | PATHS ${PC_PCRE_LIBDIR}) | ||
| 36 | set(PCRE_VERSION ${PC_PCRE_VERSION}) | ||
| 37 | |||
| 38 | include(SelectLibraryConfigurations) | ||
| 39 | select_library_configurations(PCRECPP) | ||
| 40 | select_library_configurations(PCRE) | ||
| 41 | |||
| 42 | include(FindPackageHandleStandardArgs) | ||
| 43 | find_package_handle_standard_args(PCRE | ||
| 44 | REQUIRED_VARS PCRECPP_LIBRARY PCRE_LIBRARY PCRE_INCLUDE_DIR | ||
| 45 | VERSION_VAR PCRE_VERSION) | ||
| 46 | |||
| 47 | if(PCRE_FOUND) | ||
| 48 | set(PCRE_LIBRARIES ${PCRECPP_LIBRARY} ${PCRE_LIBRARY}) | ||
| 49 | set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) | ||
| 50 | if(WIN32) | ||
| 51 | set(PCRE_DEFINITIONS -DPCRE_STATIC=1) | ||
| 52 | endif() | ||
| 53 | |||
| 54 | if(NOT TARGET PCRE::PCRE) | ||
| 55 | add_library(PCRE::PCRE UNKNOWN IMPORTED) | ||
| 56 | if(PCRE_LIBRARY_RELEASE) | ||
| 57 | set_target_properties(PCRE::PCRE PROPERTIES | ||
| 58 | IMPORTED_CONFIGURATIONS RELEASE | ||
| 59 | IMPORTED_LOCATION "${PCRE_LIBRARY_RELEASE}") | ||
| 60 | endif() | ||
| 61 | if(PCRE_LIBRARY_DEBUG) | ||
| 62 | set_target_properties(PCRE::PCRE PROPERTIES | ||
| 63 | IMPORTED_CONFIGURATIONS DEBUG | ||
| 64 | IMPORTED_LOCATION "${PCRE_LIBRARY_DEBUG}") | ||
| 65 | endif() | ||
| 66 | set_target_properties(PCRE::PCRE PROPERTIES | ||
| 67 | INTERFACE_INCLUDE_DIRECTORIES "${PCRE_INCLUDE_DIR}") | ||
| 68 | if(WIN32) | ||
| 69 | set_target_properties(PCRE::PCRE PROPERTIES | ||
| 70 | INTERFACE_COMPILE_DEFINITIONS PCRE_STATIC=1) | ||
| 71 | endif() | ||
| 72 | |||
| 73 | endif() | ||
| 74 | if(NOT TARGET PCRE::PCRECPP) | ||
| 75 | add_library(PCRE::PCRECPP UNKNOWN IMPORTED) | ||
| 76 | if(PCRE_LIBRARY_RELEASE) | ||
| 77 | set_target_properties(PCRE::PCRECPP PROPERTIES | ||
| 78 | IMPORTED_CONFIGURATIONS RELEASE | ||
| 79 | IMPORTED_LOCATION "${PCRECPP_LIBRARY_RELEASE}") | ||
| 80 | endif() | ||
| 81 | if(PCRE_LIBRARY_DEBUG) | ||
| 82 | set_target_properties(PCRE::PCRECPP PROPERTIES | ||
| 83 | IMPORTED_CONFIGURATIONS DEBUG | ||
| 84 | IMPORTED_LOCATION "${PCRECPP_LIBRARY_DEBUG}") | ||
| 85 | endif() | ||
| 86 | set_target_properties(PCRE::PCRECPP PROPERTIES | ||
| 87 | INTERFACE_LINK_LIBRARIES PCRE::PCRE) | ||
| 88 | endif() | ||
| 89 | endif() | ||
| 90 | |||
| 91 | mark_as_advanced(PCRE_INCLUDE_DIR PCRECPP_LIBRARY PCRE_LIBRARY) | ||
