CMakeLists.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 develop
  33. GIT_SHALLOW TRUE
  34. )
  35. FetchContent_MakeAvailable(sol2)
  36. # Google Test
  37. FetchContent_Declare(
  38. googletest
  39. GIT_REPOSITORY https://github.com/google/googletest.git
  40. GIT_TAG release-1.11.0 # Or a more recent stable release
  41. )
  42. # FetchContent_MakeAvailable(googletest) # This is not enough for subdirectories
  43. FetchContent_GetProperties(googletest) # Get properties to use SOURCE_DIR and BINARY_DIR
  44. if(NOT googletest_POPULATED)
  45. FetchContent_Populate(googletest)
  46. endif()
  47. add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) # Expose targets to subdirectories
  48. # Core library (UI-independent)
  49. add_library(lumacs_core STATIC
  50. src/buffer.cpp
  51. src/window.cpp
  52. src/editor_core.cpp
  53. src/lua_api.cpp
  54. src/kill_ring.cpp
  55. src/theme.cpp
  56. src/config.cpp
  57. src/keybinding.cpp
  58. src/command_system.cpp
  59. src/modeline.cpp
  60. src/minibuffer_manager.cpp
  61. src/completion_system.cpp
  62. src/buffer_manager.cpp
  63. src/window_manager.cpp
  64. src/kill_ring_manager.cpp
  65. src/register_manager.cpp
  66. src/macro_manager.cpp
  67. src/rectangle_manager.cpp
  68. src/plugin_manager.cpp
  69. )
  70. target_include_directories(lumacs_core PUBLIC
  71. ${CMAKE_CURRENT_SOURCE_DIR}/include
  72. ${LUA_INCLUDE_DIR}
  73. ${sol2_SOURCE_DIR}/include # Explicitly add sol2 include directory
  74. )
  75. target_link_libraries(lumacs_core PUBLIC
  76. sol2::sol2
  77. ${LUA_LIBRARIES}
  78. ${CURSES_LIBRARIES}
  79. )
  80. # Main Executable (Single binary)
  81. add_executable(lumacs
  82. src/main.cpp
  83. src/tui_editor.cpp
  84. src/gtk_editor.cpp
  85. src/gtk_renderer.cpp
  86. src/gtk_completion_popup.cpp
  87. src/command_system.cpp
  88. )
  89. target_link_libraries(lumacs PRIVATE
  90. lumacs_core
  91. ${CURSES_LIBRARIES}
  92. )
  93. target_include_directories(lumacs PRIVATE
  94. ${CURSES_INCLUDE_DIR}
  95. )
  96. # Configure GTK if available
  97. if(GTKMM_FOUND)
  98. message(STATUS "GTKMM 4.0 found - Building with GUI support")
  99. target_compile_definitions(lumacs PRIVATE LUMACS_WITH_GTK)
  100. target_include_directories(lumacs PRIVATE ${GTKMM_INCLUDE_DIRS})
  101. target_link_libraries(lumacs PRIVATE ${GTKMM_LIBRARIES})
  102. else()
  103. message(WARNING "GTKMM 4.0 not found - Building TUI only")
  104. endif()
  105. # Enable testing
  106. enable_testing()
  107. add_subdirectory(tests)