Skip to content

Commit

Permalink
Attempt to fix travis mac build findlibuv
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Mar 30, 2018
1 parent 5fb676e commit 539fbed
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 49 deletions.
114 changes: 67 additions & 47 deletions CMake/Modules/FindLibUV.cmake
Original file line number Diff line number Diff line change
@@ -1,51 +1,71 @@
#=============================================================================
# Copyright 2016 The Luvit Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
# Locate libuv library
# This module defines
# LIBUV_FOUND, if false, do not try to link to libuv
# LIBUV_LIBRARIES
# LIBUV_INCLUDE_DIR, where to find uv.h
find_library(LibUV_LIBRARY
NAMES uv
)
mark_as_advanced(LibUV_LIBRARY)

find_path(
LIBUV_INCLUDE_DIR
NAMES uv.h
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
)
find_path(LibUV_INCLUDE_DIR
NAMES uv.h
)
mark_as_advanced(LibUV_INCLUDE_DIR)

find_path(LIBUV_INCLUDE_DIR NAMES uv.h)

find_library(
LIBUV_LIBRARIES
NAMES libuv.a uv libuv
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)

find_library(LIBUV_LIBRARIES NAMES libuv.a uv libuv)


if(WIN32)
list(APPEND LIBUV_LIBRARIES iphlpapi)
list(APPEND LIBUV_LIBRARIES psapi)
list(APPEND LIBUV_LIBRARIES userenv)
list(APPEND LIBUV_LIBRARIES ws2_32)
#-----------------------------------------------------------------------------
# Extract version number if possible.
set(_LibUV_H_REGEX "#[ \t]*define[ \t]+UV_VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+")
if(LibUV_INCLUDE_DIR AND EXISTS "${LibUV_INCLUDE_DIR}/uv-version.h")
file(STRINGS "${LibUV_INCLUDE_DIR}/uv-version.h" _LibUV_H REGEX "${_LibUV_H_REGEX}")
elseif(LibUV_INCLUDE_DIR AND EXISTS "${LibUV_INCLUDE_DIR}/uv.h")
file(STRINGS "${LibUV_INCLUDE_DIR}/uv.h" _LibUV_H REGEX "${_LibUV_H_REGEX}")
else()
set(_LibUV_H "")
endif()
foreach(c MAJOR MINOR PATCH)
if(_LibUV_H MATCHES "#[ \t]*define[ \t]+UV_VERSION_${c}[ \t]+([0-9]+)")
set(_LibUV_VERSION_${c} "${CMAKE_MATCH_1}")
else()
unset(_LibUV_VERSION_${c})
endif()
endforeach()
if(DEFINED _LibUV_VERSION_MAJOR AND DEFINED _LibUV_VERSION_MINOR)
set(LibUV_VERSION_MAJOR "${_LibUV_VERSION_MAJOR}")
set(LibUV_VERSION_MINOR "${_LibUV_VERSION_MINOR}")
set(LibUV_VERSION "${LibUV_VERSION_MAJOR}.${LibUV_VERSION_MINOR}")
if(DEFINED _LibUV_VERSION_PATCH)
set(LibUV_VERSION_PATCH "${_LibUV_VERSION_PATCH}")
set(LibUV_VERSION "${LibUV_VERSION}.${LibUV_VERSION_PATCH}")
else()
unset(LibUV_VERSION_PATCH)
endif()
else()
set(LibUV_VERSION_MAJOR "")
set(LibUV_VERSION_MINOR "")
set(LibUV_VERSION_PATCH "")
set(LibUV_VERSION "")
endif()
unset(_LibUV_VERSION_MAJOR)
unset(_LibUV_VERSION_MINOR)
unset(_LibUV_VERSION_PATCH)
unset(_LibUV_H_REGEX)
unset(_LibUV_H)

#-----------------------------------------------------------------------------
include(${CMAKE_CURRENT_LIST_DIR}/../../Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUV
FOUND_VAR LibUV_FOUND
REQUIRED_VARS LibUV_LIBRARY LibUV_INCLUDE_DIR
VERSION_VAR LibUV_VERSION
)
set(LIBUV_FOUND ${LibUV_FOUND})

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUV DEFAULT_MSG LIBUV_LIBRARIES LIBUV_INCLUDE_DIR)
#-----------------------------------------------------------------------------
# Provide documented result variables and targets.
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_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LibUV_INCLUDE_DIRS}"
)
endif()
endif()
4 changes: 2 additions & 2 deletions extern/CMakeProject-uwebsocket.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ if(NOT MSVC)
file(GLOB SOURCES "${SM_EXTERN_DIR}/uWebSocket/src/*.cpp")
add_library("uWS" STATIC ${SOURCES})
set_property(TARGET "uWS" PROPERTY FOLDER "External Libraries")
target_include_directories("uWS" PUBLIC ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} "${SM_EXTERN_DIR}/uWebSocket/include")
target_link_libraries("uWS" PUBLIC ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBUV_LIBRARY})
target_include_directories("uWS" PUBLIC ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ${LibUV_INCLUDE_DIRS} "${SM_EXTERN_DIR}/uWebSocket/include")
target_link_libraries("uWS" PUBLIC ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${LibUV_LIBRARIES})
endif()

0 comments on commit 539fbed

Please sign in to comment.