Added support for builtin config in cmake
This commit is contained in:
@@ -82,7 +82,7 @@ endif(OS_LINUX)
|
|||||||
# Optional features etc
|
# 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)
|
option(BUILD_MATH "Enable math support" true)
|
||||||
|
|
||||||
|
@@ -65,10 +65,10 @@ if(BUILD_MATH)
|
|||||||
set(conky_libs ${conky_libs} -lm)
|
set(conky_libs ${conky_libs} -lm)
|
||||||
endif(BUILD_MATH)
|
endif(BUILD_MATH)
|
||||||
|
|
||||||
if(BUILD_CONFIG_OUTPUT)
|
if(BUILD_BUILTIN_CONFIG)
|
||||||
check_function_exists(fopencookie HAVE_FOPENCOOKIE)
|
check_function_exists(fopencookie HAVE_FOPENCOOKIE)
|
||||||
check_function_exists(funopen HAVE_FUNOPEN)
|
check_function_exists(funopen HAVE_FUNOPEN)
|
||||||
endif(BUILD_CONFIG_OUTPUT)
|
endif(BUILD_BUILTIN_CONFIG)
|
||||||
|
|
||||||
if(BUILD_NCURSES)
|
if(BUILD_NCURSES)
|
||||||
check_include_file(ncurses.h NCURSES_H)
|
check_include_file(ncurses.h NCURSES_H)
|
||||||
|
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
#cmakedefine BUILD_MATH 1
|
#cmakedefine BUILD_MATH 1
|
||||||
|
|
||||||
#cmakedefine BUILD_CONFIG_OUTPUT 1
|
#cmakedefine BUILD_BUILTIN_CONFIG 1
|
||||||
|
|
||||||
#cmakedefine BUILD_NCURSES 1
|
#cmakedefine BUILD_NCURSES 1
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
if(BUILD_CONFIG_OUTPUT)
|
if(BUILD_BUILTIN_CONFIG)
|
||||||
# generate defconfig
|
# generate defconfig
|
||||||
add_custom_command(OUTPUT defconfig.h COMMAND
|
add_custom_command(OUTPUT defconfig.h COMMAND
|
||||||
${CMAKE_SOURCE_DIR}/text2c.sh ${CMAKE_CURRENT_SOURCE_DIR}/conky.conf
|
${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)
|
add_custom_target(defconfig ALL DEPENDS defconfig.h)
|
||||||
set_source_files_properties(defconfig.h PROPERTIES GENERATED TRUE)
|
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})
|
include_directories(${conky_includes})
|
||||||
if(BUILD_CONFIG_OUTPUT)
|
if(BUILD_BUILTIN_CONFIG)
|
||||||
# include config output dir
|
# include config output dir
|
||||||
include_directories(${CMAKE_BINARY_DIR}/data)
|
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
|
# ensure build.h and config.h aren't in the way
|
||||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
||||||
@@ -165,9 +165,9 @@ if(BUILD_ICONV)
|
|||||||
set(optional_sources ${optional_sources} ${iconv})
|
set(optional_sources ${optional_sources} ${iconv})
|
||||||
endif(BUILD_ICONV)
|
endif(BUILD_ICONV)
|
||||||
|
|
||||||
if(BUILD_CONFIG_OUTPUT)
|
if(BUILD_BUILTIN_CONFIG)
|
||||||
set(optional_sources ${optional_sources} conf_cookie.c)
|
set(optional_sources ${optional_sources} conf_cookie.c)
|
||||||
endif(BUILD_CONFIG_OUTPUT)
|
endif(BUILD_BUILTIN_CONFIG)
|
||||||
|
|
||||||
add_executable(conky ${conky_sources} ${optional_sources})
|
add_executable(conky ${conky_sources} ${optional_sources})
|
||||||
|
|
||||||
|
29
src/conky.cc
29
src/conky.cc
@@ -107,7 +107,7 @@
|
|||||||
#include <bsd/bsd.h>
|
#include <bsd/bsd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_OUTPUT
|
#ifdef BUILD_BUILTIN_CONFIG
|
||||||
#include "defconfig.h"
|
#include "defconfig.h"
|
||||||
#include "conf_cookie.h"
|
#include "conf_cookie.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -240,9 +240,9 @@ static void print_version(void)
|
|||||||
#ifdef BUILD_EVE
|
#ifdef BUILD_EVE
|
||||||
" * eve-online\n"
|
" * eve-online\n"
|
||||||
#endif /* BUILD_EVE */
|
#endif /* BUILD_EVE */
|
||||||
#ifdef BUILD_CONFIG_OUTPUT
|
#ifdef BUILD_BUILTIN_CONFIG
|
||||||
" * config-output\n"
|
" * builtin default configuration\n"
|
||||||
#endif /* CONFIG_OUTPUT */
|
#endif /* BUILD_BUILTIN_CONFIG */
|
||||||
#ifdef BUILD_IMLIB2
|
#ifdef BUILD_IMLIB2
|
||||||
" * Imlib2\n"
|
" * Imlib2\n"
|
||||||
#endif /* BUILD_IMLIB2 */
|
#endif /* BUILD_IMLIB2 */
|
||||||
@@ -2837,11 +2837,11 @@ static void X11_create_window(void)
|
|||||||
|
|
||||||
static FILE *open_config_file(const char *f)
|
static FILE *open_config_file(const char *f)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_OUTPUT
|
#ifdef BUILD_BUILTIN_CONFIG
|
||||||
if (!strcmp(f, "==builtin==")) {
|
if (!strcmp(f, "==builtin==")) {
|
||||||
return conf_cookie_open();
|
return conf_cookie_open();
|
||||||
} else
|
} else
|
||||||
#endif /* CONFIG_OUTPUT */
|
#endif /* BUILD_BUILTIN_CONFIG */
|
||||||
return fopen(f, "r");
|
return fopen(f, "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3897,7 +3897,7 @@ static void print_help(const char *prog_name) {
|
|||||||
" -q, --quiet quiet mode\n"
|
" -q, --quiet quiet mode\n"
|
||||||
" -D, --debug increase debugging output, ie. -DD for more debugging\n"
|
" -D, --debug increase debugging output, ie. -DD for more debugging\n"
|
||||||
" -c, --config=FILE config file to load\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"
|
" -C, --print-config print the builtin default config to stdout\n"
|
||||||
" e.g. 'conky -C > ~/.conkyrc' will create a new default config\n"
|
" e.g. 'conky -C > ~/.conkyrc' will create a new default config\n"
|
||||||
#endif
|
#endif
|
||||||
@@ -3936,7 +3936,7 @@ static const char *getopt_string = "vVqdDt:u:i:hc:p:"
|
|||||||
"b"
|
"b"
|
||||||
#endif
|
#endif
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
#ifdef CONFIG_OUTPUT
|
#ifdef BUILD_BUILTIN_CONFIG
|
||||||
"C"
|
"C"
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
@@ -3946,7 +3946,7 @@ static const struct option longopts[] = {
|
|||||||
{ "version", 0, NULL, 'V' },
|
{ "version", 0, NULL, 'V' },
|
||||||
{ "debug", 0, NULL, 'D' },
|
{ "debug", 0, NULL, 'D' },
|
||||||
{ "config", 1, NULL, 'c' },
|
{ "config", 1, NULL, 'c' },
|
||||||
#ifdef CONFIG_OUTPUT
|
#ifdef BUILD_BUILTIN_CONFIG
|
||||||
{ "print-config", 0, NULL, 'C' },
|
{ "print-config", 0, NULL, 'C' },
|
||||||
#endif
|
#endif
|
||||||
{ "daemonize", 0, NULL, 'd' },
|
{ "daemonize", 0, NULL, 'd' },
|
||||||
@@ -4231,7 +4231,7 @@ int main(int argc, char **argv)
|
|||||||
case 'h':
|
case 'h':
|
||||||
print_help(argv[0]);
|
print_help(argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef CONFIG_OUTPUT
|
#ifdef BUILD_BUILTIN_CONFIG
|
||||||
case 'C':
|
case 'C':
|
||||||
print_defconfig();
|
print_defconfig();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -4285,12 +4285,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* No readable config found */
|
/* No readable config found */
|
||||||
if (!current_config) {
|
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==");
|
current_config = strdup("==builtin==");
|
||||||
NORM_ERR("no readable personal or system-wide config file found,"
|
NORM_ERR(NOCFGFILEFOUND
|
||||||
" using builtin default");
|
", using builtin default");
|
||||||
#else
|
#else
|
||||||
CRIT_ERR(NULL, NULL, "no readable personal or system-wide config file found");
|
CRIT_ERR(NULL, NULL, NOCFGFILEFOUND);
|
||||||
#endif /* ! CONF_OUTPUT */
|
#endif /* ! CONF_OUTPUT */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user