Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 141)
+++ CMakeLists.txt	(revision 225)
@@ -1,5 +1,101 @@
-project (LEMON)
-enable_testing ()
-add_subdirectory (lemon)
-add_subdirectory (demo)
-add_subdirectory (test)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+#EXECUTE_PROCESS(
+#  COMMAND hg id -i
+#  OUTPUT_VARIABLE HG_REVISION
+#  OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+SET(PROJECT_NAME "Lemon")
+SET(PROJECT_VERSION_MAJOR "0")
+SET(PROJECT_VERSION_MINOR "99")
+SET(PROJECT_VERSION_PATCH "0")
+SET(PROJECT_VERSION
+  "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+
+PROJECT(${PROJECT_NAME})
+
+SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
+
+INCLUDE(FindDoxygen)
+INCLUDE(FindGhostscript)
+
+ENABLE_TESTING()
+
+ADD_SUBDIRECTORY(lemon)
+ADD_SUBDIRECTORY(demo)
+ADD_SUBDIRECTORY(doc)
+ADD_SUBDIRECTORY(test)
+
+IF(WIN32)
+  INSTALL(FILES ${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico
+    DESTINATION bin)
+ENDIF(WIN32)
+
+IF(WIN32)
+  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
+  SET(CPACK_PACKAGE_VENDOR
+    "EGRES - Egervary Research Group on Combinatorial Optimization")
+  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
+    "Lemon - Library of Efficient Models and Optimization in Networks")
+  SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
+
+  SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
+  SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
+  SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
+  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
+
+  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
+    "${PROJECT_NAME} ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
+  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
+    "${PROJECT_NAME} ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+
+  # Variables to generate a component-based installer.
+  #SET(CPACK_COMPONENTS_ALL headers library html_documentation)
+
+  #SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
+  #SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Static library")
+  #SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
+
+  #SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
+  #  "C++ header files for use with the Lemon library")
+  #SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
+  #  "Static library used to build programs with Lemon")
+  #SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
+  #  "Doxygen generated documentation")
+
+  #SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
+
+  #SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
+  #SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
+  #SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
+
+  #SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
+  #  "Components needed to develop software using Lemon")
+  #SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
+  #  "Documentation of Lemon")
+
+  #SET(CPACK_ALL_INSTALL_TYPES Full Developer)
+
+  #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_GENERATOR "NSIS")
+  SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico")
+  SET(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/cmake/nsis/uninstall.ico")
+  #SET(CPACK_PACKAGE_ICON "${CMAKE_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\\\\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(WIN32)
Index: cmake/FindGhostscript.cmake
===================================================================
--- cmake/FindGhostscript.cmake	(revision 225)
+++ cmake/FindGhostscript.cmake	(revision 225)
@@ -0,0 +1,10 @@
+INCLUDE(FindPackageHandleStandardArgs)
+
+FIND_PROGRAM(GHOSTSCRIPT_EXECUTABLE
+  NAMES gs gswin32c
+  PATHS "$ENV{ProgramFiles}/gs"
+  PATH_SUFFIXES gs8.61/bin gs8.62/bin
+  DOC "Ghostscript: PostScript and PDF language interpreter and previewer."
+)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ghostscript DEFAULT_MSG GHOSTSCRIPT_EXECUTABLE)
Index: configure.ac
===================================================================
--- configure.ac	(revision 219)
+++ configure.ac	(revision 226)
@@ -7,5 +7,5 @@
 
 AC_PREREQ([2.59])
-AC_INIT([LEMON], [lemon_version()], [lemon-devel@lemon.cs.elte.hu], [lemon])
+AC_INIT([Lemon], [lemon_version()], [lemon-user@lemon.cs.elte.hu], [lemon])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
@@ -26,4 +26,5 @@
 AC_CHECK_PROG([gs_found],[gs],[yes],[no])
 
+dnl Set custom compiler flags when using g++.
 if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes; then
   CXXFLAGS="$CXXFLAGS -Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas"
@@ -35,5 +36,5 @@
 LX_CHECK_SOPLEX
 
-dnl Disable/enable building the demo programs
+dnl Disable/enable building the demo programs.
 AC_ARG_ENABLE([demo],
 AS_HELP_STRING([--enable-demo], [build the demo programs])
@@ -48,5 +49,5 @@
 AM_CONDITIONAL([WANT_DEMO], [test x"$enable_demo" != x"no"])
 
-dnl Disable/enable building the binary tools
+dnl Disable/enable building the binary tools.
 AC_ARG_ENABLE([tools],
 AS_HELP_STRING([--enable-tools], [build additional tools @<:@default@:>@])
@@ -61,5 +62,5 @@
 AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"])
 
-dnl Disable/enable building the benchmarks
+dnl Disable/enable building the benchmarks.
 AC_ARG_ENABLE([benchmark],
 AS_HELP_STRING([--enable-benchmark], [build the benchmarks])
Index: demo/CMakeLists.txt
===================================================================
--- demo/CMakeLists.txt	(revision 141)
+++ demo/CMakeLists.txt	(revision 225)
@@ -1,13 +1,13 @@
-include_directories (${LEMON_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 
-link_directories (${LEMON_BINARY_DIR}/lemon)
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
 
-set (DEMOS
+SET(DEMOS
   arg_parser_demo
   graph_to_eps_demo
   lgf_demo)
 
-foreach (DEMO_NAME ${DEMOS})
-  add_executable (${DEMO_NAME} ${DEMO_NAME}.cc)
-  target_link_libraries (${DEMO_NAME} lemon)
-  endforeach (DEMO_NAME)
+FOREACH(DEMO_NAME ${DEMOS})
+  ADD_EXECUTABLE(${DEMO_NAME} ${DEMO_NAME}.cc)
+  TARGET_LINK_LIBRARIES(${DEMO_NAME} lemon)
+ENDFOREACH(DEMO_NAME)
Index: doc/CMakeLists.txt
===================================================================
--- doc/CMakeLists.txt	(revision 225)
+++ doc/CMakeLists.txt	(revision 225)
@@ -0,0 +1,42 @@
+SET(PACKAGE_NAME ${PROJECT_NAME})
+SET(PACKAGE_VERSION ${PROJECT_VERSION})
+SET(abs_top_srcdir ${CMAKE_SOURCE_DIR})
+SET(abs_top_builddir ${CMAKE_BINARY_DIR})
+
+CONFIGURE_FILE(
+  ${CMAKE_SOURCE_DIR}/doc/Doxyfile.in
+  ${CMAKE_BINARY_DIR}/doc/Doxyfile
+  @ONLY)
+
+IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
+  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/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 rm -rf html
+      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+  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/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 if exist html rmdir /s /q html
+      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+  ENDIF(UNIX)
+ENDIF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
+
+INSTALL(
+  DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
+  DESTINATION doc
+  COMPONENT html_documentation)
Index: doc/Doxyfile.in
===================================================================
--- doc/Doxyfile.in	(revision 219)
+++ doc/Doxyfile.in	(revision 226)
@@ -16,6 +16,6 @@
 INLINE_INHERITED_MEMB  = NO
 FULL_PATH_NAMES        = YES
-STRIP_FROM_PATH        = @abs_top_srcdir@
-STRIP_FROM_INC_PATH    = @abs_top_srcdir@
+STRIP_FROM_PATH        = "@abs_top_srcdir@"
+STRIP_FROM_INC_PATH    = "@abs_top_srcdir@"
 SHORT_NAMES            = YES
 JAVADOC_AUTOBRIEF      = NO
@@ -81,11 +81,11 @@
 # configuration options related to the input files
 #---------------------------------------------------------------------------
-INPUT                  = @abs_top_srcdir@/doc \
-                         @abs_top_srcdir@/lemon \
-                         @abs_top_srcdir@/lemon/bits \
-                         @abs_top_srcdir@/lemon/concepts \
-                         @abs_top_srcdir@/demo \
-                         @abs_top_srcdir@/tools \
-                         @abs_top_srcdir@/test/test_tools.h
+INPUT                  = "@abs_top_srcdir@/doc" \
+                         "@abs_top_srcdir@/lemon" \
+                         "@abs_top_srcdir@/lemon/bits" \
+                         "@abs_top_srcdir@/lemon/concepts" \
+                         "@abs_top_srcdir@/demo" \
+                         "@abs_top_srcdir@/tools" \
+                         "@abs_top_srcdir@/test/test_tools.h"
 INPUT_ENCODING         = UTF-8
 FILE_PATTERNS          = *.h \
@@ -97,11 +97,11 @@
 EXCLUDE_PATTERNS       = 
 EXCLUDE_SYMBOLS        = 
-EXAMPLE_PATH           = @abs_top_srcdir@/demo \
-                         @abs_top_srcdir@/LICENSE \
-                         @abs_top_srcdir@/doc
+EXAMPLE_PATH           = "@abs_top_srcdir@/demo" \
+                         "@abs_top_srcdir@/LICENSE" \
+                         "@abs_top_srcdir@/doc"
 EXAMPLE_PATTERNS       = 
 EXAMPLE_RECURSIVE      = NO
-IMAGE_PATH             = @abs_top_srcdir@/doc/images \
-                         @abs_top_builddir@/doc/gen-images
+IMAGE_PATH             = "@abs_top_srcdir@/doc/images" \
+                         "@abs_top_builddir@/doc/gen-images"
 INPUT_FILTER           = 
 FILTER_PATTERNS        = 
Index: lemon/CMakeLists.txt
===================================================================
--- lemon/CMakeLists.txt	(revision 141)
+++ lemon/CMakeLists.txt	(revision 225)
@@ -1,2 +1,18 @@
-include_directories (${LEMON_SOURCE_DIR})
-add_library (lemon arg_parser.cc base.cc color.cc random.cc)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+
+ADD_LIBRARY(lemon
+  arg_parser.cc
+  base.cc
+  color.cc
+  random.cc)
+
+INSTALL(
+  TARGETS lemon
+  ARCHIVE DESTINATION lib
+  COMPONENT library)
+
+INSTALL(
+  DIRECTORY . bits concepts
+  DESTINATION include/lemon
+  COMPONENT headers
+  FILES_MATCHING PATTERN "*.h")
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt	(revision 203)
+++ test/CMakeLists.txt	(revision 225)
@@ -1,7 +1,7 @@
-include_directories (${LEMON_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 
-link_directories (${LEMON_BINARY_DIR}/lemon)
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
 
-set (TESTS
+SET(TESTS
   bfs_test
   counter_test
@@ -17,12 +17,12 @@
   kruskal_test
   maps_test
+  random_test
   path_test
-  random_test
   time_measure_test
   unionfind_test)
 
-foreach (TEST_NAME ${TESTS})
-  add_executable (${TEST_NAME} ${TEST_NAME}.cc)
-  target_link_libraries (${TEST_NAME} lemon)
-  add_test(${TEST_NAME} ${TEST_NAME})
-endforeach (TEST_NAME)
+FOREACH(TEST_NAME ${TESTS})
+  ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
+  TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
+  ADD_TEST(${TEST_NAME} ${TEST_NAME})
+ENDFOREACH(TEST_NAME)
Index: test/error_test.cc
===================================================================
--- test/error_test.cc	(revision 209)
+++ test/error_test.cc	(revision 223)
@@ -30,4 +30,8 @@
 #ifdef LEMON_DISABLE_ASSERTS
 #undef LEMON_DISABLE_ASSERTS
+#endif
+
+#ifdef NDEBUG
+#undef NDEBUG
 #endif
 
