Skip to content

Commit

Permalink
Separate include files (#2)
Browse files Browse the repository at this point in the history
* Separate include files
  • Loading branch information
Ciachociech authored Jun 28, 2024
1 parent ac9794f commit e1477f7
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 63 deletions.
63 changes: 14 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,25 @@ option(IMGUI_USE_DARK_THEME "Use Dark ImGui Spectrum Theme" OFF)
option(IMGUI_DEFINE_MATH_OPERATORS "Enable ImGui ImVec2/ImVec4 operators" OFF)
option(IMGUI_BUILD_EXAMPLES "" OFF)

add_library(imgui
"${imgui_SOURCE_DIR}/imconfig.h"
"${imgui_SOURCE_DIR}/imgui.h"
"${imgui_SOURCE_DIR}/imgui.cpp"
"${imgui_SOURCE_DIR}/imgui_demo.cpp"
"${imgui_SOURCE_DIR}/imgui_draw.cpp"
"${imgui_SOURCE_DIR}/imgui_internal.h"
"${imgui_SOURCE_DIR}/imgui_tables.cpp"
"${imgui_SOURCE_DIR}/imgui_widgets.cpp"
"${imgui_SOURCE_DIR}/imstb_rectpack.h"
"${imgui_SOURCE_DIR}/imstb_textedit.h"
"${imgui_SOURCE_DIR}/imstb_truetype.h"
"${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.h"
"${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp"
"${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.h"
"${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp"
"${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.h"
"${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp"
add_library(imgui STATIC
imgui.cpp
imgui_demo.cpp
imgui_draw.cpp
imgui_tables.cpp
imgui_widgets.cpp
backends/imgui_impl_glfw.cpp
backends/imgui_impl_opengl3.cpp
)
add_library(imgui::imgui ALIAS imgui)

if(IMGUI_USE_DARK_THEME)
target_compile_definitions(imgui PUBLIC SPECTRUM_USE_DARK_THEME)
endif()
if(IMGUI_DEFINE_MATH_OPERATORS)
target_compile_definitions(imgui PUBLIC IMGUI_DEFINE_MATH_OPERATORS)
endif()
target_compile_definitions(imgui PUBLIC
IMGUI_IMPL_OPENGL_LOADER_GL3W=1
IMGUI_DISABLE_OBSOLETE_FUNCTIONS # to check for obsolete functions
# IMGUI_USER_CONFIG="${PROJECT_SOURCE_DIR}/path/to/imconfig.h" # to use your own imconfig.h
target_include_directories(imgui PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/backends
)
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_compile_features(imgui PUBLIC cxx_std_23)

# the following should go in different files, but we're keeping things here to avoid future conflicts.
if(NOT TARGET glfw)
include(FetchContent)
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG tags/3.3
GIT_SHALLOW TRUE
)

option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
option(GLFW_INSTALL "Generate installation target" OFF)
option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
FetchContent_MakeAvailable(glfw)
endif()
find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)

target_link_libraries(imgui PUBLIC glfw)
target_link_libraries(imgui PUBLIC glfw OpenGL::GL)

if(IMGUI_BUILD_EXAMPLES)
add_executable(imgui_example
Expand Down
2 changes: 1 addition & 1 deletion examples/example_glfw_opengl3/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp

#include "imgui.h"
#include "include/imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,9 @@ CODE
#define IMGUI_DEFINE_MATH_OPERATORS
#endif

#include "imgui.h"
#include "include/imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_internal.h"
#include "include/imgui_internal.h"

// System includes
#include <stdio.h> // vsnprintf, sscanf, printf
Expand Down
2 changes: 1 addition & 1 deletion imgui_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Index of this file:
#define _CRT_SECURE_NO_WARNINGS
#endif

#include "imgui.h"
#include "include/imgui.h"
#ifndef IMGUI_DISABLE

// System includes
Expand Down
8 changes: 4 additions & 4 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Index of this file:
#define IMGUI_DEFINE_MATH_OPERATORS
#endif

#include "imgui.h"
#include "include/imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_internal.h"
#include "include/imgui_internal.h"
#ifdef IMGUI_ENABLE_FREETYPE
#include "misc/freetype/imgui_freetype.h"
#endif
Expand Down Expand Up @@ -123,7 +123,7 @@ namespace IMGUI_STB_NAMESPACE
#ifdef IMGUI_STB_RECT_PACK_FILENAME
#include IMGUI_STB_RECT_PACK_FILENAME
#else
#include "imstb_rectpack.h"
#include "include/imstb_rectpack.h"
#endif
#endif

Expand All @@ -147,7 +147,7 @@ namespace IMGUI_STB_NAMESPACE
#ifdef IMGUI_STB_TRUETYPE_FILENAME
#include IMGUI_STB_TRUETYPE_FILENAME
#else
#include "imstb_truetype.h"
#include "include/imstb_truetype.h"
#endif
#endif
#endif // IMGUI_ENABLE_STB_TRUETYPE
Expand Down
4 changes: 2 additions & 2 deletions imgui_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ Index of this file:
#define IMGUI_DEFINE_MATH_OPERATORS
#endif

#include "imgui.h"
#include "include/imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_internal.h"
#include "include/imgui_internal.h"

// System includes
#include <stdint.h> // intptr_t
Expand Down
6 changes: 3 additions & 3 deletions imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Index of this file:
#define IMGUI_DEFINE_MATH_OPERATORS
#endif

#include "imgui.h"
#include "include/imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_internal.h"
#include "include/imgui_internal.h"

// System includes
#include <stdint.h> // intptr_t
Expand Down Expand Up @@ -3863,7 +3863,7 @@ static bool STB_TEXTEDIT_INSERTCHARS(ImGuiInputTextState* obj, int pos, const Im

#define IMSTB_TEXTEDIT_IMPLEMENTATION
#define IMSTB_TEXTEDIT_memmove memmove
#include "imstb_textedit.h"
#include "include/imstb_textedit.h"

// stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling
// the stb_textedit_paste() function creates two separate records, so we perform it manually. (FIXME: Report to nothings/stb?)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion misc/cpp/imgui_stdlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness

#include "imgui.h"
#include "include/imgui.h"
#include "imgui_stdlib.h"

// Clang warnings with -Weverything
Expand Down

0 comments on commit e1477f7

Please sign in to comment.