build FEATURE pkg-config package info file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4303f8c..08a063b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,12 +4,21 @@
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
 
 project(libnetconf2 C)
+set(LIBNETCONF2_DESCRIPTION "NETCONF server and client library in C.")
 
 # check the supported platform
 if(NOT UNIX)
     message(FATAL_ERROR "Only *nix like systems are supported.")
 endif()
 
+if(NOT LIB_INSTALL_DIR)
+    set(LIB_INSTALL_DIR lib)
+endif()
+
+if(NOT INCLUDE_INSTALL_DIR)
+    set(INCLUDE_INSTALL_DIR include)
+endif()
+
 # set default build type if not specified by user
 if(NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE debug)
@@ -157,6 +166,22 @@
     CODE "file(INSTALL \${yin_schemas} DESTINATION ${DATA_INSTALL_DIR})"
 )
 
+# install pkg-config file
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+    configure_file("libnetconf2.pc.in" "libnetconf2.pc" @ONLY)
+    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnetconf2.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
+    # check that pkg-config includes the used path
+    execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable pc_path pkg-config RESULT_VARIABLE RETURN OUTPUT_VARIABLE PC_PATH ERROR_QUIET)
+    if(RETURN EQUAL 0)
+        string(REGEX MATCH "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" SUBSTR "${PC_PATH}")
+        string(LENGTH "${SUBSTR}" SUBSTR_LEN)
+        if(SUBSTR_LEN EQUAL 0)
+            message(WARNING "pkg-config will not detect the new package after installation, adjust PKG_CONFIG_PATH using \"export PKG_CONFIG_PATH=\${PKG_CONFIG_PATH}:${CMAKE_INSTALL_PREFIX}/lib/pkgconfig\".")
+        endif()
+    endif()
+endif()
+
 if(ENABLE_VALGRIND_TESTS)
     set(ENABLE_BUILD_TESTS ON)
 endif()