Build and install Zep as a library for production applications
Integrating Zep as a CMake library provides the best build performance and is ideal for production applications. This approach builds Zep separately and links it to your project.
CMake config files to ${CMAKE_INSTALL_PREFIX}/lib/cmake/zep/
On Linux/macOS, you may need sudo for the install step if installing to system directories. Alternatively, specify -DCMAKE_INSTALL_PREFIX=/path/to/local to install locally.
cmake_minimum_required(VERSION 3.2)project(MyZepApp)set(CMAKE_CXX_STANDARD 17)set(CMAKE_CXX_STANDARD_REQUIRED ON)# Find the installed Zep packagefind_package(Zep REQUIRED)# Your executableadd_executable(myapp src/main.cpp src/editor_window.cpp)# Link against Zeptarget_link_libraries(myapp PRIVATE Zep::Zep)
That’s it! CMake will automatically:
Find the Zep headers and add them to your include path
cmake_minimum_required(VERSION 3.2)project(ZepExample VERSION 1.0.0)# C++17 required for Zepset(CMAKE_CXX_STANDARD 17)set(CMAKE_CXX_STANDARD_REQUIRED ON)# Find packagesfind_package(Zep REQUIRED)# If using ImGui, you'll also need to find it# find_package(imgui REQUIRED)# Create executableadd_executable(zep_example src/main.cpp)# Link librariestarget_link_libraries(zep_example PRIVATE Zep::Zep # Add your other dependencies (imgui, Qt, etc.))# Optional: Enable warningsif(MSVC) target_compile_options(zep_example PRIVATE /W4)else() target_compile_options(zep_example PRIVATE -Wall -Wextra)endif()
#include <zep/editor.h>#include <zep/mode_vim.h>#include <zep/mode_standard.h>#include <zep/tab_window.h>#include <zep/window.h>// Include your display backend#include <zep/imgui/editor_imgui.h>#include <zep/imgui/display_imgui.h>#include <imgui.h>using namespace Zep;int main(){ // Initialize your windowing/graphics system // ... // Create Zep editor auto pixelScale = NVec2f(1.0f, 1.0f); ZepEditor_ImGui editor("/path/to/config", pixelScale); // Load a file or create a buffer editor.InitWithText("example.cpp", "// Hello, Zep!\n"); // Set editing mode editor.SetGlobalMode(ZepMode_Vim::StaticName()); // or: editor.SetGlobalMode(ZepMode_Standard::StaticName()); // Main loop while (running) { ImGui::NewFrame(); ImGui::Begin("Zep Editor"); // Get the region for the editor auto min = ImGui::GetCursorScreenPos(); auto max = ImGui::GetContentRegionAvail(); // Set display region editor.SetDisplayRegion( NVec2f(min.x, min.y), NVec2f(min.x + max.x, min.y + max.y) ); // Display and handle input editor.Display(); editor.HandleInput(); ImGui::End(); ImGui::Render(); // Present frame... } return 0;}
If you prefer not to install Zep system-wide, you can add it as a submodule:
CMakeLists.txt
# Add Zep as a subdirectoryadd_subdirectory(external/zep)# Create your executableadd_executable(myapp src/main.cpp)# Link against Zeptarget_link_libraries(myapp PRIVATE Zep::Zep)
This builds Zep as part of your project without installation.