# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1404727065 -7200
# Node ID d9e802637310b0648909fb4b3c78f55827825500
# Parent  bdc029900564980f8145b060adead58f6e31dd71# Parent  07cd9a2d20e09f9d66de9c74b0136a3f485b0040
Merge bugfixes #480, #481, #482 and #487 to branch 1.3

diff -r bdc029900564 -r d9e802637310 CMakeLists.txt
--- a/CMakeLists.txt	Tue Apr 08 15:57:42 2014 +0200
+++ b/CMakeLists.txt	Mon Jul 07 11:57:45 2014 +0200
@@ -1,5 +1,7 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
+CMAKE_POLICY(SET CMP0048 OLD)
+
 SET(PROJECT_NAME "LEMON")
 PROJECT(${PROJECT_NAME})
 
@@ -186,11 +188,11 @@
     "Flags used by the C compiler during maintainer builds."
     )
   SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
-    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
+    "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
     "Flags used for linking binaries during maintainer builds."
     )
   SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
-    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
+    "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
     "Flags used by the shared libraries linker during maintainer builds."
     )
 ENDIF()
diff -r bdc029900564 -r d9e802637310 lemon/CMakeLists.txt
--- a/lemon/CMakeLists.txt	Tue Apr 08 15:57:42 2014 +0200
+++ b/lemon/CMakeLists.txt	Mon Jul 07 11:57:45 2014 +0200
@@ -55,8 +55,13 @@
 ENDIF()
 
 ADD_LIBRARY(lemon ${LEMON_SOURCES})
+
+TARGET_LINK_LIBRARIES(lemon
+  ${GLPK_LIBRARIES} ${COIN_LIBRARIES} ${ILOG_LIBRARIES} ${SOPLEX_LIBRARIES}
+  )
+
 IF(UNIX)
-  SET_TARGET_PROPERTIES(lemon PROPERTIES OUTPUT_NAME emon)
+  SET_TARGET_PROPERTIES(lemon PROPERTIES OUTPUT_NAME emon VERSION ${LEMON_VERSION} SOVERSION ${LEMON_VERSION})
 ENDIF()
 
 INSTALL(
diff -r bdc029900564 -r d9e802637310 lemon/dim2.h
--- a/lemon/dim2.h	Tue Apr 08 15:57:42 2014 +0200
+++ b/lemon/dim2.h	Mon Jul 07 11:57:45 2014 +0200
@@ -20,6 +20,7 @@
 #define LEMON_DIM2_H
 
 #include <iostream>
+#include <algorithm>
 
 ///\ingroup geomdat
 ///\file
diff -r bdc029900564 -r d9e802637310 lemon/math.h
--- a/lemon/math.h	Tue Apr 08 15:57:42 2014 +0200
+++ b/lemon/math.h	Mon Jul 07 11:57:45 2014 +0200
@@ -67,7 +67,7 @@
 
   ///Round a value to its closest integer
   inline double round(double r) {
-    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
+    return (r > 0.0) ? std::floor(r + 0.5) : std::ceil(r - 0.5);
   }
 
   /// @}
diff -r bdc029900564 -r d9e802637310 test/arc_look_up_test.cc
--- a/test/arc_look_up_test.cc	Tue Apr 08 15:57:42 2014 +0200
+++ b/test/arc_look_up_test.cc	Mon Jul 07 11:57:45 2014 +0200
@@ -24,7 +24,6 @@
 
 using namespace lemon;
 
-const int lgfn = 4;
 const std::string lgf =
   "@nodes\n"
 "label\n"
diff -r bdc029900564 -r d9e802637310 tools/lgf-gen.cc
--- a/tools/lgf-gen.cc	Tue Apr 08 15:57:42 2014 +0200
+++ b/tools/lgf-gen.cc	Mon Jul 07 11:57:45 2014 +0200
@@ -246,7 +246,7 @@
 
   struct BeachIt;
 
-  typedef std::multimap<double, BeachIt> SpikeHeap;
+  typedef std::multimap<double, BeachIt*> SpikeHeap;
 
   typedef std::multimap<Part, SpikeHeap::iterator, YLess> Beach;
 
@@ -329,6 +329,7 @@
       Beach::iterator bit = beach.upper_bound(Part(site, site, site));
 
       if (bit->second != spikeheap.end()) {
+        delete bit->second->second;
         spikeheap.erase(bit->second);
       }
 
@@ -342,8 +343,8 @@
       if (prev != -1 &&
           circle_form(points[prev], points[curr], points[site])) {
         double x = circle_point(points[prev], points[curr], points[site]);
-        pit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end())));
-        pit->second.it =
+        pit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end())));
+        pit->second->it =
           beach.insert(std::make_pair(Part(prev, curr, site), pit));
       } else {
         beach.insert(std::make_pair(Part(prev, curr, site), pit));
@@ -355,8 +356,8 @@
       if (next != -1 &&
           circle_form(points[site], points[curr],points[next])) {
         double x = circle_point(points[site], points[curr], points[next]);
-        nit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end())));
-        nit->second.it =
+        nit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end())));
+        nit->second->it =
           beach.insert(std::make_pair(Part(site, curr, next), nit));
       } else {
         beach.insert(std::make_pair(Part(site, curr, next), nit));
@@ -366,7 +367,7 @@
     } else {
       sweep = spit->first;
 
-      Beach::iterator bit = spit->second.it;
+      Beach::iterator bit = spit->second->it;
 
       int prev = bit->first.prev;
       int curr = bit->first.curr;
@@ -399,10 +400,22 @@
       Beach::iterator nbit = bit; ++nbit;
       int nnt = nbit->first.next;
 
-      if (bit->second != spikeheap.end()) spikeheap.erase(bit->second);
-      if (pbit->second != spikeheap.end()) spikeheap.erase(pbit->second);
-      if (nbit->second != spikeheap.end()) spikeheap.erase(nbit->second);
-
+      if (bit->second != spikeheap.end())
+        {
+          delete bit->second->second;
+          spikeheap.erase(bit->second);
+        }
+      if (pbit->second != spikeheap.end())
+        {
+          delete pbit->second->second;
+          spikeheap.erase(pbit->second);
+        }
+      if (nbit->second != spikeheap.end())
+        {
+          delete nbit->second->second;
+          spikeheap.erase(nbit->second);
+        }
+      
       beach.erase(nbit);
       beach.erase(bit);
       beach.erase(pbit);
@@ -412,8 +425,8 @@
           circle_form(points[ppv], points[prev], points[next])) {
         double x = circle_point(points[ppv], points[prev], points[next]);
         if (x < sweep) x = sweep;
-        pit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end())));
-        pit->second.it =
+        pit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end())));
+        pit->second->it =
           beach.insert(std::make_pair(Part(ppv, prev, next), pit));
       } else {
         beach.insert(std::make_pair(Part(ppv, prev, next), pit));
@@ -424,8 +437,8 @@
           circle_form(points[prev], points[next], points[nnt])) {
         double x = circle_point(points[prev], points[next], points[nnt]);
         if (x < sweep) x = sweep;
-        nit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end())));
-        nit->second.it =
+        nit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end())));
+        nit->second->it =
           beach.insert(std::make_pair(Part(prev, next, nnt), nit));
       } else {
         beach.insert(std::make_pair(Part(prev, next, nnt), nit));