| 1 |
# |
| 2 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
# or more contributor license agreements. See the NOTICE file |
| 4 |
# distributed with this work for additional information |
| 5 |
# regarding copyright ownership. The ASF licenses this file |
| 6 |
# to you under the Apache License, Version 2.0 (the |
| 7 |
# "License"); you may not use this file except in compliance |
| 8 |
# with the License. You may obtain a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, |
| 13 |
# software distributed under the License is distributed on an |
| 14 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
# KIND, either express or implied. See the License for the |
| 16 |
# specific language governing permissions and limitations |
| 17 |
# under the License. |
| 18 |
# |
| 19 |
|
| 20 |
#.rst |
| 21 |
# FindJsonCpp |
| 22 |
#---------- |
| 23 |
# |
| 24 |
# Find jsoncpp include directories and libraries. |
| 25 |
# |
| 26 |
# Sets the following variables: |
| 27 |
# |
| 28 |
# JsonCpp_FOUND - True if headers and requested libraries were found |
| 29 |
# JsonCpp_INCLUDE_DIRS - JsonCpp include directories |
| 30 |
# JsonCpp_LIBRARIES - Link these to use jsoncpp. |
| 31 |
# |
| 32 |
# This module reads hints about search locations from variables:: |
| 33 |
# JSONCPP_ROOT - Preferred installation prefix |
| 34 |
# JSONCPP_INCLUDEDIR - Preferred include directory e.g. <prefix>/include |
| 35 |
# JSONCPP_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib |
| 36 |
|
| 37 |
find_package (PkgConfig) |
| 38 |
pkg_check_modules (PC_JsonCpp QUIET jsoncpp) |
| 39 |
|
| 40 |
find_library(JsonCpp_LIBRARY NAMES jsoncpp libjsoncpp |
| 41 |
HINTS ${JSONCPP_LIBRARYDIR} ${JSONCPP_ROOT}/lib ${CMAKE_INSTALL_PREFIX}/lib |
| 42 |
PATHS ${PC_JsonCpp_LIBRARY_DIRS}) |
| 43 |
|
| 44 |
find_path(JsonCpp_INCLUDE_DIR NAMES json/json.h json/value.h |
| 45 |
HINTS ${JSONCPP_INCLUDEDIR} ${JSONCPP_ROOT}/include ${CMAKE_INSTALL_PREFIX}/include |
| 46 |
PATHS /usr/include ${PC_JsonCpp_INCLUDE_DIRS}) |
| 47 |
|
| 48 |
set(JsonCpp_VERSION ${PC_JsonCpp_VERSION}) |
| 49 |
|
| 50 |
include(FindPackageHandleStandardArgs) |
| 51 |
find_package_handle_standard_args(JsonCpp |
| 52 |
FOUND_VAR JsonCpp_FOUND |
| 53 |
REQUIRED_VARS JsonCpp_LIBRARY JsonCpp_INCLUDE_DIR |
| 54 |
VERSION_VAR JsonCpp_VERSION) |
| 55 |
|
| 56 |
if (JsonCpp_FOUND) |
| 57 |
set(JsonCpp_INCLUDE_DIRS ${JsonCpp_INCLUDE_DIR}) |
| 58 |
set(JsonCpp_LIBRARIES ${JsonCpp_LIBRARY}) |
| 59 |
|
| 60 |
if (NOT TARGET JsonCpp::JsonCpp) |
| 61 |
add_library(JsonCpp::JsonCpp UNKNOWN IMPORTED) |
| 62 |
set_target_properties(JsonCpp::JsonCpp |
| 63 |
PROPERTIES |
| 64 |
IMPORTED_LOCATION "${JsonCpp_LIBRARY}" |
| 65 |
INTERFACE_INCLUDE_DIRECTORIES "${JsonCpp_INCLUDE_DIR}" |
| 66 |
) |
| 67 |
endif () |
| 68 |
|
| 69 |
endif () |
| 70 |
|
| 71 |
mark_as_advanced (JsonCpp_LIBRARY JsonCpp_INCLUDE_DIR) |