Finding correct cmake configuration for yaml-cpp library

前端 未结 1 1238
南笙
南笙 2021-01-24 09:52

I was trying to use yaml-cpp in my project. It took me half an hour to correctly link the library by experimenting with the following names. After I finally stumbled across them

相关标签:
1条回答
  • 2021-01-24 10:16

    Most of FindXXX.cmake scripts have usage description at the top of them (as CMake comments started #). The same is true about XXXConfig.cmake (or xxx-config.cmake) scripts.

    Command find_package(XXX) uses one of such scripts (the one which actually exists). So, before using this approach for discover the package, make sure that you have read the description "embedded" into such script.

    In your case, yaml-cpp-config.cmake file (created in the build or in the install directory) contains following description:

    # - Config file for the yaml-cpp package
    # It defines the following variables
    #  YAML_CPP_INCLUDE_DIR - include directory
    #  YAML_CPP_LIBRARIES    - libraries to link against
    

    so proper usage of results of find_package(yaml-cpp) is

    include_directories(${YAML_CPP_INCLUDE_DIRS})
    target_link_libraries(<your-target> ${YAML_CPP_LIBRARIES})
    
    0 讨论(0)
提交回复
热议问题