| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- cmake_minimum_required(VERSION 3.20)
- project(lumacs VERSION 0.1.0 LANGUAGES CXX)
- # C++20 standard
- set(CMAKE_CXX_STANDARD 20)
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
- set(CMAKE_CXX_EXTENSIONS OFF)
- # Export compile commands for clangd/LSP
- set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
- # Build type
- if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE Release)
- endif()
- # Compiler warnings
- if(MSVC)
- add_compile_options(/W4 /WX)
- else()
- add_compile_options(-Wall -Wextra -Wpedantic -Werror)
- endif()
- # Dependencies
- include(FetchContent)
- # ncurses for TUI (better control key support)
- find_package(Curses REQUIRED)
- # GTK4 / gtkmm for GUI
- find_package(PkgConfig REQUIRED)
- pkg_check_modules(GTKMM gtkmm-4.0)
- # Lua and sol2
- find_package(Lua 5.4 REQUIRED)
- # sol2 - use develop branch for latest compatibility fixes
- FetchContent_Declare(
- sol2
- GIT_REPOSITORY https://github.com/ThePhD/sol2.git
- GIT_TAG v3.5.0
- GIT_SHALLOW TRUE
- )
- FetchContent_MakeAvailable(sol2)
- # spdlog
- FetchContent_Declare(
- spdlog
- GIT_REPOSITORY https://github.com/gabime/spdlog.git
- GIT_TAG v1.12.0
- )
- FetchContent_MakeAvailable(spdlog)
- # Google Test
- FetchContent_Declare(
- googletest
- GIT_REPOSITORY https://github.com/google/googletest.git
- GIT_TAG release-1.11.0 # Or a more recent stable release
- )
- # FetchContent_MakeAvailable(googletest) # This is not enough for subdirectories
- FetchContent_GetProperties(googletest) # Get properties to use SOURCE_DIR and BINARY_DIR
- if(NOT googletest_POPULATED)
- FetchContent_Populate(googletest)
- endif()
- add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) # Expose targets to subdirectories
- # Core library (UI-independent)
- add_library(lumacs_core STATIC
- src/buffer.cpp
- src/window.cpp
- src/editor_core.cpp
- src/lua_api.cpp
- src/kill_ring.cpp
- src/theme.cpp
- src/config.cpp
- src/keybinding.cpp
- src/command_system.cpp
- src/modeline.cpp
- src/minibuffer_manager.cpp
- src/completion_system.cpp
- src/buffer_manager.cpp
- src/window_manager.cpp
- src/kill_ring_manager.cpp
- src/register_manager.cpp
- src/macro_manager.cpp
- src/rectangle_manager.cpp
- src/plugin_manager.cpp
- src/logger.cpp
- )
- target_include_directories(lumacs_core PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/include
- ${LUA_INCLUDE_DIR}
- ${sol2_SOURCE_DIR}/include # Explicitly add sol2 include directory
- )
- target_link_libraries(lumacs_core PUBLIC
- sol2::sol2
- spdlog::spdlog
- ${LUA_LIBRARIES}
- ${CURSES_LIBRARIES}
- )
- # Main Executable (Single binary)
- add_executable(lumacs
- src/main.cpp
- src/tui_editor.cpp
- src/gtk_editor.cpp
- src/gtk_renderer.cpp
- src/gtk_completion_popup.cpp
- src/command_system.cpp
- )
- target_link_libraries(lumacs PRIVATE
- lumacs_core
- ${CURSES_LIBRARIES}
- )
- target_include_directories(lumacs PRIVATE
- ${CURSES_INCLUDE_DIR}
- )
- # Configure GTK if available
- if(GTKMM_FOUND)
- message(STATUS "GTKMM 4.0 found - Building with GUI support")
- target_compile_definitions(lumacs PRIVATE LUMACS_WITH_GTK)
- target_include_directories(lumacs PRIVATE ${GTKMM_INCLUDE_DIRS})
- target_link_libraries(lumacs PRIVATE ${GTKMM_LIBRARIES})
- else()
- message(WARNING "GTKMM 4.0 not found - Building TUI only")
- endif()
- # Enable testing
- enable_testing()
- add_subdirectory(tests)
|