From 7fa6d6448c142409058a40617fa0071d6a6053e6 Mon Sep 17 00:00:00 2001
From: Leorize <alaviss@users.noreply.github.com>
Date: Tue, 16 Jan 2018 18:45:42 +0700
Subject: CMakeLists: Use GNUInstallDirs and don't link rt


diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6780e0..63ede58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,17 +24,25 @@ if(HEFUR_CONTROL_INTERFACE)
   add_definitions(-DHEFUR_CONTROL_INTERFACE)
 endif()
 
+include(GNUInstallDirs)
+
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  set(RT_LIB "rt")
+else()
+  set(RT_LIB "")
+endif()
+
 add_subdirectory(mimosa EXCLUDE_FROM_ALL)
 include_directories(mimosa)
 add_subdirectory(hefur)
 
 install(
   DIRECTORY www/
-  DESTINATION share/hefur/www
+  DESTINATION ${CMAKE_INSTALL_DATADIR}/hefur/www
   PATTERN bootstrap EXCLUDE
   PATTERN *.less EXCLUDE
   PATTERN update-bootstrap.sh EXCLUDE)
 
 install(
   FILES manual/manual.html
-  DESTINATION share/doc/hefur/)
\ No newline at end of file
+  DESTINATION ${CMAKE_INSTALL_DOCDIR}/hefur/)
diff --git a/hefur/CMakeLists.txt b/hefur/CMakeLists.txt
index c347e9f..7c11b0d 100644
--- a/hefur/CMakeLists.txt
+++ b/hefur/CMakeLists.txt
@@ -15,12 +15,12 @@ if(HEFUR_CONTROL_INTERFACE)
     mimosa
     ${GNUTLS_LIBRARY}
     pthread
-    rt)
+    ${RT_LIB})
 
   install(TARGETS hefurctl
-    RUNTIME DESTINATION bin
-    LIBRARY DESTINATION lib
-    ARCHIVE DESTINATION lib)
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
   set(HEFURD_CONTROL_SOURCES
     control-server.cc
@@ -64,13 +64,13 @@ target_link_libraries(hefurd
   mimosa
   ${GNUTLS_LIBRARY}
   pthread
-  rt)
+  ${RT_LIB})
 
 install(TARGETS hefurd
-  RUNTIME DESTINATION bin
-  LIBRARY DESTINATION lib
-  ARCHIVE DESTINATION lib
-  PUBLIC_HEADER DESTINATION include/hefur)
+  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hefur)
 
 install(FILES tracker-controller.hh
-  DESTINATION include/hefur)
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hefur)
-- 
2.15.0

