CMakeLists.txt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. # Core library (UI-independent)
  37. add_library(lumacs_core STATIC
  38. src/buffer.cpp
  39. src/window.cpp
  40. src/editor_core.cpp
  41. src/lua_api.cpp
  42. src/kill_ring.cpp
  43. src/theme.cpp
  44. src/config.cpp
  45. src/keybinding.cpp
  46. src/command_system.cpp
  47. src/modeline.cpp
  48. src/minibuffer_manager.cpp
  49. src/completion_system.cpp
  50. )
  51. target_include_directories(lumacs_core PUBLIC
  52. ${CMAKE_CURRENT_SOURCE_DIR}/include
  53. ${LUA_INCLUDE_DIR}
  54. )
  55. target_link_libraries(lumacs_core PUBLIC
  56. sol2::sol2
  57. ${LUA_LIBRARIES}
  58. )
  59. # Main Executable (Single binary)
  60. add_executable(lumacs
  61. src/main.cpp
  62. src/tui_editor.cpp
  63. src/gtk_editor.cpp
  64. src/gtk_renderer.cpp
  65. src/gtk_window_controller.cpp
  66. )
  67. target_link_libraries(lumacs PRIVATE
  68. lumacs_core
  69. ${CURSES_LIBRARIES}
  70. )
  71. target_include_directories(lumacs PRIVATE
  72. ${CURSES_INCLUDE_DIR}
  73. )
  74. # Configure GTK if available
  75. if(GTKMM_FOUND)
  76. message(STATUS "GTKMM 4.0 found - Building with GUI support")
  77. target_compile_definitions(lumacs PRIVATE LUMACS_WITH_GTK)
  78. target_include_directories(lumacs PRIVATE ${GTKMM_INCLUDE_DIRS})
  79. target_link_libraries(lumacs PRIVATE ${GTKMM_LIBRARIES})
  80. else()
  81. message(WARNING "GTKMM 4.0 not found - Building TUI only")
  82. endif()
  83. # Enable testing
  84. # enable_testing()
  85. # add_subdirectory(tests EXCLUDE_FROM_ALL)