mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-08 17:31:39 -05:00
Add support for libproc2 (Linux)
Needed for Debian build. (#590) Also cleaned up platform dependent sections of CMakeLists.txt.
This commit is contained in:
parent
7407bc7d82
commit
fd8e3c1e5c
|
|
@ -346,10 +346,8 @@ elseif(OS_MACOS)
|
|||
|
||||
find_library(COCOA Cocoa)
|
||||
target_include_directories(${LIB_NAME} PRIVATE ${COCOA})
|
||||
target_sources(${LIB_NAME} PRIVATE src/osx/advanced-scene-switcher-osx.mm)
|
||||
set_source_files_properties(advanced-scene-switcher-osx.mm
|
||||
PROPERTIES COMPILE_FLAGS "-fobjc-arc")
|
||||
set("${PROJECT_NAME}_PLATFORM_LIBS" ${COCOA})
|
||||
target_link_libraries(${LIB_NAME} PRIVATE ${COCOA})
|
||||
|
||||
find_package(CURL)
|
||||
find_package(Libcurl)
|
||||
if(CURL_FOUND)
|
||||
|
|
@ -359,6 +357,10 @@ elseif(OS_MACOS)
|
|||
else()
|
||||
message(FATAL_ERROR "Couldn't find CURL or Libcurl - abort")
|
||||
endif()
|
||||
|
||||
target_sources(${LIB_NAME} PRIVATE src/osx/advanced-scene-switcher-osx.mm)
|
||||
set_source_files_properties(advanced-scene-switcher-osx.mm
|
||||
PROPERTIES COMPILE_FLAGS "-fobjc-arc")
|
||||
# --- End of section ---
|
||||
|
||||
# --- Linux-specific build settings and tasks ---
|
||||
|
|
@ -369,23 +371,36 @@ else()
|
|||
set_target_properties(${LIB_NAME} PROPERTIES SOVERSION 1)
|
||||
|
||||
find_package(X11 REQUIRED COMPONENTS Xtst Xss)
|
||||
find_path(PROCPS_INCLUDE_DIR NAMES proc/procps.h)
|
||||
if(NOT PROCPS_INCLUDE_DIR)
|
||||
message(
|
||||
FATAL_ERROR "procps include dir not found - please set PROCPS_INCLUDE_DIR"
|
||||
)
|
||||
endif()
|
||||
find_library(PROCPS_LIBRARY NAMES procps)
|
||||
if(NOT PROCPS_LIBRARY)
|
||||
message(FATAL_ERROR "procps lib not found - please set PROCPS_LIBRARY")
|
||||
endif()
|
||||
target_link_libraries(${LIB_NAME} PRIVATE ${X11_LIBRARIES}
|
||||
${procps_LIBRARIES})
|
||||
target_include_directories(
|
||||
${LIB_NAME} PRIVATE "${X11_INCLUDE_DIR}" "${X11_Xtst_INCLUDE_PATH}"
|
||||
"${X11_Xss_INCLUDE_PATH}" "${PROCPS_INCLUDE_DIR}")
|
||||
target_sources(${LIB_NAME} PRIVATE src/linux/advanced-scene-switcher-nix.cpp)
|
||||
set("${PROJECT_NAME}_PLATFORM_LIBS" Xss ${PROCPS_LIBRARY})
|
||||
"${X11_Xss_INCLUDE_PATH}")
|
||||
target_link_libraries(${LIB_NAME} PRIVATE ${X11_LIBRARIES})
|
||||
|
||||
find_path(PROCPS_INCLUDE_DIR NAMES proc/procps.h)
|
||||
find_path(PROCPS2_INCLUDE_DIR NAMES libproc2/pids.h)
|
||||
find_library(PROCPS_LIBRARY NAMES procps)
|
||||
find_library(PROCPS2_LIBRARY NAMES proc2)
|
||||
if(PROCPS_INCLUDE_DIR AND PROCPS_LIBRARY)
|
||||
message(STATUS "${PROJECT_NAME} using procps")
|
||||
set(PROC_INCLUDE_DIR "${PROCPS_INCLUDE_DIR}")
|
||||
set(PROC_LIBRARY "${PROCPS_LIBRARY}")
|
||||
target_compile_definitions(${LIB_NAME} PRIVATE USE_PROCPS)
|
||||
elseif(PROCPS2_INCLUDE_DIR AND PROCPS2_LIBRARY)
|
||||
message(STATUS "${PROJECT_NAME} using libproc2")
|
||||
set(PROC_INCLUDE_DIR "${PROCPS2_INCLUDE_DIR}")
|
||||
set(PROC_LIBRARY "${PROCPS2_LIBRARY}")
|
||||
else()
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"found neither procps nor libproc2!
|
||||
please either set ...
|
||||
PROCPS_INCLUDE_DIR and PROCPS_LIBRARY
|
||||
... or ...
|
||||
PROCPS2_INCLUDE_DIR and PROCPS2_LIBRARY")
|
||||
endif()
|
||||
target_link_libraries(${LIB_NAME} PRIVATE "${PROC_LIBRARY}")
|
||||
target_include_directories(${LIB_NAME} PRIVATE "${PROC_INCLUDE_DIR}")
|
||||
|
||||
find_package(CURL)
|
||||
find_package(Libcurl)
|
||||
if(CURL_FOUND)
|
||||
|
|
@ -395,11 +410,11 @@ else()
|
|||
else()
|
||||
message(FATAL_ERROR "Couldn't find CURL or Libcurl - abort")
|
||||
endif()
|
||||
|
||||
target_sources(${LIB_NAME} PRIVATE src/linux/advanced-scene-switcher-nix.cpp)
|
||||
endif()
|
||||
# --- End of section ---
|
||||
|
||||
target_link_libraries(${LIB_NAME} PUBLIC ${${PROJECT_NAME}_PLATFORM_LIBS})
|
||||
|
||||
if(DEB_INSTALL)
|
||||
file(GLOB ASS_TRANSLATION_FILES "data/locale/*.ini")
|
||||
if(NOT LIB_OUT_DIR)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@
|
|||
#include <QStringList>
|
||||
#include <QRegularExpression>
|
||||
#include <QLibrary>
|
||||
#ifdef USE_PROCPS
|
||||
#include <proc/readproc.h>
|
||||
#else
|
||||
#include <libproc2/pids.h>
|
||||
#endif
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
|
|
@ -362,7 +366,7 @@ bool isFullscreen(const std::string &title)
|
|||
return false;
|
||||
}
|
||||
|
||||
//exe switch is not quite what is expected but it works for now
|
||||
#ifdef USE_PROCPS
|
||||
void GetProcessList(QStringList &processes)
|
||||
{
|
||||
processes.clear();
|
||||
|
|
@ -371,12 +375,37 @@ void GetProcessList(QStringList &processes)
|
|||
memset(&proc_info, 0, sizeof(proc_info));
|
||||
while (readproc(proc, &proc_info) != NULL) {
|
||||
QString procName(proc_info.cmd);
|
||||
if (!procName.isEmpty() && !processes.contains(proc_info.cmd)) {
|
||||
processes << QString(proc_info.cmd);
|
||||
if (!procName.isEmpty() && !processes.contains(procName)) {
|
||||
processes << procName;
|
||||
}
|
||||
}
|
||||
closeproc(proc);
|
||||
}
|
||||
#else
|
||||
void GetProcessList(QStringList &processes)
|
||||
{
|
||||
processes.clear();
|
||||
struct pids_info *info = NULL;
|
||||
struct pids_stack *stack;
|
||||
enum pids_item Items[] = {
|
||||
PIDS_CMD,
|
||||
};
|
||||
|
||||
if (procps_pids_new(&info, Items, sizeof(Items) / sizeof(Items[0])) <
|
||||
0) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ((stack = procps_pids_get(info, PIDS_FETCH_TASKS_ONLY))) {
|
||||
auto cmd = PIDS_VAL(0, str, stack, info);
|
||||
QString procName(cmd);
|
||||
if (!procName.isEmpty() && !processes.contains(procName)) {
|
||||
processes << procName;
|
||||
}
|
||||
}
|
||||
procps_pids_unref(&info);
|
||||
}
|
||||
#endif
|
||||
|
||||
int getForegroundProcessPid()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user