Detect Regex lib with cmake instead of pkg_config

This commit is contained in:
Gilles Caulier
2018-10-10 07:58:12 +02:00
committed by Luis Díaz Más
parent 11e66c6c9e
commit af44cec65f
2 changed files with 49 additions and 2 deletions
+48
View File
@@ -0,0 +1,48 @@
# - Try to find the Regex library
#
# Once done this will define
#
# REGEX_FOUND - system has libregex
# REGEX_INCLUDE_DIR - the libregex include directory
# REGEX_LIBRARIES - Link these to use libregex
#
# Copyright (c) 2018, Gilles Caulier, <caulier dot gilles at gmail dot com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
find_path(Regex_INCLUDE_DIR
NAMES regex.h
DOC "libregex include directory"
)
mark_as_advanced(Regex_INCLUDE_DIR)
find_library(Regex_LIBRARY "regex"
DOC "libregex libraries"
)
mark_as_advanced(Regex_LIBRARY)
find_package_handle_standard_args(Regex
FOUND_VAR Regex_FOUND
REQUIRED_VARS Regex_INCLUDE_DIR
FAIL_MESSAGE "Failed to find libregex"
)
if(REGEX_FOUND)
set(REGEX_INCLUDE_DIRS ${Regex_INCLUDE_DIRS})
if(Regex_LIBRARY)
set(REGEX_LIBRARIES ${Regex_LIBRARY})
else()
unset(REGEX_LIBRARIES)
endif()
endif()
+1 -2
View File
@@ -11,8 +11,7 @@ endif()
find_package(Threads REQUIRED)
if(MINGW)
find_package(PkgConfig REQUIRED)
pkg_check_modules(REGEX REQUIRED regex)
find_package(Regex REQUIRED)
if(REGEX_FOUND)
include_directories(${REGEX_INCLUDE_DIRS})
endif()