Locating libconfig from CMake-based projects
Configuration files for CMake are provided to simplify
locating libconfig from within project that use CMake
as their build system.
Separate configuration files are provided for C and C++
builds.
In a CMakeLists.txt file, use the following commands to
locate libconfig:
- To locate the library, use either
find_package(libconfig)
or
find_package(libconfig++)
- The include directories are available as variables
LIBCONFIG_INCLUDE_DIRS
and
LIBCONFIG++_INCLUDE_DIRS
respectively, and can be used like this:
include_directories(${LIBCONFIG++_INCLUDE_DIRS})
- Link to libconfig using variables
LIBCONFIG_LIBRARIES
and
LIBCONFIG++_LIBRARIES
respectively, by writing:
target_link_libraries(${PROJECT_NAME}
${LIBCONFIG++_LIBRARIES}
)