forked from AidanSun05/ImGuiTextSelect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
59 lines (51 loc) · 1.57 KB
/
CMakeLists.txt
File metadata and controls
59 lines (51 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright 2024-2025 Aidan Sun and the ImGuiTextSelect contributors
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.15)
project(ImGuiTextSelectExample)
# Set C++ standard and encoding (CMake doesn't directly handle encodings, but this ensures UTF-8)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (MSVC)
add_compile_options(/utf-8)
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(-finput-charset=UTF-8 -fexec-charset=UTF-8)
endif()
# Fetch dependencies (modern CMake approach)
include(FetchContent)
# GLFW
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.3.8
)
FetchContent_MakeAvailable(glfw)
# Dear ImGui
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.92.0
)
FetchContent_MakeAvailable(imgui)
# OpenGL (system library)
find_package(OpenGL REQUIRED)
# Configure ImGui with GLFW + OpenGL3 backend
set(IMGUI_DIR ${imgui_SOURCE_DIR})
file(GLOB IMGUI_SOURCES
"${IMGUI_DIR}/*.cpp"
"${IMGUI_DIR}/backends/imgui_impl_glfw.cpp"
"${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp"
)
add_library(imgui STATIC ${IMGUI_SOURCES})
target_include_directories(imgui PUBLIC
${IMGUI_DIR}
${IMGUI_DIR}/backends
${glfw_SOURCE_DIR}/include
)
target_link_libraries(imgui PUBLIC glfw OpenGL::GL)
# Main executable
add_executable(example
example/main.cpp
textselect.cpp
)
target_include_directories(example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(example PRIVATE imgui)