Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 718)
+++ CMakeLists.txt	(revision 727)
@@ -1,17 +1,31 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
-IF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake)
-  INCLUDE(${CMAKE_SOURCE_DIR}/cmake/version.cmake)
-ELSE(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake)
-  SET(PROJECT_NAME "LEMON")
-  SET(PROJECT_VERSION "hg-tip" CACHE STRING "LEMON version string.")
-ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake)
+SET(PROJECT_NAME "LEMON")
+PROJECT(${PROJECT_NAME})
 
-PROJECT(${PROJECT_NAME})
+IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
+  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
+ELSEIF(DEFINED ENV{LEMON_VERSION})
+  SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
+ELSE()
+  EXECUTE_PROCESS(
+    COMMAND hg id -i
+    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+    OUTPUT_VARIABLE HG_REVISION
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+  IF(HG_REVISION STREQUAL "")
+    SET(HG_REVISION "hg-tip")
+  ENDIF()
+  SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
+ENDIF()
+
+SET(PROJECT_VERSION ${LEMON_VERSION})
 
 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
 
-INCLUDE(FindDoxygen)
-INCLUDE(FindGhostscript)
+FIND_PACKAGE(Doxygen)
+FIND_PACKAGE(Ghostscript)
 FIND_PACKAGE(GLPK 4.33)
 FIND_PACKAGE(CPLEX)
@@ -19,5 +33,6 @@
 
 INCLUDE(CheckTypeSize)
-CHECK_TYPE_SIZE("long long" LEMON_LONG_LONG)
+CHECK_TYPE_SIZE("long long" LONG_LONG)
+SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
 
 ENABLE_TESTING()
@@ -29,72 +44,87 @@
   ADD_SUBDIRECTORY(doc)
   ADD_SUBDIRECTORY(test)
-ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
+ENDIF()
 
-IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
-  IF(WIN32)
-    SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
-    SET(CPACK_PACKAGE_VENDOR "EGRES")
-    SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
-      "LEMON - Library for Efficient Modeling and Optimization in Networks")
-    SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
+CONFIGURE_FILE(
+  ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
+  ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
+  @ONLY
+)
+IF(UNIX)
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
+    DESTINATION share/lemon/cmake
+  )
+ELSEIF(WIN32)
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
+    DESTINATION cmake
+  )
+ENDIF()
 
-    SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
+IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} AND WIN32)
+  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
+  SET(CPACK_PACKAGE_VENDOR "EGRES")
+  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
+    "LEMON - Library for Efficient Modeling and Optimization in Networks")
+  SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
 
-    SET(CPACK_PACKAGE_INSTALL_DIRECTORY
-      "${PROJECT_NAME} ${PROJECT_VERSION}")
-    SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
-      "${PROJECT_NAME} ${PROJECT_VERSION}")
+  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
 
-    SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
+  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
+    "${PROJECT_NAME} ${PROJECT_VERSION}")
+  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
+    "${PROJECT_NAME} ${PROJECT_VERSION}")
 
-    SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
-    SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
-    SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
-    SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
+  SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
 
-    SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
-      "C++ header files")
-    SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
-      "DLL and import library")
-    SET(CPACK_COMPONENT_BIN_DESCRIPTION
-      "Command line utilities")
-    SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
-      "Doxygen generated documentation")
+  SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
+  SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
+  SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
+  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
 
-    SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
+  SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
+    "C++ header files")
+  SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
+    "DLL and import library")
+  SET(CPACK_COMPONENT_BIN_DESCRIPTION
+    "Command line utilities")
+  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
+    "Doxygen generated documentation")
 
-    SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
-    SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
-    SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
+  SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
 
-    SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
-      "Components needed to develop software using LEMON")
-    SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
-      "Documentation of LEMON")
+  SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
+  SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
+  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
 
-    SET(CPACK_ALL_INSTALL_TYPES Full Developer)
+  SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
+    "Components needed to develop software using LEMON")
+  SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
+    "Documentation of LEMON")
 
-    SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
-    SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
-    SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
+  SET(CPACK_ALL_INSTALL_TYPES Full Developer)
 
-    SET(CPACK_GENERATOR "NSIS")
-    SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
-    SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
-    #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
-    SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
-    SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
-    SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
-    SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
-    SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
-    SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
-      CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
-      ")
-    SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
-      !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
-      Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
-      ")
+  SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
+  SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
+  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
 
-    INCLUDE(CPack)
-  ENDIF(WIN32)
-ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
+  SET(CPACK_GENERATOR "NSIS")
+  SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
+  SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
+  #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
+  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
+  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
+  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
+  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
+  SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
+  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
+    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
+    ")
+  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
+    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
+    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
+    ")
+
+  INCLUDE(CPack)
+ENDIF()
Index: cmake/LEMONConfig.cmake.in
===================================================================
--- cmake/LEMONConfig.cmake.in	(revision 722)
+++ cmake/LEMONConfig.cmake.in	(revision 722)
@@ -0,0 +1,13 @@
+SET(LEMON_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include" CACHE PATH "LEMON include directory")
+SET(LEMON_INCLUDE_DIRS "${LEMON_INCLUDE_DIR}")
+
+IF(UNIX)
+  SET(LEMON_LIB_NAME "libemon.a")
+ELSEIF(WIN32)
+  SET(LEMON_LIB_NAME "lemon.lib")
+ENDIF(UNIX)
+
+SET(LEMON_LIBRARY "@CMAKE_INSTALL_PREFIX@/lib/${LEMON_LIB_NAME}" CACHE FILEPATH "LEMON library")
+SET(LEMON_LIBRARIES "${LEMON_LIBRARY}")
+
+MARK_AS_ADVANCED(LEMON_LIBRARY LEMON_INCLUDE_DIR)
Index: cmake/version.cmake.in
===================================================================
--- cmake/version.cmake.in	(revision 503)
+++ cmake/version.cmake.in	(revision 725)
@@ -1,2 +1,1 @@
-SET(PROJECT_NAME "@PACKAGE_NAME@")
-SET(PROJECT_VERSION "@PACKAGE_VERSION@" CACHE STRING "LEMON version string.")
+SET(LEMON_VERSION "@PACKAGE_VERSION@" CACHE STRING "LEMON version string.")
Index: configure.ac
===================================================================
--- configure.ac	(revision 674)
+++ configure.ac	(revision 727)
@@ -3,12 +3,15 @@
 dnl Version information.
 m4_define([lemon_version_number],
-	[m4_normalize(esyscmd([echo ${LEMON_VERSION}]))])
+          [m4_normalize(esyscmd([echo ${LEMON_VERSION}]))])
 dnl m4_define([lemon_version_number], [])
 m4_define([lemon_hg_path], [m4_normalize(esyscmd([./scripts/chg-len.py]))])
-m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i]))])
+m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i 2> /dev/null]))])
 m4_define([lemon_version], [ifelse(lemon_version_number(),
-			   [],
-			   [lemon_hg_path().lemon_hg_revision()],
-			   [lemon_version_number()])])
+                           [],
+                           [ifelse(lemon_hg_revision(),
+                           [],
+                           [hg-tip],
+                           [lemon_hg_path().lemon_hg_revision()])],
+                           [lemon_version_number()])])
 
 AC_PREREQ([2.59])
@@ -19,4 +22,6 @@
 AC_CONFIG_SRCDIR([lemon/list_graph.h])
 AC_CONFIG_HEADERS([config.h lemon/config.h])
+
+AC_DEFINE([LEMON_VERSION], [lemon_version()], [The version string])
 
 dnl Do compilation tests using the C++ compiler.
Index: demo/CMakeLists.txt
===================================================================
--- demo/CMakeLists.txt	(revision 674)
+++ demo/CMakeLists.txt	(revision 726)
@@ -4,13 +4,16 @@
 )
 
-LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon)
+LINK_DIRECTORIES(
+  ${PROJECT_BINARY_DIR}/lemon
+)
 
 SET(DEMOS
   arg_parser_demo
   graph_to_eps_demo
-  lgf_demo)
+  lgf_demo
+)
 
 FOREACH(DEMO_NAME ${DEMOS})
   ADD_EXECUTABLE(${DEMO_NAME} ${DEMO_NAME}.cc)
   TARGET_LINK_LIBRARIES(${DEMO_NAME} lemon)
-ENDFOREACH(DEMO_NAME)
+ENDFOREACH()
Index: doc/CMakeLists.txt
===================================================================
--- doc/CMakeLists.txt	(revision 633)
+++ doc/CMakeLists.txt	(revision 726)
@@ -7,50 +7,45 @@
   ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
   ${PROJECT_BINARY_DIR}/doc/Doxyfile
-  @ONLY)
+  @ONLY
+)
 
 IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
   FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/)
+  SET(GHOSTSCRIPT_OPTIONS -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha)
+  ADD_CUSTOM_TARGET(html
+    COMMAND ${CMAKE_COMMAND} -E remove_directory gen-images
+    COMMAND ${CMAKE_COMMAND} -E make_directory gen-images
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/bipartite_matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_matching.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/bipartite_partitions.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_partitions.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
+    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
+    COMMAND ${CMAKE_COMMAND} -E remove_directory html
+    COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+  )
+
+  SET_TARGET_PROPERTIES(html PROPERTIES PROJECT_LABEL BUILD_DOC)
+
   IF(UNIX)
-    ADD_CUSTOM_TARGET(html
-      COMMAND rm -rf gen-images
-      COMMAND mkdir gen-images
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/bipartite_matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_matching.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/bipartite_partitions.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_partitions.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
-      COMMAND rm -rf html
-      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
-      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+    INSTALL(
+      DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
+      DESTINATION share/doc/lemon/html
+      COMPONENT html_documentation
+    )
   ELSEIF(WIN32)
-    ADD_CUSTOM_TARGET(html
-      COMMAND if exist gen-images rmdir /s /q gen-images
-      COMMAND mkdir gen-images
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/bipartite_matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_matching.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/bipartite_partitions.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_partitions.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
-      COMMAND if exist html rmdir /s /q html
-      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
-      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-  ENDIF(UNIX)
-  INSTALL(
-    DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
-    DESTINATION share/doc
-    COMPONENT html_documentation)
-ENDIF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
+    INSTALL(
+      DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
+      DESTINATION doc
+      COMPONENT html_documentation
+    )
+  ENDIF()
+
+ENDIF()
Index: doc/Makefile.am
===================================================================
--- doc/Makefile.am	(revision 710)
+++ doc/Makefile.am	(revision 720)
@@ -92,9 +92,9 @@
 install-html-local: doc/html
 	@$(NORMAL_INSTALL)
-	$(mkinstalldirs) $(DESTDIR)$(htmldir)/docs
+	$(mkinstalldirs) $(DESTDIR)$(htmldir)/html
 	for p in doc/html/*.{html,css,png,map,gif,tag} ; do \
 	  f="`echo $$p | sed -e 's|^.*/||'`"; \
-	  echo " $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/docs/$$f"; \
-	  $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/docs/$$f; \
+	  echo " $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/html/$$f"; \
+	  $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/html/$$f; \
 	done
 
@@ -103,6 +103,6 @@
 	for p in doc/html/*.{html,css,png,map,gif,tag} ; do \
 	  f="`echo $$p | sed -e 's|^.*/||'`"; \
-	  echo " rm -f $(DESTDIR)$(htmldir)/docs/$$f"; \
-	  rm -f $(DESTDIR)$(htmldir)/docs/$$f; \
+	  echo " rm -f $(DESTDIR)$(htmldir)/html/$$f"; \
+	  rm -f $(DESTDIR)$(htmldir)/html/$$f; \
 	done
 
Index: lemon/CMakeLists.txt
===================================================================
--- lemon/CMakeLists.txt	(revision 674)
+++ lemon/CMakeLists.txt	(revision 726)
@@ -26,28 +26,32 @@
     INSTALL(FILES ${GLPK_BIN_DIR}/libltdl3.dll DESTINATION bin)
     INSTALL(FILES ${GLPK_BIN_DIR}/zlib1.dll DESTINATION bin)
-  ENDIF(WIN32)
-ENDIF(LEMON_HAVE_GLPK)
+  ENDIF()
+ENDIF()
 
 IF(LEMON_HAVE_CPLEX)
   SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc)
   INCLUDE_DIRECTORIES(${CPLEX_INCLUDE_DIRS})
-ENDIF(LEMON_HAVE_CPLEX)
+ENDIF()
 
 IF(LEMON_HAVE_CLP)
   SET(LEMON_SOURCES ${LEMON_SOURCES} clp.cc)
   INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS})
-ENDIF(LEMON_HAVE_CLP)
+ENDIF()
 
 IF(LEMON_HAVE_CBC)
   SET(LEMON_SOURCES ${LEMON_SOURCES} cbc.cc)
   INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS})
-ENDIF(LEMON_HAVE_CBC)
+ENDIF()
 
 ADD_LIBRARY(lemon ${LEMON_SOURCES})
+IF(UNIX)
+  SET_TARGET_PROPERTIES(lemon PROPERTIES OUTPUT_NAME emon)
+ENDIF()
 
 INSTALL(
   TARGETS lemon
   ARCHIVE DESTINATION lib
-  COMPONENT library)
+  COMPONENT library
+)
 
 INSTALL(
@@ -55,8 +59,10 @@
   DESTINATION include/lemon
   COMPONENT headers
-  FILES_MATCHING PATTERN "*.h")
+  FILES_MATCHING PATTERN "*.h"
+)
 
 INSTALL(
   FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
   DESTINATION include/lemon
-  COMPONENT headers)
+  COMPONENT headers
+)
Index: lemon/config.h.cmake
===================================================================
--- lemon/config.h.cmake	(revision 674)
+++ lemon/config.h.cmake	(revision 725)
@@ -1,2 +1,3 @@
+#define LEMON_VERSION "@PROJECT_VERSION@"
 #cmakedefine LEMON_HAVE_LONG_LONG 1
 #cmakedefine LEMON_HAVE_LP 1
Index: lemon/config.h.in
===================================================================
--- lemon/config.h.in	(revision 674)
+++ lemon/config.h.in	(revision 725)
@@ -1,2 +1,5 @@
+/* The version string */
+#undef LEMON_VERSION
+
 /* Define to 1 if you have long long */
 #undef LEMON_HAVE_LONG_LONG
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt	(revision 696)
+++ test/CMakeLists.txt	(revision 726)
@@ -4,5 +4,7 @@
 )
 
-LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon)
+LINK_DIRECTORIES(
+  ${PROJECT_BINARY_DIR}/lemon
+)
 
 SET(TESTS
@@ -36,18 +38,21 @@
   suurballe_test
   time_measure_test
-  unionfind_test)
+  unionfind_test
+)
 
 IF(LEMON_HAVE_LP)
   ADD_EXECUTABLE(lp_test lp_test.cc)
   SET(LP_TEST_LIBS lemon)
+
   IF(LEMON_HAVE_GLPK)
     SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES})
-  ENDIF(LEMON_HAVE_GLPK)
+  ENDIF()
   IF(LEMON_HAVE_CPLEX)
     SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES})
-  ENDIF(LEMON_HAVE_CPLEX)
+  ENDIF()
   IF(LEMON_HAVE_CLP)
     SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES})
-  ENDIF(LEMON_HAVE_CLP)
+  ENDIF()
+
   TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS})
   ADD_TEST(lp_test lp_test)
@@ -57,30 +62,33 @@
     GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
-      COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
-      COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
-      COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
+      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
+      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
+      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
     )
-  ENDIF(WIN32 AND LEMON_HAVE_GLPK)
+  ENDIF()
+
   IF(WIN32 AND LEMON_HAVE_CPLEX)
     GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
     GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
-      COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
+      COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
     )
-  ENDIF(WIN32 AND LEMON_HAVE_CPLEX)
-ENDIF(LEMON_HAVE_LP)
+  ENDIF()
+ENDIF()
 
 IF(LEMON_HAVE_MIP)
   ADD_EXECUTABLE(mip_test mip_test.cc)
   SET(MIP_TEST_LIBS lemon)
+
   IF(LEMON_HAVE_GLPK)
     SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES})
-  ENDIF(LEMON_HAVE_GLPK)
+  ENDIF()
   IF(LEMON_HAVE_CPLEX)
     SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES})
-  ENDIF(LEMON_HAVE_CPLEX)
+  ENDIF()
   IF(LEMON_HAVE_CBC)
     SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES})
-  ENDIF(LEMON_HAVE_CBC)
+  ENDIF()
+
   TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS})
   ADD_TEST(mip_test mip_test)
@@ -90,17 +98,18 @@
     GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
-      COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
-      COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
-      COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
+      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
+      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
+      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
     )
-  ENDIF(WIN32 AND LEMON_HAVE_GLPK)
+  ENDIF()
+
   IF(WIN32 AND LEMON_HAVE_CPLEX)
     GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
     GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
-      COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
+      COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
     )
-  ENDIF(WIN32 AND LEMON_HAVE_CPLEX)
-ENDIF(LEMON_HAVE_MIP)
+  ENDIF()
+ENDIF()
 
 FOREACH(TEST_NAME ${TESTS})
@@ -108,3 +117,3 @@
   TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
   ADD_TEST(${TEST_NAME} ${TEST_NAME})
-ENDFOREACH(TEST_NAME)
+ENDFOREACH()
Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt	(revision 596)
+++ tools/CMakeLists.txt	(revision 726)
@@ -4,5 +4,7 @@
 )
 
-LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon)
+LINK_DIRECTORIES(
+  ${PROJECT_BINARY_DIR}/lemon
+)
 
 ADD_EXECUTABLE(lgf-gen lgf-gen.cc)
@@ -25,4 +27,5 @@
     PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/lemon-0.x-to-1.x.sh
     DESTINATION bin
-    COMPONENT bin)
-ENDIF(NOT WIN32)
+    COMPONENT bin
+  )
+ENDIF()
Index: tools/Makefile.am
===================================================================
--- tools/Makefile.am	(revision 573)
+++ tools/Makefile.am	(revision 721)
@@ -1,2 +1,5 @@
+EXTRA_DIST += \
+	tools/CMakeLists.txt
+
 if WANT_TOOLS
 
