mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
Fix linking error: clock_gettime not found
I decided to reimplement AC_SEARCH_LIB from autotools in the process, as I consider it a very nifty feature.
This commit is contained in:
parent
b2331969d5
commit
031e79e77e
@ -61,6 +61,7 @@ set(conky_libs ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(conky_includes ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_definitions(-D_GNU_SOURCE) # Standard definitions
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE")
|
||||
|
||||
# Do version stuff
|
||||
set(VERSION_MAJOR "2")
|
||||
@ -112,3 +113,24 @@ endif(RELEASE)
|
||||
|
||||
set(COPYRIGHT "Copyright Brenden Matthews, et al, 2005-2010")
|
||||
|
||||
macro(AC_SEARCH_LIBS FUNCTION_NAME INCLUDES TARGET_VAR)
|
||||
if("${TARGET_VAR}" MATCHES "^${TARGET_VAR}$")
|
||||
unset(AC_SEARCH_LIBS_TMP CACHE)
|
||||
check_symbol_exists(${FUNCTION_NAME} ${INCLUDES} AC_SEARCH_LIBS_TMP)
|
||||
if(${AC_SEARCH_LIBS_TMP})
|
||||
set(${TARGET_VAR} "" CACHE INTERNAL "Library containing ${FUNCTION_NAME}")
|
||||
return()
|
||||
endif(${AC_SEARCH_LIBS_TMP})
|
||||
|
||||
foreach(LIB ${ARGN})
|
||||
unset(AC_SEARCH_LIBS_TMP CACHE)
|
||||
unset(AC_SEARCH_LIBS_FOUND CACHE)
|
||||
find_library(AC_SEARCH_LIBS_TMP ${LIB})
|
||||
check_library_exists(${LIB} ${FUNCTION_NAME} ${AC_SEARCH_LIBS_TMP} AC_SEARCH_LIBS_FOUND)
|
||||
if(${AC_SEARCH_LIBS_FOUND})
|
||||
set(${TARGET_VAR} ${AC_SEARCH_LIBS_TMP} CACHE INTERNAL "Library containing ${FUNCTION_NAME}")
|
||||
break()
|
||||
endif(${AC_SEARCH_LIBS_FOUND})
|
||||
endforeach(LIB)
|
||||
endif("${TARGET_VAR}" MATCHES "^${TARGET_VAR}$")
|
||||
endmacro(AC_SEARCH_LIBS)
|
||||
|
@ -23,6 +23,7 @@
|
||||
include(FindPkgConfig)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckSymbolExists)
|
||||
|
||||
# Check for some headers
|
||||
check_include_files(sys/statfs.h HAVE_SYS_STATFS_H)
|
||||
@ -33,6 +34,12 @@ check_include_files(dirent.h HAVE_DIRENT_H)
|
||||
# Check for some functions
|
||||
check_function_exists(strndup HAVE_STRNDUP)
|
||||
|
||||
AC_SEARCH_LIBS(clock_gettime "time.h" CLOCK_GETTIME_LIB "rt")
|
||||
if(NOT CLOCK_GETTIME_LIB)
|
||||
message(FATAL_ERROR "clock_gettime not found.")
|
||||
endif(NOT CLOCK_GETTIME_LIB)
|
||||
set(conky_libs ${conky_libs} ${CLOCK_GETTIME_LIB})
|
||||
|
||||
# standard path to search for includes
|
||||
set(INCLUDE_SEARCH_PATH /usr/include /usr/local/include)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user