* CMakeLists.txt: Generate the pkg-config module file.


git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1834404 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2452350..56bdd6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -186,10 +186,14 @@
 # Process other build options
 if(PREFIX)
   set(CMAKE_INSTALL_PREFIX ${PREFIX})
+else()
+  set(PREFIX ${CMAKE_INSTALL_PREFIX})
 endif()
 
 if(LIBDIR)
   message(WARNING "option LIBDIR is not implemented yet")
+else()
+  set(LIBDIR "${PREFIX}/lib")
 endif()
 
 if(DEBUG)
@@ -238,6 +242,17 @@
   endif()
 endif()
 
+if(NOT WINDOWS)
+  # Use a separate variable scope for the substitutions in serf.pc.in.
+  function(make_pkgconfig)
+    set(VERSION ${SERF_VERSION})
+    set(MAJOR ${SERF_MAJOR_VERSION})
+    set(INCLUDE_SUBDIR "serf-${SERF_MAJOR_VERSION}")
+    set(LIBS ${DEPENDENCY_LIBRARIES})
+    configure_file("build/serf.pc.in" "serf.pc" @ONLY)
+  endfunction()
+  make_pkgconfig()
+endif()
 
 add_library(serf SHARED ${SOURCES} ${SHARED_SOURCES})
 target_link_libraries(serf ${DEPENDENCY_LIBRARIES})