mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-06-02 07:20:47 +00:00
Added support for builtin config in cmake
This commit is contained in:
parent
5664cc3d13
commit
287c38a0b9
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
#cmakedefine BUILD_MATH 1
|
||||
|
||||
#cmakedefine BUILD_CONFIG_OUTPUT 1
|
||||
#cmakedefine BUILD_BUILTIN_CONFIG 1
|
||||
|
||||
#cmakedefine BUILD_NCURSES 1
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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)
|
||||
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
|
29
src/conky.cc
29
src/conky.cc
|
@ -107,7 +107,7 @@
|
|||
#include <bsd/bsd.h>
|
||||
#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 */
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user