diff --git a/.gitignore b/.gitignore index 36d896d23..336dd0f3f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,14 +15,13 @@ cmake_install.cmake cmake_uninstall.cmake CPackConfig.cmake CPackSourceConfig.cmake +CMakeUserPresets.json # Generated files data/convertconf.h data/defconfig.h *.so *.a -/config.h -/build.h src/colour-names.hh # Compiler cache diff --git a/3rdparty/toluapp/CMakeLists.txt b/3rdparty/toluapp/CMakeLists.txt index cfcb8144c..2a3ecc855 100644 --- a/3rdparty/toluapp/CMakeLists.txt +++ b/3rdparty/toluapp/CMakeLists.txt @@ -1,41 +1,39 @@ -# Copyright (C) 2007-2012 LuaDist. -# Created by Peter Kapec -# Redistribution and use of this file is allowed according to the terms of the MIT license. -# For details see the COPYRIGHT file distributed with LuaDist. -# Please note that the package source code is licensed under its own license. +# Created under MIT License 2007-2012 for LuaDist by Peter Kapec +# Copy of the license is available in the COPYRIGHT file. +# Vendored and maintained for conky build process. -project ( toluapp C ) -cmake_minimum_required ( VERSION 3.15 ) -# Disable dist stuff, we're not installing this as a lib -# include ( cmake/dist.cmake ) +project(toluapp C) +cmake_minimum_required(VERSION 3.15) -include(FindPkgConfig) -include(FindLua) -include_directories ( include src/lib ${LUA_INCLUDE_DIR} ) +if(NOT DEFINED LUA_VERSION) + set(LUA_VERSION "5.3") +endif() + +include(FindLua ${LUA_VERSION}) +find_package(Lua ${LUA_VERSION} REQUIRED) # Build lib -file ( GLOB SRC_LIBTOLUAPP src/lib/*.c ) -if ( MSVC ) - set ( DEF_FILE libtoluapp.def ) -endif ( ) +file(GLOB SRC_LIBTOLUAPP "${CMAKE_CURRENT_SOURCE_DIR}/src/lib/*.c") +if(MSVC) + list(APPEND SRC_LIBTOLUAPP libtoluapp.def) +endif() -# add_library ( toluapp_lib SHARED ${SRC_LIBTOLUAPP} ${DEF_FILE} ) -add_library ( toluapp_lib_static STATIC ${SRC_LIBTOLUAPP} ${DEF_FILE} ) -target_link_libraries ( toluapp_lib_static ${LUA_LIBRARIES} ) -set_target_properties ( toluapp_lib_static PROPERTIES COMPILE_FLAGS -fPIC) # -fPIC required for static linking -set_target_properties ( toluapp_lib_static PROPERTIES OUTPUT_NAME toluapp CLEAN_DIRECT_OUTPUT - 1 ) +add_library(toluapp_lib_static STATIC ${SRC_LIBTOLUAPP}) +target_include_directories(toluapp_lib_static + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" + PRIVATE ${LUA_INCLUDE_DIR} +) +target_link_libraries(toluapp_lib_static PUBLIC ${LUA_LIBRARIES}) +set_target_properties(toluapp_lib_static PROPERTIES + COMPILE_FLAGS -fPIC # required for static linking + OUTPUT_NAME toluapp + CLEAN_DIRECT_OUTPUT 1 +) # Build app -include_directories ( src/bin ) -set ( SRC_TOLUA src/bin/tolua.c src/bin/toluabind.c ) -add_executable ( toluapp ${SRC_TOLUA} ) -target_link_libraries ( toluapp toluapp_lib_static ${LUA_LIBRARIES} ) - -# Disable installation, we don't need these at runtime for Conky -# Install -#install_library ( toluapp_lib ) -#install_executable ( toluapp ) -#install_header ( include/ ) -#install_data ( README INSTALL ) -#install_doc ( doc/ ) +set(SRC_TOLUA + src/bin/tolua.c + src/bin/toluabind.c +) +add_executable(toluapp ${SRC_TOLUA}) +target_link_libraries(toluapp toluapp_lib_static) diff --git a/3rdparty/toluapp/INSTALL b/3rdparty/toluapp/INSTALL deleted file mode 100644 index 5ee408f9e..000000000 --- a/3rdparty/toluapp/INSTALL +++ /dev/null @@ -1,42 +0,0 @@ -This version of tolua++ uses SCons to compile (http://www.scons.org). SCons uses -pythin. If you don't want to install python, check "Installation without scons" -below. - -* Installation - - 1. Edit the "config" file for your platform to suit your environment, - if at all necessary (for cygwin, mingw, BSD and mac OSX use - 'config_posix') - 2. Then, type "scons". - - You can use 'scons -h' to see a list of available command line options. - -* What you get - - If "scons" succeeds, you get: - * an executable to generate binding code in ./bin; - * the C library to be linked in your application in ./lib; - * the include file needed to compile your application in ./include. - These are the only directories you need for development, besides Lua. - - You can use 'scons install' to install the files, see the 'prefix' option. - -* Installation without scons - - The instructions for building tolua++ without scons depend on the particular - compiler you are using. - The simplest way is to create a folder with all .c and .h files except - 'toluabind_default.c', and then create a project for the executable and the - library, as follows: - - tolua.exe: all *.c *.h in src/bin (except toluabind_default.c) - tolua.lib: all *.c *.h in src/lib. - -* Installation with Microsoft Visual Studio - - The directory 'win32' contains project files for Microsoft Visual Studio 7 - (contributed by Makoto Hamanaka). The project has 4 different build options: - withLua50_Release, withLua51_Release, withLua50_Debug and withLua51_Debug. - They all expect the lua library names used by the LuaBinaries packages - (http://luabinaries.luaforge.net/). The resulting files are built on /lib and - /bin (for the library and tolua++.exe). diff --git a/3rdparty/toluapp/Makefile b/3rdparty/toluapp/Makefile deleted file mode 100644 index 92ded6c4e..000000000 --- a/3rdparty/toluapp/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# makefile for tolua hierarchy - -all: - @echo "Makefile is deprecated ;)" - @echo "see INSTALL for details on how to build tolua++" diff --git a/3rdparty/toluapp/SConstruct b/3rdparty/toluapp/SConstruct deleted file mode 100644 index 6354d6d1e..000000000 --- a/3rdparty/toluapp/SConstruct +++ /dev/null @@ -1,182 +0,0 @@ -import sys; -import os - -tools = ['default'] -if os.name == 'nt': - tools = ['mingw'] - -env = Environment(tools = tools) - -options_file = None -if sys.platform == 'linux2': - options_file = "linux" - -elif 'msvc' in env['TOOLS']: - options_file = "msvc" -else: - options_file = "posix" - -opts = Options(["config_"+options_file+".py", "custom.py", "custom_"+options_file+".py"], ARGUMENTS) -opts.Add('CC', 'The C compiler.') -opts.Add('CXX', 'The C++ compiler (for the tests)') -opts.Add('CCFLAGS', 'Flags for the compiler.', ['-O2', '-Wall']) -opts.Add('LINK', 'The linker.') -opts.Add('LINKFLAGS', 'Linker flags.', []) -opts.Add('no_cygwin', 'Use -mno-cygwin to build using the mingw compiler on cygwin', 0) -opts.Add('LIBS', 'libraries', []) -opts.Add('LIBPATH', 'library path', []) - -opts.Add('tolua_bin', 'the resulting binary', 'tolua++') -opts.Add('tolua_lib', 'the resulting library', 'tolua++') -opts.Add('TOLUAPP', 'the name of the tolua++ binary (to use with built_dev=1)', 'tolua++') - -opts.Add('prefix', 'The installation prefix') -opts.Add('build_dev', 'Build for development (uses tolua to rebuild toluabind.c with the embeded scripts', 0) -opts.Add('build_failsafe', "Build using 'factory default' toluabind file (in case build_dev fails)", 0) -opts.Add('ENV', 'The environment variables') -opts.Add('shared', 'Build a shared object', False) -opts.Update(env) -Help(opts.GenerateHelpText(env)) - -def save_config(target, source, env): - opts.Save('custom.py', env) - -cust = env.Command('custom.py', [], save_config) -env.Alias('configure', [cust]) - -env['TOLUAPP_BOOTSTRAP'] = env['tolua_bin']+"_bootstrap"+env['PROGSUFFIX'] - -env['build_dev'] = int(env['build_dev']) - -## detecting the install directory on win32 -if 'msvc' in env['TOOLS'] and not (env.has_key('prefix') or env['prefix']): - - if env['MSVS'].has_key('PLATFORMSDKDIR'): - env['prefix'] = env['MSVS']['PLATFORMSDKDIR'] - - -SConscriptChdir(0) - -############ helper builders -def pkg_scan_dep(self, target, source): - - import re - - ## TODO: detectar si el archivo existe antes de abrirlo asi nomas - pkg = open(source, "rt") - - for linea in pkg.xreadlines(): - dep = re.search("^[\t\w]*\$[cphl]file\s*\"([^\"]+)\"", linea) - if dep: - self.Depends(target, '#' + dep.groups()[0]); - - if dep.groups()[0][-4:] == '.pkg': - # recursividad - self.pkg_scan_dep(target, dep.groups()[0]) - - -def make_tolua_code(self, target, source, pkgname = None, bootstrap = False, use_own = False, use_typeid=None): - - ptarget = Dir('.').path + '/' + target - psource = Dir('.').path + '/' + source - header = target[:-2] + '.h' - pheader = Dir('.').path + '/' + header - - print("Generating ", target, " from ", source) - - tolua = "" - if bootstrap: - if os.name == 'nt': - tolua = 'bin\\'+self['TOLUAPP_BOOTSTRAP'] - else: - tolua = 'bin/'+self['TOLUAPP_BOOTSTRAP'] - print("********* tolua is ", tolua) - else: - if use_own: - if 'msvc' in self['TOOLS']: - tolua = 'bin\\$tolua_bin' - else: - tolua = 'bin/$tolua_bin' - else: - tolua = "$TOLUAPP" - - if pkgname: - pkgname = ' -n '+pkgname - else: - pkgname = '' - - if use_typeid: - tolua = tolua+' -t' - - comando = tolua + ' -C -H ' + pheader + ' -o ' + ptarget + pkgname + ' ' + psource - command = self.Command(target, source, comando) - - self.SideEffect(header, target) - self.Depends(target, source) - - self.pkg_scan_dep(target, psource) - - if bootstrap: - self.Depends(target, "#/bin/$TOLUAPP_BOOTSTRAP") - if use_own: - self.Depends(target, "#/bin/$tolua_bin") - - return command - - -env.__class__.LuaBinding = make_tolua_code; -env.__class__.pkg_scan_dep = pkg_scan_dep; - -def print_install_error(target, source, env): - - msg = """Error: no install prefix was specified, or detected. - -you can use the 'prefix' option on command line to specify one. Examples: - - scons prefix=/usr/local install - -or on Windows: - - scons "prefix=c:\\program files\\visual basic" install - -Files will be installed on /bin, /lib and /include -""" - import SCons.Errors - raise SCons.Errors.UserError(msg) - -########### end of helper builders - -env['CPPPATH'] = '#/include' -env['LIBPATH'] = ['#/lib'] + env['LIBPATH'] - -if env['no_cygwin']: - - env['CCFLAGS'] += ['-mno-cygwin'] - env['LINKFLAGS'] += ['-mno-cygwin'] - -import string - -Export('env') - -SConscript('src/lib/SCsub') -SConscript('src/bin/SCsub') -#SConscript('src/lib/SCsub') -SConscript('src/tests/SCsub') - -env.Alias('all', [env.bin_target, env.lib_target]) -env.Alias('test', env.test_targets) - -Default('all') - -if env['prefix']: - env.Install(env['prefix']+'/bin', env.bin_target) - env.Install(env['prefix']+'/lib', env.lib_target) - env.Install(env['prefix']+'/include', '#include/tolua++.h') - - env.Alias('install', [env['prefix']+'/bin', env['prefix']+'/include', env['prefix']+'/lib']) -else: - env.Command('install', [], print_install_error) - env.Depends('install', 'all') - -env.Command('deb', [], 'dpkg-buildpackage -I.svn -Icustom.py -Itoluabind_dev.c -Itoluabind_dev.h -Itoluabind_default.o -Icustom.lua -I.sconsign', ENV=os.environ) - diff --git a/3rdparty/toluapp/config_linux.py b/3rdparty/toluapp/config_linux.py deleted file mode 100644 index 31620279d..000000000 --- a/3rdparty/toluapp/config_linux.py +++ /dev/null @@ -1,22 +0,0 @@ - -## This is the linux configuration file -# use 'scons -h' to see the list of command line options available - -# Compiler flags (based on Debian's installation of lua) -#LINKFLAGS = ['-g'] -CCFLAGS = ['-O2', '-ansi', '-Wall'] -#CCFLAGS = ['-I/usr/include/lua50', '-g'] - -# this is the default directory for installation. Files will be installed on -# /bin, /lib and /include when you run 'scons install' -# -# You can also specify this directory on the command line with the 'prefix' -# option -# -# You can see more 'generic' options for POSIX systems on config_posix.py - -prefix = '/usr/local' - -# libraries (based on Debian's installation of lua) -LIBS = ['lua', 'dl', 'm'] - diff --git a/3rdparty/toluapp/config_msvc.py b/3rdparty/toluapp/config_msvc.py deleted file mode 100644 index 6fda57839..000000000 --- a/3rdparty/toluapp/config_msvc.py +++ /dev/null @@ -1,28 +0,0 @@ - -## This is the MSVC configuration file -# use 'scons -h' to see the list of command line options available - -# flags for the compiler -CCFLAGS = ['/nologo'] - -# this is the default directory for installation. Files will be installed on -# /bin, /lib and /include when you run 'scons install' -# -# You can also specify this directory on the command line with the 'prefix' -# option -# -# If you leave it as 'None', we'll try to auto-detect it (as 'PLATFORMSDKDIR' -# detected by SCons). - -prefix = None # (it's a string) - -# the libraries -LIBS = ['lua', 'lualib'] - -# linkflags -LINKFLAGS = ['/nologo'] - -## We need to specifiy the environment for the PATH and LIB and all those -# parameters cl tales from it -import os -ENV = os.environ diff --git a/3rdparty/toluapp/config_posix.py b/3rdparty/toluapp/config_posix.py deleted file mode 100644 index 2bb696ce4..000000000 --- a/3rdparty/toluapp/config_posix.py +++ /dev/null @@ -1,23 +0,0 @@ - -## This is the POSIX configuration file (will be included for cygwin, mingw -# and possibly mac OSX and BSDs) -# use 'scons -h' to see the list of command line options available - -# flags for the compiler -#CCFLAGS = [] -CCFLAGS = ['-O2', '-ansi', '-Wall'] - -# this is the default directory for installation. Files will be installed on -# /bin, /lib and /include when you run 'scons install' -# -# You can also specify this directory on the command line with the 'prefix' -# option - -prefix = '/usr/local' - -# libraries -LIBS = ['lua', 'lualib', 'm'] - - - -import os diff --git a/3rdparty/toluapp/custom-5.1.py b/3rdparty/toluapp/custom-5.1.py deleted file mode 100644 index 4d1007998..000000000 --- a/3rdparty/toluapp/custom-5.1.py +++ /dev/null @@ -1,9 +0,0 @@ -CCFLAGS = ['-I/usr/include/lua5.1', '-O2', '-ansi'] -#LIBPATH = ['/usr/local/lib'] -LIBS = ['lua5.1', 'dl', 'm'] -prefix = '/mingw' -#build_dev=1 -tolua_bin = 'tolua++5.1' -tolua_lib = 'tolua++5.1' -TOLUAPP = 'tolua++5.1' - diff --git a/3rdparty/toluapp/dist.info b/3rdparty/toluapp/dist.info deleted file mode 100644 index d1f0a0539..000000000 --- a/3rdparty/toluapp/dist.info +++ /dev/null @@ -1,14 +0,0 @@ ---- This file is part of LuaDist project - -name = "toluapp" -version = "1.0.93" - -desc = "tolua++ is an extension of toLua, a tool to integrate C/Cpp code with Lua." -author = "Waldemar Celes, Ariel Manzur" -license = "as-is" -url = "http://www.codenix.com/~tolua/" -maintainer = "Peter Kapec" - -depends = { - "lua ~> 5.1" -} diff --git a/3rdparty/toluapp/win32/vc7/toluapp.sln b/3rdparty/toluapp/win32/vc7/toluapp.sln deleted file mode 100755 index c974421f6..000000000 --- a/3rdparty/toluapp/win32/vc7/toluapp.sln +++ /dev/null @@ -1,27 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluapp", "toluapp.vcproj", "{71891C1A-E328-4258-AC3F-6F9698C6D8B4}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - withLua50_Debug = withLua50_Debug - withLua50_Release = withLua50_Release - withLua51_Debug = withLua51_Debug - withLua51_Release = withLua51_Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Debug.ActiveCfg = withLua51_Release|Win32 - {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Debug.Build.0 = withLua51_Release|Win32 - {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Release.ActiveCfg = withLua50_Release|Win32 - {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Release.Build.0 = withLua50_Release|Win32 - {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Debug.ActiveCfg = withLua51_Debug|Win32 - {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Debug.Build.0 = withLua51_Debug|Win32 - {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Release.ActiveCfg = withLua51_Release|Win32 - {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Release.Build.0 = withLua51_Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/3rdparty/toluapp/win32/vc7/toluapp.vcproj b/3rdparty/toluapp/win32/vc7/toluapp.vcproj deleted file mode 100755 index f27c63b85..000000000 --- a/3rdparty/toluapp/win32/vc7/toluapp.vcproj +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CMakeLists.txt b/CMakeLists.txt index c68f65334..4b9af5ad2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,45 +18,43 @@ # along with this program. If not, see . # -cmake_minimum_required(VERSION 3.17) - -project(conky) +cmake_minimum_required(VERSION 3.25.3) # From Mar 8, 2023 # This is the directory for our custom CMake modules. set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -# 'core' CMake stuff +# Core build settings and options. include(Conky) # Set project version, languages -project(conky VERSION ${RELEASE_VERSION} LANGUAGES C CXX) +project(${PACKAGE_NAME} VERSION ${RELEASE_VERSION} LANGUAGES C CXX) -# Handle build options +# Handle build options. +# Detect OS that's running the build +include(OSDetection) +# If you're a package maintainer, this file has all the information you need. include(ConkyBuildOptions) - # Do platform checks include(ConkyPlatformChecks) # CPack module for installation tasks include(ConkyCPackSetup) - # Use compilation cache (if enabled) include(CCache) -# setup our configuration headers -configure_file(${CMAKE_MODULE_PATH}/config.h.in ${CMAKE_BINARY_DIR}/config.h) -configure_file(${CMAKE_MODULE_PATH}/build.h.in ${CMAKE_BINARY_DIR}/build.h) +# Configure headers +# configure_file("${CMAKE_MODULE_PATH}/config.h.in" "${CMAKE_BINARY_DIR}/include/config.h") -set(conky_sources ${CMAKE_BINARY_DIR}/config.h ${CMAKE_BINARY_DIR}/build.h) +add_subdirectory(src) # Include 3rdparty code add_subdirectory(3rdparty) -set(conky_libs ${conky_libs} toluapp_lib_static) -set(conky_libs ${conky_libs} Vc) -set(conky_includes ${conky_includes} "${CMAKE_SOURCE_DIR}/3rdparty/Vc") +target_link_libraries(conky-dependencies INTERFACE toluapp_lib_static) +target_link_libraries(conky-dependencies INTERFACE Vc) +target_include_directories(conky-dependencies INTERFACE "${CMAKE_SOURCE_DIR}/3rdparty/Vc") # Finally, add some code -add_subdirectory(lua) +add_subdirectory(lua_modules) add_subdirectory(data) add_subdirectory(doc) @@ -74,7 +72,7 @@ if(BUILD_TESTING) include(Catch) endif() -add_subdirectory(src) +add_subdirectory(src/main) if(BUILD_TESTING) add_subdirectory(tests) @@ -102,5 +100,5 @@ if(NOT TARGET uninstall) IMMEDIATE @ONLY) add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake) + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake") endif() diff --git a/cmake/Conky.cmake b/cmake/Conky.cmake index 47059a8fc..01ca10dac 100644 --- a/cmake/Conky.cmake +++ b/cmake/Conky.cmake @@ -1,161 +1,9 @@ -# -# Conky, a system monitor, based on torsmo -# -# Please see COPYING for details -# -# Copyright (c) 2005-2024 Brenden Matthews, et. al. (see AUTHORS) All rights -# reserved. -# -# This program is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation, either version 3 of the License, or (at your option) any later -# version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# +set(PACKAGE_NAME "conky" CACHE INTERNAL "Name of the package") -# set(RELEASE true) - -# Set system vars -if(CMAKE_SYSTEM_NAME MATCHES "Linux") - set(OS_LINUX true) -endif(CMAKE_SYSTEM_NAME MATCHES "Linux") - -if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - set(OS_FREEBSD true) -endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - -if(CMAKE_SYSTEM_NAME MATCHES "DragonFly") - set(OS_DRAGONFLY true) -endif(CMAKE_SYSTEM_NAME MATCHES "DragonFly") - -if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD") - set(OS_OPENBSD true) -endif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD") - -if(CMAKE_SYSTEM_NAME MATCHES "SunOS") - set(OS_SOLARIS true) -endif(CMAKE_SYSTEM_NAME MATCHES "SunOS") - -if(CMAKE_SYSTEM_NAME MATCHES "NetBSD") - set(OS_NETBSD true) -endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD") - -if(CMAKE_SYSTEM_NAME MATCHES "Haiku") - set(OS_HAIKU true) -endif(CMAKE_SYSTEM_NAME MATCHES "Haiku") - -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - set(OS_DARWIN true) -endif(CMAKE_SYSTEM_NAME MATCHES "Darwin") - -if(NOT OS_LINUX - AND NOT OS_FREEBSD - AND NOT OS_OPENBSD - AND NOT OS_NETBSD - AND NOT OS_DRAGONFLY - AND NOT OS_SOLARIS - AND NOT OS_HAIKU - AND NOT OS_DARWIN) - 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 - AND - NOT - OS_NETBSD - AND - NOT - OS_DRAGONFLY - AND - NOT - OS_SOLARIS - AND - NOT - OS_HAIKU - AND - NOT - OS_DARWIN) - -include(FindThreads) -find_package(Threads) - -set(conky_libs ${CMAKE_THREAD_LIBS_INIT}) -set(conky_includes ${CMAKE_BINARY_DIR}) - -# -# On Darwin _POSIX_C_SOURCE must be >= __DARWIN_C_FULL for asprintf to be -# enabled! Thus disable this and _LARGEFILE64_SOURCE isnt needed, it is already -# used on macOS. -# -if(NOT OS_DARWIN AND NOT OS_OPENBSD) - add_definitions(-D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L) # Standard definitions - set( - CMAKE_REQUIRED_DEFINITIONS - "${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L" - ) -endif(NOT OS_DARWIN AND NOT OS_OPENBSD) - -if(OS_FREEBSD) - add_definitions(-D__BSD_VISIBLE=1 -D_XOPEN_SOURCE=700) - set( - CMAKE_REQUIRED_DEFINITIONS - "${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L -D__BSD_VISIBLE=1 -D_XOPEN_SOURCE=700" - ) -endif(OS_FREEBSD) - -if(OS_DRAGONFLY) - set(conky_libs ${conky_libs} -L/usr/pkg/lib) - set(conky_includes ${conky_includes} -I/usr/pkg/include) -endif(OS_DRAGONFLY) - -if(OS_OPENBSD) - # For asprintf - add_definitions(-D_GNU_SOURCE) # Standard definitions - set( - CMAKE_REQUIRED_DEFINITIONS - "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE" - ) -endif(OS_OPENBSD) -if(OS_NETBSD) - set(conky_libs ${conky_libs} -L/usr/pkg/lib) - - add_definitions(-D_NETBSD_SOURCE -D_XOPEN_SOURCE=700) - set( - CMAKE_REQUIRED_DEFINITIONS - "${CMAKE_REQUIRED_DEFINITIONS} -D_NETBSD_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700" - ) -endif(OS_NETBSD) - -if(OS_SOLARIS) - set(conky_libs ${conky_libs} -L/usr/local/lib) -endif(OS_SOLARIS) - -if(OS_HAIKU) - # For asprintf - add_definitions(-D_GNU_SOURCE) # Standard definitions - set( - CMAKE_REQUIRED_DEFINITIONS - "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE" - ) -endif(OS_HAIKU) - -# Do version stuff -set(VERSION_MAJOR "1") -set(VERSION_MINOR "22") -set(VERSION_PATCH "1") +# Current version +set(VERSION_MAJOR "1" CACHE INTERNAL "${PACKAGE_NAME} major version") +set(VERSION_MINOR "22" CACHE INTERNAL "${PACKAGE_NAME} minor version") +set(VERSION_PATCH "1" CACHE INTERNAL "${PACKAGE_NAME} patch version") find_program(APP_AWK awk) @@ -198,7 +46,7 @@ execute_process(COMMAND ${APP_GIT} rev-parse --short HEAD OUTPUT_VARIABLE GIT_SHORT_SHA OUTPUT_STRIP_TRAILING_WHITESPACE) -set(RELEASE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") +set(RELEASE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" CACHE INTERNAL "${PACKAGE_NAME} release version") if(RELEASE) set(VERSION ${RELEASE_VERSION}) @@ -207,34 +55,7 @@ else(RELEASE) "${RELEASE_VERSION}-pre-${GIT_SHORT_SHA}") endif(RELEASE) -set(COPYRIGHT "Copyright Brenden Matthews, et al, 2005-2024") - -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}") - else(${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(${AC_SEARCH_LIBS_TMP}) - endif("${TARGET_VAR}" MATCHES "^${TARGET_VAR}$") -endmacro(AC_SEARCH_LIBS) +set(COPYRIGHT "Copyright Brenden Matthews, et al, 2005-2024" CACHE INTERNAL "${PACKAGE_NAME} copyright") # A function to print the target build properties function(print_target_properties tgt) @@ -259,7 +80,84 @@ function(print_target_properties tgt) if(propval) get_target_property(propval ${tgt} ${prop}) - message(STATUS "${prop} = ${propval}") + message(STATUS "${tgt} ${prop} = ${propval}") endif() endforeach(prop) endfunction(print_target_properties) + +#[[ +Conky uses a C++ compiler to compile the sources. + +DO NOT add c_std_99, because it will cause warnings, which are errors in +MAINTANER_MODE, and that will cause all platform tests to fail in the CI. +c_std_99 only causes a warning with g++/clang++, because they ARE NOT C +compilers. Conky can't be compiled with a C compiler because it's a C++ +program. A program can't simutaneously adhere to both C and C++ +specifications because they're fundamentally different. +]] +add_library(conky-options INTERFACE) +target_compile_features(conky-options INTERFACE cxx_std_17) +target_compile_options(conky-options INTERFACE -Wpedantic) # disable compiler extensions + +# In 99% of use cases this shouldn't be touched. However, if some standard implementation for +# compilation target is bad, it might be necessary to override the defaults. +# Value is a ';'-delimited list of custom compilation definitions (without a '-D' prefix, like defaults). +option(CUSTOM_COMPILE_DEFINITIONS "" "") +mark_as_advanced(CUSTOM_COMPILE_DEFINITIONS) +if(NOT CUSTOM_COMPILE_DEFINITIONS) + # Feature configuration + # These are shared across all supported platforms to ensure build consistency. + target_compile_definitions(conky-options INTERFACE + _POSIX_C_SOURCE=200809L # Use POSIX.1-2008 - https://ieeexplore.ieee.org/document/4694976 + # _XOPEN_SOURCE=700 # Use X/Open 7 / SUSv4 - https://pubs.opengroup.org/onlinepubs/9699919799/ + _FILE_OFFSET_BITS=64 # Use 64-bit types + _LARGEFILE64_SOURCE # Enable statfs64 + # _GNU_SOURCE is intentionally excluded to disable non-standard GNU extensions + ) +else() + foreach(ITEM IN LISTS CUSTOM_COMPILE_DEFINITIONS) + target_compile_definitions(conky-options INTERFACE ${ITEM}) + endforeach() +endif() + +if(NOT OS_OPENBSD) + # Always use libc++ when compiling w/ clang + # Not on OpenBSD because that's the default for its vendored Clang (warning is error -> build fails) + target_compile_options(conky-options INTERFACE + $<$:-stdlib=libc++> + ) + target_link_options(conky-options INTERFACE + $<$:-stdlib=libc++> + ) +endif() + +target_compile_options(conky-options INTERFACE + $<$:-Wno-unknown-warning-option> + $<$:-Wno-unknown-warning> +) + +#[[ +Provides an interface to store compile-time definitions in. This is similar to +configuring a header, only it doesn't require copying all variables multiple +times (in CMake and in header input) and including that header in every place +it's being used. + +This shouldn't contain any defines that affect third-party dependencies +(e.g. _POSIX_C_SOURCE). Those go into `conky-definitions` target. +]] +add_library(conky-definitions INTERFACE) + +# Utility function that adds a source #define to default compilation targets. +# This replaces having to configure and import a header file. +function(source_define DEFINE_NAME) + set(VALUE "") + if(ARGC GREATER 1) + set(VALUE "=${ARGV1}") + endif() + target_compile_definitions(conky-definitions INTERFACE "${DEFINE_NAME}${VALUE}") +endfunction() + +source_define(SYSTEM_NAME "\"${CMAKE_SYSTEM_NAME}\"") +source_define(PACKAGE_NAME "\"${PACKAGE_NAME}\"") +source_define(VERSION "\"${VERSION}\"") +source_define(BUILD_ARCH "\"${BUILD_ARCH}\"") diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index 404a6ff4d..1b6ee6bad 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -18,15 +18,16 @@ # along with this program. If not, see . # -include(CMakeDependentOption) include(DependentOption) # This flag is for developers of conky and automated tests in conky repository. # It should not be enabled by package maintainers as produced binary is -O0. option(MAINTAINER_MODE "Use defaults for development environment (debug, testing, etc.)" false) option(BUILD_TESTING "Build test binary" ${MAINTAINER_MODE}) -cmake_dependent_option(RUN_TESTS "Run tests once the build is complete" false - "BUILD_TESTING" false) +dependent_option(RUN_TESTS + "Run tests once the build is complete" + SHOW_IF "BUILD_TESTING" +) # Use gcov (requires LLVM compiler) to generate code coverage option(CODE_COVERAGE "Enable code coverage report generation" false) @@ -38,37 +39,22 @@ if(NOT CMAKE_BUILD_TYPE) CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE) - else(MAINTAINER_MODE) + FORCE + ) + else() message(STATUS "Default build type: RelWithDebInfo") set( CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE) - endif(MAINTAINER_MODE) -endif(NOT CMAKE_BUILD_TYPE) + FORCE + ) + endif() +endif() -# -std options for all build types -set(CMAKE_C_STANDARD 99) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_COMPILE_WARNING_AS_ERROR ${MAINTAINER_MODE}) -if(NOT OS_OPENBSD) - # Always use libc++ when compiling w/ clang - # Not on OpenBSD because that's the default for its vendored Clang - add_compile_options( - $<$:-stdlib=libc++>) - add_link_options($<$:-stdlib=libc++>) -endif(NOT OS_OPENBSD) - -add_compile_options( - $<$:-Wno-unknown-warning-option> - $<$:-Wno-unknown-warning>) - # Makes builds fully reproducible for environments (such as NixOS) that prefer # building the binary from a clean slate. This makes build defaults and process # avoid optimizations like compiler caching and reusing already built files. @@ -92,18 +78,70 @@ mark_as_advanced(RELEASE) option(BUILD_DOCS "Build documentation" false) option(BUILD_EXTRAS "Build extras (includes syntax files for editors)" false) -option(BUILD_I18N "Enable if you want internationalization support" true) - -option(BUILD_COLOUR_NAME_MAP "Include mappings of colour name -> RGB (e.g. red -> ff0000)" true) - -if(BUILD_I18N) - set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale" - CACHE STRING "Directory containing the locales") -endif(BUILD_I18N) +set(_SOURCE_DEFINES) +#[[.md: +A `DEPENDENT_OPTION` that also adds preprocessor definitions to the build. + +```cmake +conky_option( +