Skip to content

Commit

Permalink
Fixing CMakeLists.txt.
Browse files Browse the repository at this point in the history
  • Loading branch information
SySyAli committed Jan 4, 2024
1 parent af5d57a commit 70e02cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
33 changes: 12 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ else()
# Assuming GCC or Clang
add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()
# include sqlite3
find_package(SQLite3 REQUIRED)

# find X11 - linux
find_package(X11 REQUIRED)
# Find packages
find_package(SQLite3 REQUIRED)
if(UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
endif()

# include testing
enable_testing()
Expand All @@ -42,24 +43,14 @@ add_executable(desktop_screentime main.cpp
IWindowInterface.cpp
)

# Link SQLite3 and possibly X11 and pthread to the executable
# Link libraries
if(MSVC)
# Using Microsoft Visual C++
target_link_libraries(desktop_screentime PRIVATE ${SQLite3_LIBRARIES})
else()
# Assuming GCC or Clang
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()
elseif(UNIX AND NOT APPLE)
target_link_libraries(desktop_screentime PRIVATE ${SQLite3_LIBRARIES} ${X11_LIBRARIES} pthread)
endif()


# Testing Executable
# Define the source files and dependencies for the executable
set(SOURCE_FILES
tests/main.cpp
tests/AppEntryTest.cpp
Expand All @@ -70,9 +61,9 @@ set(SOURCE_FILES
AppEntry.cpp
IWindowInterface.cpp
)

# Make the project root directory the working directory when we run
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
add_executable(tests ${SOURCE_FILES})
target_link_libraries(tests gtest gtest_main ${SQLite3_LIBRARIES})
target_include_directories(tests PRIVATE ${SQLite3_INCLUDE_DIRS})
if(UNIX AND NOT APPLE)
target_link_libraries(tests ${X11_LIBRARIES} pthread)
endif()
target_include_directories(tests PRIVATE ${SQLite3_INCLUDE_DIRS})
4 changes: 2 additions & 2 deletions IWindowInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ void WindowsTracker::startTracking()
#endif

#if __linux__
std::string getTrackingScreenLinux(Display* display)
{
std::string getTrackingScreenLinux(Display* display) {
Window window;
char* title = nullptr;
int revert_to_return;
Expand All @@ -115,6 +114,7 @@ std::string getTrackingScreenLinux(Display* display)
XFree(title);
return windowTitle;
}

void LinuxTracker::startTracking()
{
AppEntry prevEntry;
Expand Down

0 comments on commit 70e02cd

Please sign in to comment.