Browse Source

Fixed Ubuntu having undefined references.

naelstrof 10 years ago
parent
commit
77f5af15ac
3 changed files with 29 additions and 2 deletions
  1. 5
    2
      CMakeLists.txt
  2. 23
    0
      cmakemodules/FindRT.cmake
  3. 1
    0
      src/main.cpp

+ 5
- 2
CMakeLists.txt View File

@@ -91,13 +91,15 @@ set( source
91 91
 set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmakemodules" )
92 92
 find_package( X11       REQUIRED )
93 93
 find_package( XExt      REQUIRED )
94
+find_package( RT        REQUIRED )
94 95
 
95 96
 set( CMAKE_CXX_FLAGS
96 97
      "${CMAKE_CXX_FLAGS} ${CMAKE_IMLIB2_CXX_FLAGS}" )
97 98
 
98 99
 # Includes
99 100
 include_directories( ${X11_INCLUDE_DIR}
100
-                     ${XEXT_INCLUDE_DIR} )
101
+                     ${XEXT_INCLUDE_DIR}
102
+                     ${RT_INCLUDE_DIR} )
101 103
 
102 104
 # Executable
103 105
 add_executable( "${BIN_TARGET}" ${source} )
@@ -105,7 +107,8 @@ add_executable( "${BIN_TARGET}" ${source} )
105 107
 # Libraries
106 108
 target_link_libraries( "${BIN_TARGET}"
107 109
                        ${X11_LIBRARIES}
108
-                       "${XEXT_LIBRARY}" )
110
+                       "${XEXT_LIBRARY}"
111
+                       "${RT_LIBRARY}" )
109 112
 
110 113
 install( TARGETS ${BIN_TARGET}
111 114
          DESTINATION  ${CMAKE_INSTALL_PREFIX} )

+ 23
- 0
cmakemodules/FindRT.cmake View File

@@ -0,0 +1,23 @@
1
+# - Find rt
2
+# Find the rt libraries, this is to fix ubuntu not having clock_gettime defined without it.
3
+#
4
+#  This module defines the following variables:
5
+#     RT_FOUND        - 1 if RT_INCLUDE_DIR & RT_LIBRARY are found, 0 otherwise
6
+#     RT_INCLUDE_DIR  - where to find Xlib.h, etc.
7
+#     RT_LIBRARY      - the X11 library
8
+#
9
+
10
+find_path( RT_INCLUDE_DIR
11
+           NAMES time.h )
12
+
13
+find_library( RT_LIBRARY
14
+              NAMES rt
15
+              PATHS /usr/lib /lib )
16
+
17
+if( RT_INCLUDE_DIR AND RT_LIBRARY )
18
+    set( RT_FOUND 1 )
19
+else()
20
+    set( RT_FOUND 0 )
21
+endif()
22
+
23
+mark_as_advanced( RT_INCLUDE_DIR RT_LIBRARY )

+ 1
- 0
src/main.cpp View File

@@ -18,6 +18,7 @@
18 18
  * along with Slop.  If not, see <http://www.gnu.org/licenses/>.
19 19
  */
20 20
 #include <unistd.h>
21
+#include <time.h>
21 22
 #include <cstdio>
22 23
 #include <sstream>
23 24