From af5d57a71661943cd59e260263024a3be2c37451 Mon Sep 17 00:00:00 2001 From: SySyAli Date: Wed, 3 Jan 2024 23:58:08 -0500 Subject: [PATCH] Fixing CMakeLists.txt --- CMakeLists.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea524cb..84c95de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,22 +42,21 @@ add_executable(desktop_screentime main.cpp IWindowInterface.cpp ) -## Link SQLite3 to the executable ## -# Set compiler flags +# Link SQLite3 and possibly X11 and pthread to the executable if(MSVC) # Using Microsoft Visual C++ target_link_libraries(desktop_screentime PRIVATE ${SQLite3_LIBRARIES}) else() # Assuming GCC or Clang - target_link_libraries(desktop_screentime PRIVATE ${SQLite3_LIBRARIES} pthread) + if(X11_FOUND) + # Link both SQLite3 and X11 (and pthread for Linux) + target_link_libraries(desktop_screentime PRIVATE ${SQLite3_LIBRARIES} ${X11_LIBRARIES} pthread) + else() + # Link only SQLite3 and pthread (for Linux without X11) + target_link_libraries(desktop_screentime PRIVATE ${SQLite3_LIBRARIES} pthread) + endif() endif() -target_include_directories(desktop_screentime PRIVATE ${SQLite3_INCLUDE_DIRS}) -# Link X11 library for Linux build -if(X11_FOUND) - target_link_libraries(desktop_screentime ${X11_LIBRARIES}) - target_include_directories(desktop_screentime PRIVATE ${X11_INCLUDE_DIR}) -endif() # Testing Executable # Define the source files and dependencies for the executable