--- demo/CMakeLists.txt.orig	2013-10-30 14:11:59.000000000 +0100
+++ demo/CMakeLists.txt	2014-10-13 10:52:19.000000000 +0200
@@ -61,7 +61,7 @@
   # =======================================================================
   foreach(demo ${demos_NAMES})
     add_executable(${demo} ${demo}.c)
-    target_link_libraries(${demo} ${_LIBHPDF_LIB})
+    target_link_libraries(${demo} ${_LIBHPDF_LIB} m)
     if(DEMO_C_FLAGS)
       set_target_properties(${demo} PROPERTIES COMPILE_FLAGS ${DEMO_C_FLAGS})
     endif(DEMO_C_FLAGS)
@@ -70,7 +70,7 @@
   # some demos need grid_sheet.c compiled in
   foreach(demo ${demos_with_grid_NAMES})
     add_executable(${demo} ${demo}.c grid_sheet.c)
-    target_link_libraries(${demo} ${_LIBHPDF_LIB})
+    target_link_libraries(${demo} ${_LIBHPDF_LIB} m)
     if(DEMO_C_FLAGS)
       set_target_properties(${demo} PROPERTIES COMPILE_FLAGS ${DEMO_C_FLAGS})
     endif(DEMO_C_FLAGS)
@@ -75,6 +75,7 @@
       set_target_properties(${demo} PROPERTIES COMPILE_FLAGS ${DEMO_C_FLAGS})
     endif(DEMO_C_FLAGS)
   endforeach(demo)
+  target_link_libraries(text_demo2 m)
     
   # the grid_sheet demo needs extra defines
   add_executable(grid_sheet grid_sheet.c)
@@ -86,15 +87,15 @@
   # =======================================================================
   install(
     TARGETS ${demos_NAMES} ${demos_with_grid_NAMES} grid_sheet
-    DESTINATION demo
+    DESTINATION ${EXAMPLESDIR}
   )
   foreach(demo ${demos_NAMES} ${demos_with_grid_NAMES} grid_sheet)
-    install(FILES ${demo}.c DESTINATION demo)
+    install(FILES ${demo}.c DESTINATION ${EXAMPLESDIR})
   endforeach(demo)
 
   # install demo files
   install(
     DIRECTORY images mbtext pngsuite rawimage ttfont type1
-    DESTINATION demo
+    DESTINATION ${EXAMPLESDIR}
   )
 endif(LIBHPDF_EXAMPLES)
