fastfetch/CMakeLists.txt

262 lines
7.1 KiB
CMake
Raw Normal View History

2021-11-07 21:35:59 +01:00
cmake_minimum_required(VERSION 3.1.0) # Threads::Threads
2021-02-18 22:25:36 +01:00
2021-11-08 10:27:26 +08:00
project(fastfetch LANGUAGES C)
2021-02-18 22:25:36 +01:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
2021-03-07 20:05:00 +01:00
2021-11-17 18:38:57 +01:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion")
2021-10-25 13:29:39 +02:00
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-O3")
2021-02-22 20:36:25 +01:00
execute_process(
COMMAND git rev-list --count HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_REV_LIST
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_REV_PARSE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(PROJECT_VERSION "r${GIT_REV_LIST}.${GIT_REV_PARSE}")
2021-11-13 18:43:33 +01:00
set(PROJECT_VERSION_MAJOR "${GIT_REV_LIST}")
2021-02-22 20:36:25 +01:00
2021-10-22 21:53:29 +02:00
function(fastfetch_load_text FILENAME OUTVAR)
file(READ "${FILENAME}" TEMP)
string(REPLACE "\n" "\\n" TEMP "${TEMP}")
string(REPLACE "\"" "\\\"" TEMP "${TEMP}")
string(REPLACE "$\\" "" TEMP "${TEMP}")
set("${OUTVAR}" "${TEMP}" PARENT_SCOPE)
endfunction(fastfetch_load_text)
fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE)
2021-10-22 21:53:29 +02:00
fastfetch_load_text(src/data/config.txt DATATEXT_CONFIG)
fastfetch_load_text(src/data/modules.txt DATATEXT_MODULES)
fastfetch_load_text(src/data/help.txt DATATEXT_HELP)
fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR)
fastfetch_load_text(src/data/help_format.txt DATATEXT_HELP_FORMAT)
fastfetch_load_text(src/data/help_config.txt DATATEXT_HELP_CONFIG)
2021-02-22 20:36:25 +01:00
configure_file(src/fastfetch_config.h.in fastfetch_config.h)
2021-03-06 11:28:38 +01:00
2021-04-07 17:36:03 +02:00
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
2022-02-08 07:10:46 +02:00
OPTION(ENABLE_LIBPCI "Enable libpci" ON)
OPTION(ENABLE_VULKAN "Enable vulkan" ON)
OPTION(ENABLE_WAYLAND "Enable wayland-client" ON)
OPTION(ENABLE_XCB_RANDR "Enable xcb-randr" ON)
OPTION(ENABLE_XCB "Enable xcb" ON)
OPTION(ENABLE_XRANDR "Enable xrandr" ON)
OPTION(ENABLE_X11 "Enable x11" ON)
OPTION(ENABLE_GIO "Enable gio-2.0" ON)
OPTION(ENABLE_DCONF "Enable dconf" ON)
OPTION(ENABLE_XFCONF "Enable libxfconf-0" ON)
OPTION(ENABLE_RPM "Enable rpm" ON)
if(ENABLE_LIBPCI)
pkg_check_modules (LIBPCI libpci)
if(LIBPCI_FOUND)
add_compile_definitions(FF_HAVE_LIBPCI=1)
else(LIBPCI_FOUND)
message(WARNING "Package libpci not found. Building without support.")
endif(LIBPCI_FOUND)
endif(ENABLE_LIBPCI)
if(ENABLE_VULKAN)
pkg_check_modules (VULKAN vulkan)
if(VULKAN_FOUND)
add_compile_definitions(FF_HAVE_VULKAN=1)
else(VULKAN_FOUND)
message(WARNING "Package vulkan not found. Building without support.")
endif(VULKAN_FOUND)
endif(ENABLE_VULKAN)
if(ENABLE_WAYLAND)
pkg_check_modules (WAYLAND wayland-client)
if(WAYLAND_FOUND)
add_compile_definitions(FF_HAVE_WAYLAND=1)
else(WAYLAND_FOUND)
message(WARNING "Package wayland-client not found. Building without support.")
endif(WAYLAND_FOUND)
endif(ENABLE_WAYLAND)
if(ENABLE_XCB_RANDR)
pkg_check_modules (XCB_RANDR xcb-randr)
if(XCB_RANDR_FOUND)
add_compile_definitions(FF_HAVE_XCB_RANDR=1)
else(XCB_RANDR_FOUND)
message(WARNING "Package xcb-randr not found. Building without support.")
endif(XCB_RANDR_FOUND)
endif(ENABLE_XCB_RANDR)
if(ENABLE_XCB)
pkg_check_modules (XCB xcb)
if(XCB_FOUND)
add_compile_definitions(FF_HAVE_XCB=1)
else(XCB_FOUND)
message(WARNING "Package xcb not found. Building without support.")
endif(XCB_FOUND)
endif(ENABLE_XCB)
if(ENABLE_XRANDR)
pkg_check_modules (XRANDR xrandr)
if(XRANDR_FOUND)
add_compile_definitions(FF_HAVE_XRANDR=1)
else(XRANDR_FOUND)
message(WARNING "Package xrandr not found. Building without support.")
endif(XRANDR_FOUND)
endif(ENABLE_XRANDR)
if(ENABLE_X11)
pkg_check_modules (X11 x11)
if(X11_FOUND)
add_compile_definitions(FF_HAVE_X11=1)
else(X11_FOUND)
message(WARNING "Package x11 not found. Building without support.")
endif(X11_FOUND)
endif(ENABLE_X11)
if(ENABLE_GIO)
pkg_check_modules (GIO gio-2.0)
if(GIO_FOUND)
add_compile_definitions(FF_HAVE_GIO=1)
else(GIO_FOUND)
message(WARNING "Package gio-2.0 not found. Building without support.")
endif(GIO_FOUND)
endif(ENABLE_GIO)
if(ENABLE_DCONF)
pkg_check_modules (DCONF dconf)
if(DCONF_FOUND)
add_compile_definitions(FF_HAVE_DCONF=1)
else(DCONF_FOUND)
message(WARNING "Package dconf not found. Building without support.")
endif(DCONF_FOUND)
endif(ENABLE_DCONF)
if(ENABLE_XFCONF)
pkg_check_modules (XFCONF libxfconf-0)
if(XFCONF_FOUND)
add_compile_definitions(FF_HAVE_XFCONF=1)
else(XFCONF_FOUND)
message(WARNING "Package libxfconf-0 not found. Building without support.")
endif(XFCONF_FOUND)
endif(ENABLE_XFCONF)
if(ENABLE_RPM)
pkg_check_modules (RPM rpm)
if(RPM_FOUND)
add_compile_definitions(FF_HAVE_RPM=1)
else(RPM_FOUND)
message(WARNING "Package librpm not found. Building without support.")
endif(RPM_FOUND)
endif(ENABLE_RPM)
2021-04-05 23:42:07 +02:00
2021-02-27 16:40:05 +01:00
include_directories(
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src
${LIBPCI_INCLUDE_DIRS}
2022-01-05 14:40:57 +01:00
${VULKAN_INCLUDE_DIRS}
${WAYLAND_INCLUDE_DIRS}
2022-01-05 14:40:57 +01:00
${XCB_RANDR_INCLUDE_DIRS}
${XCB_INCLUDE_DIRS}
${XRANDR_INCLUDE_DIRS}
${X11_INCLUDE_DIRS}
${GIO_INCLUDE_DIRS}
${DCONF_INCLUDE_DIRS}
${XFCONF_INCLUDE_DIRS}
${RPM_INCLUDE_DIRS}
2021-02-27 16:40:05 +01:00
)
2021-02-22 20:36:25 +01:00
2021-04-09 14:07:05 +02:00
link_libraries(
${CMAKE_DL_LIBS}
Threads::Threads
)
2021-02-27 18:30:05 +01:00
set(SRCS
2021-03-19 20:57:07 +01:00
src/util/FFstrbuf.c
2021-04-24 13:05:43 +02:00
src/util/FFlist.c
2021-04-09 14:07:05 +02:00
src/common/init.c
src/common/threading.c
src/common/io.c
2021-04-18 15:19:21 +02:00
src/common/processing.c
2021-04-09 14:07:05 +02:00
src/common/logo.c
src/common/format.c
src/common/parsing.c
2021-05-04 19:48:23 +02:00
src/common/settings.c
src/common/library.c
2022-01-10 20:20:18 +01:00
src/common/networking.c
2022-01-14 13:21:49 +01:00
src/detection/os.c
src/detection/plasma.c
src/detection/gtk.c
src/detection/terminalShell.c
2022-01-02 16:55:26 +01:00
src/detection/displayserver/displayServer.c
src/detection/displayserver/wayland.c
2022-01-05 14:40:57 +01:00
src/detection/displayserver/xcb.c
2022-01-02 16:55:26 +01:00
src/detection/displayserver/xlib.c
src/detection/displayserver/wmde.c
2021-02-27 16:40:05 +01:00
src/modules/break.c
2021-02-27 19:22:28 +01:00
src/modules/custom.c
2021-02-27 16:40:05 +01:00
src/modules/title.c
2021-05-15 12:36:25 +02:00
src/modules/separator.c
2021-02-27 16:40:05 +01:00
src/modules/os.c
src/modules/host.c
src/modules/kernel.c
src/modules/uptime.c
2021-10-18 22:38:00 +08:00
src/modules/processes.c
2021-02-27 16:40:05 +01:00
src/modules/packages.c
src/modules/shell.c
src/modules/resolution.c
2021-03-19 20:57:07 +01:00
src/modules/de.c
2021-03-05 21:38:35 +01:00
src/modules/wm.c
2021-04-03 23:10:14 +02:00
src/modules/wmtheme.c
2021-02-27 16:40:05 +01:00
src/modules/theme.c
src/modules/icons.c
src/modules/font.c
2021-06-20 21:04:55 +02:00
src/modules/cursor.c
2021-02-27 16:40:05 +01:00
src/modules/terminal.c
2021-03-11 17:21:18 +01:00
src/modules/terminalfont.c
2021-02-27 16:40:05 +01:00
src/modules/cpu.c
2021-11-24 16:16:25 +08:00
src/modules/cpuUsage.c
2021-02-27 16:40:05 +01:00
src/modules/gpu.c
src/modules/memory.c
src/modules/disk.c
src/modules/battery.c
src/modules/locale.c
2021-10-17 12:42:15 +08:00
src/modules/localip.c
2022-01-10 20:20:18 +01:00
src/modules/publicip.c
2021-02-27 16:40:05 +01:00
src/modules/colors.c
2021-02-18 22:25:36 +01:00
)
2021-02-27 18:30:05 +01:00
add_executable(fastfetch
src/fastfetch.c
src/util/FFvaluestore.c
2021-02-27 18:30:05 +01:00
${SRCS}
)
add_executable(flashfetch
src/flashfetch.c
${SRCS}
)
target_compile_definitions(flashfetch PUBLIC
FASTFETCH_BUILD_FLASHFETCH
)
2022-01-12 01:02:14 +01:00
add_executable(fastfetch-test-performance
tests/performance.c
${SRCS}
)
add_executable(fastfetch-test-strbuf
tests/strbuf.c
${SRCS}
)