Skip to content
Snippets Groups Projects
Commit 7670613a authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

FindYamlCpp05, asserts include file version, compiles and runs test.

parent 3719c6a2
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ frida ...@@ -22,6 +22,7 @@ frida
external_ci external_ci
gcc gcc
clang clang
build
qtbuild qtbuild
podstyle.css podstyle.css
pub/src/xax_yacc.hpp pub/src/xax_yacc.hpp
......
...@@ -41,7 +41,7 @@ find_package(BISON) ...@@ -41,7 +41,7 @@ find_package(BISON)
find_package(FLEX) find_package(FLEX)
include(FindGSL) include(FindGSL)
include(FindFFTW) include(FindFFTW)
include(FindYamlCpp) include(FindYamlCpp05)
include(FindFridalibs) include(FindFridalibs)
include(FindReadline) include(FindReadline)
......
#.rst:
# CheckCppIncludeFile
# -------------------
#
# macro which checks the C++ include file exists.
#
# CHECK_INCLUDE_FILE(INCLUDE VARIABLE)
#
# ::
#
# INCLUDE - name of include file
# VARIABLE - variable to return result
# Will be created as an internal cache variable.
#
#
#
# an optional third argument is the CFlags to add to the compile line or
# you can use CMAKE_REQUIRED_FLAGS
#
# The following variables may be set before calling this macro to modify
# the way the check is run:
#
# ::
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
#
# Copyright 2015 Joachim Wuttke, based on cmake 3.2 CheckIncludeFile.cmake
#
# Copyright 2002-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
if(DEFINED "${VARIABLE}")
message(WARNING "using ${VARIABLE} as cached: ${${VARIABLE}}")
return()
endif()
if(CMAKE_REQUIRED_INCLUDES)
set(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
else()
set(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS)
endif()
set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/CheckCppIncludeFile.cpp.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckCppIncludeFile.cpp)
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for ${INCLUDE}")
endif()
if(${ARGC} EQUAL 3)
set(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGV2}")
endif()
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckCppIncludeFile.cpp
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
"${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}"
OUTPUT_VARIABLE OUTPUT)
if(${ARGC} EQUAL 3)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_SAVE})
endif()
if(${VARIABLE})
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for ${INCLUDE} - found")
endif()
set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the include file ${INCLUDE} "
"exists passed with the following output:\n"
"${OUTPUT}\n\n")
else()
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for ${INCLUDE} - not found")
endif()
set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the include file ${INCLUDE} "
"exists failed with the following output:\n"
"${OUTPUT}\n\n")
endif()
endmacro()
#include <${CHECK_INCLUDE_FILE_VAR}>
#ifdef __CLASSIC_C__
int main()
{
return 0;
}
#else
int main(void)
{
return 0;
}
#endif
message( "FindYamlCpp.cmake begin" ) message( "FindYamlCpp05.cmake begin" )
# Locate yaml-cpp # Locate yaml-cpp with API version 0.5
#
# from http://code.google.com/p/yaml-cpp/issues/attachmentText?id=127&aid=1270002000&name=FindYamlCpp.cmake&token=59a4fbf54107b93367255c9d36464e81
# also at https://github.com/supercollider/supercollider/blob/master/cmake_modules/FindYamlCpp.cmake
# #
# This module defines # This module defines
# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp # YAMLCPP_FOUND, if false, do not try to link to yaml-cpp
...@@ -16,53 +13,74 @@ message( "FindYamlCpp.cmake begin" ) ...@@ -16,53 +13,74 @@ message( "FindYamlCpp.cmake begin" )
# If yaml-cpp is not installed in a standard path, you can use the YAMLCPP_DIR CMake variable # If yaml-cpp is not installed in a standard path, you can use the YAMLCPP_DIR CMake variable
# to tell CMake where yaml-cpp is. # to tell CMake where yaml-cpp is.
# attempt to find static library first if this is set include (CheckCppIncludeFile)
if(YAMLCPP_STATIC_LIBRARY) include (CheckCXXSourceRuns)
set(YAMLCPP_STATIC libyaml-cpp.a)
endif()
# find the yaml-cpp include directory # find the yaml-cpp include directory
find_path(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h find_path(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h
PATH_SUFFIXES include PATH_SUFFIXES include
PATHS PATHS
~/Library/Frameworks/yaml-cpp/include/ ~/Library/Frameworks/yaml-cpp/include/
/Library/Frameworks/yaml-cpp/include/ /Library/Frameworks/yaml-cpp/include/
/usr/local/include/yaml-cpp/ /usr/local/include/yaml-cpp/
/usr/local/include/ /usr/local/include/
/usr/include/yaml-cpp/ /usr/include/yaml-cpp/
/usr/include/ /usr/include/
/sw/yaml-cpp/ # Fink /sw/yaml-cpp/ # Fink
/opt/local/yaml-cpp/ # DarwinPorts /opt/local/yaml-cpp/ # DarwinPorts
/opt/csw/yaml-cpp/ # Blastwave /opt/csw/yaml-cpp/ # Blastwave
/opt/yaml-cpp/ /opt/yaml-cpp/
${YAMLCPP_DIR}/include/) ${YAMLCPP_DIR}/include/)
set(CMAKE_REQUIRED_INCLUDES ${YAMLCPP_INCLUDE_DIR})
set(CMAKE_REQUIRED_QUIET True)
# first look for outdated yaml-cpp0.3 include files
unset(YAMLCPP_FOUND_03 CACHE)
check_include_file("yaml-cpp/aliasmanager.h" YAMLCPP_FOUND_03)
if(${YAMLCPP_FOUND_03})
message(WARNING "Found include file for libyaml-cpp0.3. Most probably this precludes libyaml-cpp0.5 from being properly installed")
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(YAMLCPP_STATIC_LIBRARY)
set(YAMLCPP_STATIC libyaml-cpp.a)
endif()
# find the yaml-cpp library # find the yaml-cpp library
find_library(YAMLCPP_LIBRARY find_library(YAMLCPP_LIBRARY
NAMES ${YAMLCPP_STATIC} yaml-cpp NAMES ${YAMLCPP_STATIC} yaml-cpp
PATH_SUFFIXES lib64 lib PATH_SUFFIXES lib64 lib
PATHS ~/Library/Frameworks PATHS ~/Library/Frameworks
/Library/Frameworks /Library/Frameworks
/usr/local /usr/local
/usr /usr
/sw /sw
/opt/local /opt/local
/opt/csw /opt/csw
/opt /opt
${YAMLCPP_DIR}/lib) ${YAMLCPP_DIR}/lib)
# try to compile, link, and run a test program
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-cpp0.5 failed")
endif()
# handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE # handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) find_package_handle_standard_args(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
if( YAMLCPP_FOUND ) message( "FindYamlCpp05.cmake end" )
# if( NOT YAMLCPP_FIND_QUIETLY )
message( STATUS "FindYAMLCPP: Found both YAMLCPP headers and library" )
# endif( NOT YAMLCPP_FIND_QUIETLY )
else( YAMLCPP_FOUND )
# if( YAMLCPP_FIND_REQUIRED )
message( FATAL_ERROR "FindYAMLCPP: Could not find YAMLCPP headers or library" )
# endif( YAMLCPP_FIND_REQUIRED )
endif( YAMLCPP_FOUND )
message( "FindYamlCpp.cmake end" )
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