CMakeLists.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. cmake_minimum_required(VERSION 3.20)
  2. project(lumacs VERSION 0.1.0 LANGUAGES CXX)
  3. # C++20 standard
  4. set(CMAKE_CXX_STANDARD 20)
  5. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  6. set(CMAKE_CXX_EXTENSIONS OFF)
  7. # Export compile commands for clangd/LSP
  8. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  9. # Build type
  10. if(NOT CMAKE_BUILD_TYPE)
  11. set(CMAKE_BUILD_TYPE Release)
  12. endif()
  13. # Compiler warnings
  14. if(MSVC)
  15. add_compile_options(/W4 /WX)
  16. else()
  17. add_compile_options(-Wall -Wextra -Wpedantic -Werror)
  18. endif()
  19. # Dependencies
  20. include(FetchContent)
  21. # ncurses for TUI (better control key support)
  22. find_package(Curses REQUIRED)
  23. # GTK4 / gtkmm for GUI
  24. find_package(PkgConfig REQUIRED)
  25. pkg_check_modules(GTKMM gtkmm-4.0)
  26. # Lua and sol2
  27. find_package(Lua 5.4 REQUIRED)
  28. # sol2 - use develop branch for latest compatibility fixes
  29. FetchContent_Declare(
  30. sol2
  31. GIT_REPOSITORY https://github.com/ThePhD/sol2.git
  32. GIT_TAG v3.5.0
  33. GIT_SHALLOW TRUE
  34. )
  35. FetchContent_MakeAvailable(sol2)
  36. # spdlog
  37. FetchContent_Declare(
  38. spdlog
  39. GIT_REPOSITORY https://github.com/gabime/spdlog.git
  40. GIT_TAG v1.12.0
  41. )
  42. FetchContent_MakeAvailable(spdlog)
  43. # Try to find system GoogleTest first (Nix-shell provided)
  44. find_package(GTest)
  45. if(GTest_FOUND)
  46. message(STATUS "Found system GoogleTest: ${GTest_VERSION}")
  47. # Note: System GTest exports targets as GTest::gtest and GTest::gtest_main
  48. else()
  49. message(STATUS "System GoogleTest not found. Fetching via Git...")
  50. FetchContent_Declare(
  51. googletest
  52. GIT_REPOSITORY https://github.com/google/googletest.git
  53. GIT_TAG v1.15.2 # Keep this updated to prevent the MacOS CMake 4.1 error!
  54. )
  55. FetchContent_MakeAvailable(googletest)
  56. endif()
  57. # Core library (UI-independent)
  58. add_library(lumacs_core STATIC
  59. src/buffer.cpp
  60. src/window.cpp
  61. src/editor_core.cpp
  62. src/lua_api.cpp
  63. src/kill_ring.cpp
  64. src/theme.cpp
  65. src/config.cpp
  66. src/keybinding.cpp
  67. src/command_system.cpp
  68. src/modeline.cpp
  69. src/minibuffer_manager.cpp
  70. src/completion_system.cpp
  71. src/buffer_manager.cpp
  72. src/window_manager.cpp
  73. src/kill_ring_manager.cpp
  74. src/register_manager.cpp
  75. src/macro_manager.cpp
  76. src/rectangle_manager.cpp
  77. src/plugin_manager.cpp
  78. src/logger.cpp
  79. )
  80. target_include_directories(lumacs_core PUBLIC
  81. ${CMAKE_CURRENT_SOURCE_DIR}/include
  82. ${LUA_INCLUDE_DIR}
  83. ${sol2_SOURCE_DIR}/include # Explicitly add sol2 include directory
  84. )
  85. target_link_libraries(lumacs_core PUBLIC
  86. sol2::sol2
  87. spdlog::spdlog
  88. ${LUA_LIBRARIES}
  89. ${CURSES_LIBRARIES}
  90. )
  91. # Main Executable (Single binary)
  92. add_executable(lumacs
  93. src/main.cpp
  94. src/tui_editor.cpp
  95. src/gtk_editor.cpp
  96. src/gtk_renderer.cpp
  97. src/gtk_completion_popup.cpp
  98. src/command_system.cpp
  99. )
  100. target_link_libraries(lumacs PRIVATE
  101. lumacs_core
  102. ${CURSES_LIBRARIES}
  103. )
  104. target_include_directories(lumacs PRIVATE
  105. ${CURSES_INCLUDE_DIR}
  106. )
  107. # Configure GTK if available
  108. if(GTKMM_FOUND)
  109. message(STATUS "GTKMM 4.0 found - Building with GUI support")
  110. target_compile_definitions(lumacs PRIVATE LUMACS_WITH_GTK)
  111. target_include_directories(lumacs PRIVATE ${GTKMM_INCLUDE_DIRS})
  112. target_link_libraries(lumacs PRIVATE ${GTKMM_LIBRARIES})
  113. else()
  114. message(WARNING "GTKMM 4.0 not found - Building TUI only")
  115. endif()
  116. # Enable testing
  117. enable_testing()
  118. add_subdirectory(tests)