Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Add find module: CppNetlib [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Dec 28, 2013
1 parent d811075 commit c05d863
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
122 changes: 122 additions & 0 deletions cmake/find/FindCppNetlib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Copyright (c) 2013, Ruslan Baratov
# All rights reserved.

# Try to find CppNetlib library
#
# Input variables:
# CPPNETLIB_ROOT - CppNetlib installation root
#
# Output variables:
# CPPNETLIB_INCLUDE_DIR - include directories
# CPPNETLIB_LIBRARIES - libraries (client-connections, server-parsers, uri)
# CPPNETLIB_FOUND - is 'YES' if library found

# Libraries variants:
# CPPNETLIB_URI_LIBRARY
# CPPNETLIB_URI_LIBRARY_DEBUG
# CPPNETLIB_URI_LIBRARY_RELEASE
# CPPNETLIB_CLIENT_CONNECTIONS_LIBRARY
# CPPNETLIB_CLIENT_CONNECTIONS_LIBRARY_DEBUG
# CPPNETLIB_CLIENT_CONNECTIONS_LIBRARY_RELEASE
# CPPNETLIB_SERVER_PARSERS_LIBRARY
# CPPNETLIB_SERVER_PARSERS_LIBRARY_DEBUG
# CPPNETLIB_SERVER_PARSERS_LIBRARY_RELEASE

set(CPPNETLIB_FOUND YES)

find_path(
CPPNETLIB_INCLUDE_DIR
NAMES
"boost/network.hpp"
HINTS
"${CPPNETLIB_ROOT}"
ENV
"CPPNETLIB_ROOT"
PATH_SUFFIXES
"include"
)

function(_find_cppnetlib_diagnostic_message pattern)
if(CPPNETLIB_ROOT)
message("CPPNETLIB_ROOT(cmake): ${CPPNETLIB_ROOT}")
endif()
if($ENV{CPPNETLIB_ROOT})
message("CPPNETLIB_ROOT(env): $ENV{CPPNETLIB_ROOT}")
endif()

message(
FATAL_ERROR
"CppNetlib not found (pattern '${pattern}' not found)."
"Please set CPPNETLIB_ROOT variable (cmake or environment)"
)
endfunction()

if(NOT CPPNETLIB_INCLUDE_DIR)
set(CPPNETLIB_FOUND NO)
if(CppNetlib_FIND_REQUIRED)
_find_cppnetlib_diagnostic_message("include/boost/network/hpp")
endif()
endif()

foreach(lib uri client-connections server-parsers)
string(TOUPPER "${lib}" _find_cppnetlib_upper)
string(REPLACE "-" "_" _find_cppnetlib_upper "${_find_cppnetlib_upper}")
set(_find_cppnetlib_upper "CPPNETLIB_${_find_cppnetlib_upper}_LIBRARY")
set(
_find_cppnetlib_upper_release
"${_find_cppnetlib_upper}_RELEASE"
)
set(
_find_cppnetlib_upper_debug
"${_find_cppnetlib_upper}_DEBUG"
)
set(_find_cppnetlib_lower_release "cppnetlib-${lib}")
set(_find_cppnetlib_lower_debug "cppnetlib-${lib}${CMAKE_DEBUG_POSTFIX}")

find_library(
${_find_cppnetlib_upper_release}
${_find_cppnetlib_lower_release}
HINTS
"${CPPNETLIB_ROOT}"
ENV
"CPPNETLIB_ROOT"
PATH_SUFFIXES
"lib"
)

if(CMAKE_DEBUG_POSTFIX)
find_library(
${_find_cppnetlib_upper_debug}
${_find_cppnetlib_lower_debug}
HINTS
"${CPPNETLIB_ROOT}"
ENV
"CPPNETLIB_ROOT"
PATH_SUFFIXES
"lib"
)
endif()

if(${_find_cppnetlib_upper_debug} AND ${_find_cppnetlib_upper_release})
set(
${_find_cppnetlib_upper}
debug
${${_find_cppnetlib_upper_debug}}
release
${${_find_cppnetlib_upper_release}}
)
elseif(${_find_cppnetlib_upper_release})
set(${_find_cppnetlib_upper} ${${_find_cppnetlib_upper_release}})
else()
set(CPPNETLIB_FOUND NO)
if(CppNetlib_FIND_REQUIRED)
_find_cppnetlib_diagnostic_message(
"lib/...${_find_cppnetlib_lower_release}..."
)
endif()
endif()

if(${_find_cppnetlib_upper})
list(APPEND CPPNETLIB_LIBRARIES ${${_find_cppnetlib_upper}})
endif()
endforeach()
1 change: 1 addition & 0 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(HUNTER_VERSION "0.0.12")

0 comments on commit c05d863

Please sign in to comment.