From da05bed32f07ea43818885522c1892058fb4c7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 4 Jun 2026 17:32:52 +0800 Subject: [PATCH] CMake: exposes pre-defined macros to `fastfetch.c` to avoid imcompatiblity with `libfastfetch` --- CMakeLists.txt | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0211aeda..2323569b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1576,24 +1576,24 @@ endif() if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "") message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}") - target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH}) + target_compile_definitions(libfastfetch PUBLIC FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH}) endif() if(NOT "${CUSTOM_AMDGPU_IDS_PATH}" STREQUAL "") message(STATUS "Custom file path of amdgpu.ids: ${CUSTOM_AMDGPU_IDS_PATH}") - target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH}) + target_compile_definitions(libfastfetch PUBLIC FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH}) endif() if(NOT "${CUSTOM_OS_RELEASE_PATH}" STREQUAL "") message(STATUS "Custom file path of os_release: ${CUSTOM_OS_RELEASE_PATH}") - target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_OS_RELEASE_PATH=${CUSTOM_OS_RELEASE_PATH}) + target_compile_definitions(libfastfetch PUBLIC FF_CUSTOM_OS_RELEASE_PATH=${CUSTOM_OS_RELEASE_PATH}) endif() if(NOT "${CUSTOM_LSB_RELEASE_PATH}" STREQUAL "") message(STATUS "Custom file path of lsb_release: ${CUSTOM_LSB_RELEASE_PATH}") - target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_LSB_RELEASE_PATH=${CUSTOM_LSB_RELEASE_PATH}) + target_compile_definitions(libfastfetch PUBLIC FF_CUSTOM_LSB_RELEASE_PATH=${CUSTOM_LSB_RELEASE_PATH}) endif() if(NOT BINARY_LINK_TYPE STREQUAL "dlopen") message(STATUS "Enabling custom link type: ${BINARY_LINK_TYPE}") - target_compile_definitions(libfastfetch PRIVATE FF_DISABLE_DLOPEN=1) + target_compile_definitions(libfastfetch PUBLIC FF_DISABLE_DLOPEN=1) if(NOT WIN32) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--copy-dt-needed-entries") endif() @@ -1659,18 +1659,18 @@ function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME) # [CMAKE_TARGET_NAME] message(STATUS "Library: found ${VARNAME} by ${${VARNAME}_FOUND}") - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_${VARNAME}=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_${VARNAME}=1) target_include_directories(libfastfetch PRIVATE ${${VARNAME}_INCLUDE_DIRS}) if(NOT BINARY_LINK_TYPE STREQUAL "dlopen") - target_link_directories(libfastfetch PUBLIC ${${VARNAME}_LIBRARY_DIRS}) + target_link_directories(libfastfetch PRIVATE ${${VARNAME}_LIBRARY_DIRS}) target_link_libraries(libfastfetch PRIVATE ${${VARNAME}_LIBRARIES}) endif() foreach(FLAG ${${VARNAME}_CFLAGS_OTHER}) if(FLAG MATCHES "-D.*") string(SUBSTRING ${FLAG} 2 -1 FLAG) - target_compile_definitions(libfastfetch PRIVATE ${FLAG}) + target_compile_definitions(libfastfetch PUBLIC ${FLAG}) endif() endforeach() endfunction() @@ -1800,8 +1800,8 @@ if(ENABLE_LUA) message(STATUS "Library: Lua version ${Lua_VERSION} is not supported, requires 5.3-5.5") unset(Lua_FOUND) else() - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LUA=1) - target_include_directories(libfastfetch PRIVATE ${LUA_INCLUDE_DIR}) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_LUA=1) + target_include_directories(libfastfetch PUBLIC ${LUA_INCLUDE_DIR}) if(NOT BINARY_LINK_TYPE STREQUAL "dlopen") target_link_libraries(libfastfetch PRIVATE ${LUA_LIBRARIES}) @@ -1814,20 +1814,20 @@ if(ENABLE_LUA) endif() if(ENABLE_THREADS) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_THREADS=1) if(CMAKE_USE_PTHREADS_INIT) #Threads::Threads is not set for WIN32 target_link_libraries(libfastfetch PRIVATE Threads::Threads) endif() endif() if(ENABLE_EMBEDDED_PCIIDS) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EMBEDDED_PCIIDS=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_EMBEDDED_PCIIDS=1) endif() if(ENABLE_EMBEDDED_AMDGPUIDS) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EMBEDDED_AMDGPUIDS=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_EMBEDDED_AMDGPUIDS=1) endif() if(ENABLE_LIBZFS) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LIBZFS=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_LIBZFS=1) if(NOT BINARY_LINK_TYPE STREQUAL "dlopen") target_link_libraries(libfastfetch @@ -1984,7 +1984,7 @@ target_link_libraries(libfastfetch PRIVATE ${CMAKE_DL_LIBS} ) -target_compile_options(libfastfetch PRIVATE +target_compile_options(libfastfetch PUBLIC $<$:-fno-exceptions -fno-rtti>) if(FreeBSD) @@ -1993,18 +1993,18 @@ endif() if(LINUX OR FreeBSD OR OpenBSD OR NetBSD) CHECK_INCLUDE_FILE("linux/videodev2.h" HAVE_LINUX_VIDEODEV2) if(HAVE_LINUX_VIDEODEV2) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LINUX_VIDEODEV2=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_LINUX_VIDEODEV2=1) endif() endif() if(NOT WIN32) CHECK_INCLUDE_FILE("utmpx.h" HAVE_UTMPX) if(HAVE_UTMPX) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_UTMPX=1) endif() if(ENABLE_WORDEXP) CHECK_INCLUDE_FILE("wordexp.h" HAVE_WORDEXP) if(HAVE_WORDEXP) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WORDEXP=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_WORDEXP=1) message(STATUS "wordexp.h found, wordexp support enabled") else() set(ENABLE_WORDEXP OFF) @@ -2016,19 +2016,19 @@ if(NOT WIN32) if(ENABLE_THREADS AND CMAKE_USE_PTHREADS_INIT) CHECK_INCLUDE_FILE("pthread_np.h" HAVE_PTHREAD_NP) if(HAVE_PTHREAD_NP) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_PTHREAD_NP=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_PTHREAD_NP=1) set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} pthread_np.h) endif() set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} Threads::Threads) check_function_exists("pthread_timedjoin_np" HAVE_TIMEDJOIN_NP) if(HAVE_TIMEDJOIN_NP) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_TIMEDJOIN_NP=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_TIMEDJOIN_NP=1) else() message(WARNING "pthread_timedjoin_np was not found; networking timeout will not work") endif() endif() elseif(HAVE_WINRT) - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WINRT=1) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_WINRT=1) endif() set(PACKAGES_DISABLE_LIST "") @@ -2045,9 +2045,9 @@ else() list(TRANSFORM PACKAGES_DISABLE_LIST APPEND "_BIT") list(JOIN PACKAGES_DISABLE_LIST " | " PACKAGES_DISABLE_LIST) endif() -target_compile_definitions(libfastfetch PRIVATE "FF_PACKAGES_DISABLE_LIST=${PACKAGES_DISABLE_LIST}") +target_compile_definitions(libfastfetch PUBLIC "FF_PACKAGES_DISABLE_LIST=${PACKAGES_DISABLE_LIST}") if(PACKAGES_REMOVE_DISABLED) - target_compile_definitions(libfastfetch PRIVATE FF_PACKAGES_REMOVE_DISABLED=1) + target_compile_definitions(libfastfetch PUBLIC FF_PACKAGES_REMOVE_DISABLED=1) endif() ######################