Created
October 3, 2019 14:43
-
-
Save 00-matt/9595045e27f3b18e779867280e2101f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find_path(LIBUV_INCLUDE_DIR NAMES uv.h) | |
mark_as_advanced(LIBUV_INCLUDE_DIR) | |
find_library(LIBUV_LIBRARY NAMES uv libuv) | |
mark_as_advanced(LIBUV_LIBRARY) | |
if(DEFINED LIBUV_INCLUDE_DIR AND EXISTS "${LIBUV_INCLUDE_DIR}/uv/version.h") | |
file(STRINGS "${LIBUV_INCLUDE_DIR}/uv/version.h" _LIBUV_H REGEX | |
"#define UV_VERSION_(MAJOR|MINOR|PATCH) [0-9]+") | |
foreach(c MAJOR MINOR PATCH) | |
if(_LIBUV_H MATCHES "#define UV_VERSION_${c} ([0-9]+)") | |
set(LIBUV_VERSION_${c} "${CMAKE_MATCH_1}") | |
endif() | |
endforeach() | |
unset(_LIBUV_H) | |
set(LIBUV_VERSION "${LIBUV_VERSION_MAJOR}.${LIBUV_VERSION_MINOR}.${LIBUV_VERSION_PATCH}") | |
endif() | |
include(FindPackageHandleStandardArgs) | |
find_package_handle_standard_args(libuv | |
REQUIRED_VARS LIBUV_INCLUDE_DIR LIBUV_LIBRARY | |
VERSION_VAR LIBUV_VERSION) | |
if(LIBUV_FOUND) | |
set(LIBUV_INCLUDE_DIRS "${LIBUV_INCLUDE_DIR}") | |
set(LIBUV_LIBRARIES "${LIBUV_LIBRARY}") | |
if(NOT TARGET libuv::libuv) | |
add_library(libuv::libuv UNKNOWN IMPORTED) | |
set_target_properties(libuv::libuv PROPERTIES | |
IMPORTED_LOCATION "${LIBUV_LIBRARIES}" | |
INTERFACE_INCLUDE_DIRECTORIES "${LIBUV_INCLUDE_DIRS}") | |
endif() | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment