Skip to content
Snippets Groups Projects
Commit 72e5a09c authored by Coenen, Joachim's avatar Coenen, Joachim :grin:
Browse files

added FindLibyaml.cmake

parent 56909097
No related branches found
No related tags found
1 merge request!2Replace yaml cpp with libyaml
......@@ -39,6 +39,7 @@ find_package(Readline REQUIRED)
find_package(GSL REQUIRED)
find_package(FFTW_DBL REQUIRED)
find_package(YamlCpp05 REQUIRED)
find_package(Libyaml REQUIRED)
find_package(KWW REQUIRED)
find_package(Cerf REQUIRED) # currently we only accept the C version of the library
find_package(LMFit REQUIRED)
......
# Find libyaml with API version ?.?
#
# Usage:
# find_package(libyaml [REQUIRED] [QUIET])
#
# Sets the following variables:
# - LIBYAML_FOUND .. true if library is found
# - LIBYAML_LIBRARIES .. full path to library
# - LIBYAML_INCLUDE_DIR .. full path to include directory
#
# Honors the following optional variables:
# - LIBYAML_INCLUDE_LOC .. include directory path, to be searched before defaults
# - LIBYAML_LIBRARY_LOC .. the library's directory path, to be searched before defaults
# - LIBYAML_STATIC_LIBRARY .. if true, find the static library version
#
# Copyright 2015 Joachim Wuttke, Forschungszentrum Jülich.
# Redistribution permitted.
include (CheckCppIncludeFile)
include (CheckCXXSourceRuns)
# find the yaml-cpp include directory
find_path(LIBYAML_INCLUDE_DIR yaml/yaml.h
PATH_SUFFIXES include yaml/include yaml
PATHS
${LIBYAML_INCLUDE_LOC}
~/Library/Frameworks/
/Library/Frameworks/
/usr/local/
/usr/
/sw/ # Fink
/opt/local/ # DarwinPorts
/opt/csw/ # Blastwave
/opt/
)
set(CMAKE_REQUIRED_INCLUDES ${LIBYAML_INCLUDE_DIR})
set(CMAKE_REQUIRED_QUIET True)
# detect version (see comment by sanssecours at https://github.com/jbeder/yaml-cpp/issues/604)
#find_package (PkgConfig)
#pkg_check_modules (PC_YAML-CPP QUIET yaml-cpp)
#set (YAML-CPP_VERSION ${PC_YAML-CPP_VERSION})
#if (YAML-CPP_VERSION VERSION_LESS "0.5.0")
# message(FATAL_ERROR "Found YAMLCPP version ${YAML-CPP_VERSION}; needs at least 0.5.0")
#endif()
# now look for needed yaml-cpp0.5 include files
#unset(YAMLCPP_FOUND_05 CACHE)
#check_include_file("yaml-cpp/node/detail/iterator_fwd.h" YAMLCPP_FOUND_05)
#if(${YAMLCPP_FOUND_05})
#else()
# message(FATAL_ERROR "Include file for libyaml-cpp0.5 not found")
#endif()
# attempt to find static library first if this is set
if(LIBYAML_STATIC_LIBRARY)
set(LIBYAML_STATIC libyaml.a)
endif()
# find the libyaml library
find_library(LIBYAML_LIBRARY
NAMES ${LIBYAML_STATIC} yaml
PATH_SUFFIXES lib64 lib
PATHS
${LIBYAML_LIBRARY_LOC}
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
)
message(STATUS
"libyaml: FOUND=${LIBYAML_FOUND}, VERSION=${LIBYAML_VERSION}, LIB=${LIBYAML_LIBRARY}")
# try to compile, link, and run a test program
# --- outcommented because of bug in yamlcpp-0.5 [https://stackoverflow.com/questions/53234192]
# unset(YAMLCPP_RUNS CACHE)
# set(CMAKE_REQUIRED_LIBRARIES yaml-cpp)
# check_cxx_source_runs("#include \"yaml-cpp/yaml.h\"\n#include <assert.h>\nint main() {\n YAML::Node node = YAML::Load(\"[1, 2, 3]\");\n assert(node.IsSequence());\n}" YAMLCPP_RUNS)
# if(${YAMLCPP_RUNS})
# else()
# message(FATAL_ERROR "Test of libyaml-cpp failed")
# endif()
message(STATUS "Found FindLibyaml: ${LIBYAML_LIBRARY}")
mark_as_advanced(LIBYAML_INCLUDE_DIR LIBYAML_LIBRARY)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment