From 48e834d1eb5f5a32307eff55ff131321e17f4935 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Thu, 10 Dec 2009 20:37:56 -0800 Subject: [PATCH] More work on CMake build system. --- cmake/Conky.cmake | 7 +++- cmake/ConkyBuildOptions.cmake | 14 ++++++++ cmake/ConkyPlatformChecks.cmake | 62 +++++++++++++++++++++++++++++++++ cmake/config.h.in | 28 ++++++++++++++- doc/Makefile.am | 6 ++-- src/CMakeLists.txt | 4 +++ 6 files changed, 116 insertions(+), 5 deletions(-) diff --git a/cmake/Conky.cmake b/cmake/Conky.cmake index d74b1ab9..063aab16 100644 --- a/cmake/Conky.cmake +++ b/cmake/Conky.cmake @@ -75,7 +75,12 @@ if(NOT RELEASE) mark_as_advanced(APP_GIT) endif(NOT RELEASE) -mark_as_advanced(APP_GAWK APP_WC APP_DATE APP_UNAME) +# Used for doc generation +find_program(APP_DB2X_XSLTPROC db2x_xsltproc) +find_program(APP_DB2X_MANXML db2x_manxml) +find_program(APP_XSLTPROC xsltproc) + +mark_as_advanced(APP_GAWK APP_WC APP_DATE APP_UNAME APP_DB2X_XSLTPROC APP_DB2X_MANXML APP_XSLTPROC) # The version numbers are simply derived from the date and number of commits # since start of month diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index f1864d73..fc86a7ea 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -36,22 +36,35 @@ if(OS_LINUX) option(BUILD_PORT_MONITORS "Build TCP portmon support" true) option(BUILD_IBM "Support for IBM/Lenovo notebooks" true) option(BUILD_HDDTEMP "Support for hddtemp" true) + option(BUILD_IOSTATS "Enable disk I/O stats" true) + option(BUILD_WLAN "Enable wireless support" false) # nvidia may also work on FreeBSD, not sure option(BUILD_NVIDIA "Enable nvidia support" false) else(OS_LINUX) set(BUILD_PORT_MONITORS false) set(BUILD_IBM false) set(BUILD_HDDTEMP false) + set(BUILD_IOSTATS false) + set(BUILD_WLAN false) set(BUILD_NVIDIA false) endif(OS_LINUX) # Optional features etc +# + +option(BUILD_CONFIG_OUTPUT "Enable default config file output" true) + +option(BUILD_MATH "Enable math support" true) + +option(BUILD_NCURSES "Enable ncurses support" true) + option(BUILD_X11 "Build X11 support" true) if(BUILD_X11) option(OWN_WINDOW "Enable own_window support" true) option(BUILD_XDAMAGE "Build Xdamage support" true) option(BUILD_XDBE "Build Xdbe (double-buffer) support" true) option(BUILD_XFT "Build Xft (freetype fonts) support" true) + option(BUILD_IMLIB2 "Enable Imlib2 support" false) endif(BUILD_X11) option(BUILD_LUA "Build Lua support" true) @@ -83,3 +96,4 @@ if(BUILD_WEATHER_METAR OR BUILD_WEATHER_XOAP) set(BUILD_CURL true) endif(BUILD_WEATHER_METAR OR BUILD_WEATHER_XOAP) +option(BUILD_APCUPSD "Enable APCUPSD support" true) diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index 702a00ea..4f02487a 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -2,6 +2,7 @@ include(FindPkgConfig) include(CheckFunctionExists) +include(CheckIncludeFile) # Check for some headers check_include_files(sys/statfs.h HAVE_SYS_STATFS_H) @@ -40,6 +41,61 @@ if(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD) message(FATAL_ERROR "Your platform, '${CMAKE_SYSTEM_NAME}', is not currently supported. Patches are welcome.") endif(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD) +if(BUILD_MATH) + set(conky_libs ${conky_libs} -lm) +endif(BUILD_MATH) + +if(BUILD_CONFIG_OUTPUT) + check_function_exists(fopencookie HAVE_FOPENCOOKIE) + check_function_exists(funopen HAVE_FUNOPEN) +endif(BUILD_CONFIG_OUTPUT) + +if(BUILD_NCURSES) + check_include_file(ncurses.h NCURSES_H) + find_library(NCURSES_LIB NAMES ncurses) + if(NOT NCURSES_H OR NOT NCURSES_LIB) + message(FATAL_ERROR "Unable to find ncurses library") + endif(NOT NCURSES_H OR NOT NCURSES_LIB) + set(conky_libs ${conky_libs} ${NCURSES_LIB}) +endif(BUILD_NCURSES) + +if(BUILD_WLAN) + check_include_file(iwlib.h IWLIB_H) + find_library(IWLIB_LIB NAMES iw) + if(NOT IWLIB_H OR NOT IWLIB_LIB) + message(FATAL_ERROR "Unable to find iwlib") + endif(NOT IWLIB_H OR NOT IWLIB_LIB) + set(CMAKE_REQUIRED_LIBRARIES ${IWLIB_LIB}) + check_function_exists(iw_sockets_open IWLIB_SOCKETS_OPEN_FUNC) +endif(BUILD_WLAN) + +if(BUILD_PORT_MONITORS) + check_function_exists(getnameinfo HAVE_GETNAMEINFO) + if(NOT HAVE_GETNAMEINFO) + message(FATAL_ERROR "could not find getnameinfo()") + endif(NOT HAVE_GETNAMEINFO) + check_include_files("netdb.h;netinet/in.h;netinet/tcp.h;sys/socket.h;arpa/inet.h" HAVE_PORTMON_HEADERS) + if(NOT HAVE_PORTMON_HEADERS) + message(FATAL_ERROR "missing needed network header(s) for port monitoring") + endif(NOT HAVE_PORTMON_HEADERS) +endif(BUILD_PORT_MONITORS) + + +# Check for iconv +check_include_file(iconv.h HAVE_ICONV_H) +find_library(ICONV_LIBRARY NAMES iconv) +if(HAVE_ICONV_H AND ICONV_LIBRARY) + set(conky_includes ${conky_includes} ${ICONV_INCLUDE_DIR}) + set(conky_libs ${conky_libs} ${ICONV_LIBRARY}) + set(HAVE_ICONV true) +else(HAVE_ICONV_H AND ICONV_LIBRARY) + # too annoying + # message(WARNING "Unable to find iconv library") + set(HAVE_ICONV false) +endif(HAVE_ICONV_H AND ICONV_LIBRARY) + + + # check for Xlib if(BUILD_X11) include(FindX11) @@ -163,6 +219,12 @@ if(BUILD_NVIDIA) endif(XNVCtrl_INCLUDE_PATH AND XNVCtrl_LIB) endif(BUILD_NVIDIA) +if(BUILD_IMLIB2) + pkg_check_modules(IMLIB2 imlib2) + set(conky_libs ${conky_libs} ${IMLIB2_LIB}) + set(conky_includes ${conky_includes} ${IMLIB2_INCLUDE_PATH}) +endif(BUILD_IMLIB2) + # Common libraries if(WANT_GLIB) pkg_check_modules(GLIB REQUIRED glib-2.0) diff --git a/cmake/config.h.in b/cmake/config.h.in index 4ed44f18..677b3b0a 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -104,7 +104,6 @@ #define HAVE_CURL #endif /* BUILD_CURL */ -#cmakedefine BUILD_WEATHER 1 #cmakedefine BUILD_WEATHER_XOAP 1 #cmakedefine BUILD_WEATHER_METAR 1 @@ -118,4 +117,31 @@ #define WEATHER #endif /* BUILD_WEATHER */ +#cmakedefine BUILD_IMLIB2 1 +#ifdef BUILD_IMLIB2 +#define IMLIB2 +#endif /* BUILD_IMLIB2 */ + +#cmakedefine BUILD_MATH 1 +#ifdef BUILD_MATH +#define MATH +#endif /* BUILD_MATH */ + +#cmakedefine BUILD_CONFIG_OUTPUT 1 +#ifdef BUILD_CONFIG_OUTPUT +#define CONFIG_OUTPUT +#endif /* BUILD_CONFIG_OUTPUT */ + +#cmakedefine BUILD_NCURSES 1 +#ifdef BUILD_NCURSES +#define NCURSES +#endif /* BUILD_NCURSES */ + +#cmakedefine BUILD_APCUPSD 1 +#ifdef BUILD_APCUPSD +#define APCUPSD +#endif /* BUILD_APCUPSD */ + +#cmakedefine HAVE_ICONV 1 + #endif /* _conky_config_h_ */ diff --git a/doc/Makefile.am b/doc/Makefile.am index 26ca2941..7eaa935a 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -16,9 +16,9 @@ conky.1: command_options.xml config_settings.xml docs.xml variables.xml lua.xml sed -i "s/\x80//g" README sed -i "s/\x90/-/g" README mv README ${top_srcdir} - xsltproc ${srcdir}/variables.xsl ${srcdir}/variables.xml > variables.html - xsltproc ${srcdir}/config_settings.xsl ${srcdir}/config_settings.xml > config_settings.html - xsltproc ${srcdir}/lua.xsl ${srcdir}/lua.xml > lua.html + ${xsltproc_cmd} ${srcdir}/variables.xsl ${srcdir}/variables.xml > variables.html + ${xsltproc_cmd} ${srcdir}/config_settings.xsl ${srcdir}/config_settings.xml > config_settings.html + ${xsltproc_cmd} ${srcdir}/lua.xsl ${srcdir}/lua.xml > lua.html else conky.1: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ca85aff..507f1b7c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -136,6 +136,10 @@ if(BUILD_ICONV) set(optional_sources ${optional_sources} ${iconv}) endif(BUILD_ICONV) +if(BUILD_CONFIG_OUTPUT) + set(optional_sources ${optional_sources} defconfig.h conf_cookie.c conf_cookie.h) +endif(BUILD_CONFIG_OUTPUT) + add_executable(conky ${conky_sources} ${optional_sources}) target_link_libraries(conky ${conky_libs})