From 287c38a0b910dfb9b72883ab6b34f54e10ca272c Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Sun, 17 Jan 2010 03:00:51 +0100 Subject: [PATCH] Added support for builtin config in cmake --- cmake/ConkyBuildOptions.cmake | 2 +- cmake/ConkyPlatformChecks.cmake | 4 ++-- cmake/config.h.in | 2 +- data/CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 8 ++++---- src/conky.cc | 29 +++++++++++++++-------------- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index 592712df..36bb9659 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -82,7 +82,7 @@ endif(OS_LINUX) # Optional features etc # -option(BUILD_CONFIG_OUTPUT "Enable default config file output" true) +option(BUILD_BUILTIN_CONFIG "Enable builtin default configuration" true) option(BUILD_MATH "Enable math support" true) diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index bdccc080..febf4daa 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -65,10 +65,10 @@ if(BUILD_MATH) set(conky_libs ${conky_libs} -lm) endif(BUILD_MATH) -if(BUILD_CONFIG_OUTPUT) +if(BUILD_BUILTIN_CONFIG) check_function_exists(fopencookie HAVE_FOPENCOOKIE) check_function_exists(funopen HAVE_FUNOPEN) -endif(BUILD_CONFIG_OUTPUT) +endif(BUILD_BUILTIN_CONFIG) if(BUILD_NCURSES) check_include_file(ncurses.h NCURSES_H) diff --git a/cmake/config.h.in b/cmake/config.h.in index 1fb6e201..ef4d5b7f 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -75,7 +75,7 @@ #cmakedefine BUILD_MATH 1 -#cmakedefine BUILD_CONFIG_OUTPUT 1 +#cmakedefine BUILD_BUILTIN_CONFIG 1 #cmakedefine BUILD_NCURSES 1 diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 4f41ef1c..b7ff21d7 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -20,7 +20,7 @@ # along with this program. If not, see . # -if(BUILD_CONFIG_OUTPUT) +if(BUILD_BUILTIN_CONFIG) # generate defconfig add_custom_command(OUTPUT defconfig.h COMMAND ${CMAKE_SOURCE_DIR}/text2c.sh ${CMAKE_CURRENT_SOURCE_DIR}/conky.conf @@ -28,5 +28,5 @@ if(BUILD_CONFIG_OUTPUT) ) add_custom_target(defconfig ALL DEPENDS defconfig.h) set_source_files_properties(defconfig.h PROPERTIES GENERATED TRUE) -endif(BUILD_CONFIG_OUTPUT) +endif(BUILD_BUILTIN_CONFIG) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe3ff6e3..034c47a2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,10 +21,10 @@ # include_directories(${conky_includes}) -if(BUILD_CONFIG_OUTPUT) +if(BUILD_BUILTIN_CONFIG) # include config output dir include_directories(${CMAKE_BINARY_DIR}/data) -endif(BUILD_CONFIG_OUTPUT) +endif(BUILD_BUILTIN_CONFIG) # ensure build.h and config.h aren't in the way if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/config.h) @@ -165,9 +165,9 @@ if(BUILD_ICONV) set(optional_sources ${optional_sources} ${iconv}) endif(BUILD_ICONV) -if(BUILD_CONFIG_OUTPUT) +if(BUILD_BUILTIN_CONFIG) set(optional_sources ${optional_sources} conf_cookie.c) -endif(BUILD_CONFIG_OUTPUT) +endif(BUILD_BUILTIN_CONFIG) add_executable(conky ${conky_sources} ${optional_sources}) diff --git a/src/conky.cc b/src/conky.cc index 724907c2..f67078cb 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -107,7 +107,7 @@ #include #endif -#ifdef CONFIG_OUTPUT +#ifdef BUILD_BUILTIN_CONFIG #include "defconfig.h" #include "conf_cookie.h" #endif @@ -240,9 +240,9 @@ static void print_version(void) #ifdef BUILD_EVE " * eve-online\n" #endif /* BUILD_EVE */ -#ifdef BUILD_CONFIG_OUTPUT - " * config-output\n" -#endif /* CONFIG_OUTPUT */ +#ifdef BUILD_BUILTIN_CONFIG + " * builtin default configuration\n" +#endif /* BUILD_BUILTIN_CONFIG */ #ifdef BUILD_IMLIB2 " * Imlib2\n" #endif /* BUILD_IMLIB2 */ @@ -2837,11 +2837,11 @@ static void X11_create_window(void) static FILE *open_config_file(const char *f) { -#ifdef CONFIG_OUTPUT +#ifdef BUILD_BUILTIN_CONFIG if (!strcmp(f, "==builtin==")) { return conf_cookie_open(); } else -#endif /* CONFIG_OUTPUT */ +#endif /* BUILD_BUILTIN_CONFIG */ return fopen(f, "r"); } @@ -3897,7 +3897,7 @@ static void print_help(const char *prog_name) { " -q, --quiet quiet mode\n" " -D, --debug increase debugging output, ie. -DD for more debugging\n" " -c, --config=FILE config file to load\n" -#ifdef CONFIG_OUTPUT +#ifdef BUILD_BUILTIN_CONFIG " -C, --print-config print the builtin default config to stdout\n" " e.g. 'conky -C > ~/.conkyrc' will create a new default config\n" #endif @@ -3936,7 +3936,7 @@ static const char *getopt_string = "vVqdDt:u:i:hc:p:" "b" #endif #endif /* BUILD_X11 */ -#ifdef CONFIG_OUTPUT +#ifdef BUILD_BUILTIN_CONFIG "C" #endif ; @@ -3946,7 +3946,7 @@ static const struct option longopts[] = { { "version", 0, NULL, 'V' }, { "debug", 0, NULL, 'D' }, { "config", 1, NULL, 'c' }, -#ifdef CONFIG_OUTPUT +#ifdef BUILD_BUILTIN_CONFIG { "print-config", 0, NULL, 'C' }, #endif { "daemonize", 0, NULL, 'd' }, @@ -4231,7 +4231,7 @@ int main(int argc, char **argv) case 'h': print_help(argv[0]); return 0; -#ifdef CONFIG_OUTPUT +#ifdef BUILD_BUILTIN_CONFIG case 'C': print_defconfig(); return 0; @@ -4285,12 +4285,13 @@ int main(int argc, char **argv) /* No readable config found */ if (!current_config) { -#ifdef CONFIG_OUTPUT +#define NOCFGFILEFOUND "no readable personal or system-wide config file found" +#ifdef BUILD_BUILTIN_CONFIG current_config = strdup("==builtin=="); - NORM_ERR("no readable personal or system-wide config file found," - " using builtin default"); + NORM_ERR(NOCFGFILEFOUND + ", using builtin default"); #else - CRIT_ERR(NULL, NULL, "no readable personal or system-wide config file found"); + CRIT_ERR(NULL, NULL, NOCFGFILEFOUND); #endif /* ! CONF_OUTPUT */ } }