2

I'm trying to use the cmake's function:

CHECK_LIBRARY_EXISTS(library function location variable) 

How can I check if the C++ library are available ?

CHECK_LIBRARY_EXISTS(yaml-cpp "YAML::Token" ${YAML-CPP_PATHS} HAVE_YAML-CPP)
IF(HAVE_YAML-CPP)
    MESSAGE(STATUS "YAML-CPP libraries founded: OK")
ENDIF(HAVE_YAML-CPP)

IF(NOT HAVE_YAML-CPP)
    MESSAGE(FATAL_ERROR "ERROR: unable to link YAML::Token")
ENDIF(NOT HAVE_YAML-CPP)

That code snip don't work.

1 Answer 1

5

The CheckLibraryExists module only works for C symbols, not C++. Personally I would just use find_library and find_path to find the library and include path. If the library doesn't contain the right symbols, the user is going to notice soon enough during the linking...

Since yaml-cpp installs a pkg-config file, you can also use the FindPkgConfig module. However, since yaml-cpp itself is built using CMake, you should encourage them to actually install a yaml-cpp-config.cmake file. See e.g. this tutorial for more information.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.