Skip to content

Make this package compatible to yaml-cpp 0.5 #1

@goldhoorn

Description

@goldhoorn

To increase the compatibility to different systems it would be gread that this package support yaml-cpp 0.5 and yaml-cpp 0.3.

To make this possible follow this steps:
Rework this lines:

https://github.com/rock-simulation/configmaps/blob/master/CMakeLists.txt#L9-L14

to somethig like (untested):

pkg_check_modules(YAML REQUIRED
        yaml-cpp
)
include_directories(${YAML_INCLUDE_DIRS})
link_directories(${YAML_LIBRARY_DIRS})
add_definitions(${YAML_CFLAGS_OTHER})  #flags excluding the ones with -I

STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" $YAML_MAJOR_VERSION ${YAML_VERSION}") 
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" $YAML_MINOR_VERSION ${YAML_VERSION}") 
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" $YAML_PATCH_VERSION ${YAML_VERSION}") 
add_definitions("-DYAML_MINOR_VERSION=${YAML_MINOR_VERSION})
add_definitions("-DYAML_MAJOR_VERSION=${YAML_MAJOR_VERSION})
add_definitions("-DYAML_PATCH_VERSION=${YAML_PATCH_VERSION})

add_definitions(${PKGCONFIG_CFLAGS_OTHER})  #flags excluding the ones with -I

In the c++ code you can then identify the version by:

#if YAML_MAJOR_VERSION == 0
  #if YAML_MINOR_VERSION == 3
//Put here the old-code
  #endif
#endif
//Put here the new-code and hope they keep the API backward compatible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions