CMakeLists.txt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. cmake_minimum_required(VERSION 3.16.0)
  2. set(CMAKE_C_STANDARD 99)
  3. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  4. project(Practice_Timer)
  5. set(G_RESOURCE_DEPENDS ui/settings-window.glade ui/main-window.glade
  6. ui/edit-window.glade ui/mini-window.glade)
  7. set(G_RESOURCE ${CMAKE_CURRENT_SOURCE_DIR}/practicetimer.gresource.xml)
  8. set(G_RESOURCE_C ${CMAKE_CURRENT_SOURCE_DIR}/resources.c)
  9. find_package(PkgConfig REQUIRED)
  10. pkg_check_modules(GTK REQUIRED gtk+-3.0 json-glib-1.0)
  11. add_compile_definitions(PLOTUTILS_FALLBACK_FORMAT="png" PLOTUTILS_PREFERRED_FORMAT="svg" FILE_WATCHER_POLL_RATE=60 APPLICATION_VERSION="2.2.1")
  12. # Uncomment to force a specific path for plotutils
  13. # set(PLOTUTILS_GRAPH_PATH "/path/to/graph")
  14. if(DEFINED PLOTUTILS_GRAPH_PATH)
  15. add_compile_definitions(PLOTUTILS_GRAPH_PATH="${PLOTUTILS_GRAPH_PATH}")
  16. elseif(APPLE)
  17. # Fix issues related to path on macOS
  18. find_program(APPLE_GRAPH_PATH "graph")
  19. if (DEFINED APPLE_GRAPH_PATH)
  20. add_compile_definitions(PLOTUTILS_GRAPH_PATH="${APPLE_GRAPH_PATH}")
  21. else()
  22. add_compile_definitions(PLOTUTILS_GRAPH_PATH="")
  23. endif()
  24. else()
  25. add_compile_definitions(PLOTUTILS_GRAPH_PATH="graph")
  26. endif()
  27. if(APPLE)
  28. add_compile_definitions(IS_APPLE)
  29. endif()
  30. include_directories(${GTK_INCLUDE_DIRS})
  31. link_directories(${GTK_LIBRARY_DIRS})
  32. add_definitions(${GTK_CFLAGS_OTHER} "-Wall")
  33. add_custom_command(OUTPUT ${G_RESOURCE_C} MAIN_DEPENDENCY ${G_RESOURCE} DEPENDS ${G_RESOURCE_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PRE_BUILD COMMAND glib-compile-resources ${G_RESOURCE} --target=${G_RESOURCE_C} --generate-source)
  34. add_custom_target(resource_target DEPENDS ${G_REOSURCE_C})
  35. add_executable(Practice_Timer main.c TimerApplication.c TimerMainWindow.c TimerMiniWindow.c TimerEditWindow.c TimerSettingsWindow.c TimerClock.c TimerTaskTree.c TimerGraphWindow.c TimerGraph.c TimerFileWatcher.c ${G_RESOURCE_C})
  36. set_source_files_properties(${G_RESOURCE_C} PROPERTIES GENERATED TRUE)
  37. add_dependencies(Practice_Timer resource_target)
  38. target_link_libraries(Practice_Timer m ${GTK_LIBRARIES})