| 1 |
# === This file is part of Calamares - <https://calamares.io> === |
| 2 |
# |
| 3 |
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <[email protected]> |
| 4 |
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <[email protected]> |
| 5 |
# SPDX-License-Identifier: BSD-2-Clause |
| 6 |
# |
| 7 |
### |
| 8 |
# |
| 9 |
# Locate yaml-cpp |
| 10 |
# |
| 11 |
# This module defines |
| 12 |
# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp |
| 13 |
# YAMLCPP_LIBRARY, where to find yaml-cpp |
| 14 |
# YAMLCPP_INCLUDE_DIR, where to find yaml.h |
| 15 |
# There is also one IMPORTED library target, |
| 16 |
# yamlcpp::yamlcpp |
| 17 |
# |
| 18 |
# By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead, |
| 19 |
# you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...). |
| 20 |
# |
| 21 |
# If yaml-cpp is not installed in a standard path, you can use the YAMLCPP_DIR CMake variable |
| 22 |
# to tell CMake where yaml-cpp is. |
| 23 |
|
| 24 |
if(TARGET yamlcpp::yamlcpp) |
| 25 |
return() |
| 26 |
endif() |
| 27 |
|
| 28 |
# attempt to find static library first if this is set |
| 29 |
if(YAMLCPP_STATIC_LIBRARY) |
| 30 |
set(YAMLCPP_STATIC libyaml-cpp.a) |
| 31 |
endif() |
| 32 |
|
| 33 |
# find the yaml-cpp include directory |
| 34 |
find_path(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h |
| 35 |
PATH_SUFFIXES include |
| 36 |
PATHS |
| 37 |
~/Library/Frameworks/yaml-cpp/include/ |
| 38 |
/Library/Frameworks/yaml-cpp/include/ |
| 39 |
/usr/local/include/ |
| 40 |
/usr/include/ |
| 41 |
/sw/yaml-cpp/ # Fink |
| 42 |
/opt/local/yaml-cpp/ # DarwinPorts |
| 43 |
/opt/csw/yaml-cpp/ # Blastwave |
| 44 |
/opt/yaml-cpp/ |
| 45 |
${YAMLCPP_DIR}/include/) |
| 46 |
|
| 47 |
# find the yaml-cpp library |
| 48 |
find_library(YAMLCPP_LIBRARY |
| 49 |
NAMES ${YAMLCPP_STATIC} yaml-cpp |
| 50 |
PATH_SUFFIXES lib64 lib |
| 51 |
PATHS ~/Library/Frameworks |
| 52 |
/Library/Frameworks |
| 53 |
/usr/local |
| 54 |
/usr |
| 55 |
/sw |
| 56 |
/opt/local |
| 57 |
/opt/csw |
| 58 |
/opt |
| 59 |
${YAMLCPP_DIR}/lib) |
| 60 |
|
| 61 |
# handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE |
| 62 |
include(FindPackageHandleStandardArgs) |
| 63 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) |
| 64 |
mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) |
| 65 |
|
| 66 |
# Add an imported target |
| 67 |
if( YAMLCPP_LIBRARY ) |
| 68 |
add_library( yamlcpp::yamlcpp UNKNOWN IMPORTED ) |
| 69 |
set_property( TARGET yamlcpp::yamlcpp PROPERTY IMPORTED_LOCATION ${YAMLCPP_LIBRARY} ) |
| 70 |
if ( YAMLCPP_INCLUDE_DIR ) |
| 71 |
set_property( TARGET yamlcpp::yamlcpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} ) |
| 72 |
endif() |
| 73 |
endif() |