Skip to content

Commit

Permalink
Add imgui
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviii06 committed Nov 9, 2023
1 parent 6175ba3 commit cbc4ad4
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "vendor/imgui/imgui"]
path = vendor/imgui/imgui
url = https://github.com/ocornut/imgui.git
[submodule "vendor/glfw"]
path = vendor/glfw
url = https://github.com/glfw/glfw.git
[submodule "vendor/glew-cmake"]
path = vendor/glew-cmake
url = https://github.com/Aviii06/glew-cmake.git
8 changes: 8 additions & 0 deletions vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)

add_subdirectory(glew-cmake)
add_subdirectory(glfw)
add_subdirectory(imgui)
1 change: 1 addition & 0 deletions vendor/glew-cmake
Submodule glew-cmake added at 975821
1 change: 1 addition & 0 deletions vendor/glfw
Submodule glfw added at 3eaf12
53 changes: 53 additions & 0 deletions vendor/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.5)

# Maybe stop from CMAKEing in the wrong place
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Source and build directories cannot be the same. Go use the /build directory.")
endif ()


# Append Wno-error to avoid compiling imgui with Werror; imgui seems to trigger lots of warnings
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error")

# apparently, this stronger command is needed to accomplish the same in Clang
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-everything")
endif ()
endif ()

set(SRCS imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_tables.cpp imgui/imgui_widgets.cpp imgui/imgui_demo.cpp imgui/backends/imgui_impl_glfw.cpp imgui/backends/imgui_impl_opengl3.cpp)

add_library(
imgui
${SRCS}
)

target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
target_include_directories(imgui PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../glfw/include/")
target_include_directories(imgui PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../glad/include/")

target_link_libraries(imgui PRIVATE glfw)

if (APPLE)
# On macOS, get openGL & friends from Frameworks; do not use GLAD at all

add_definitions(-DGLFW_INCLUDE_GLCOREARB)

# NOTE: This code is essentially duplicated here and in polyscope/src/CMakeLists.txt

# Apple is playing hardball and deprecating openGL... we'll cross that bridge when we come to it
# Silence warnings about openGL deprecation
add_definitions(-DGL_SILENCE_DEPRECATION)
find_library(opengl_library OpenGL)
target_link_libraries(imgui PRIVATE ${opengl_library})
else ()
# On Windows/Linux, use the glad openGL loader

add_definitions(-DIMGUI_IMPL_OPENGL_LOADER_GLAD)
target_link_libraries(imgui PRIVATE glad)
endif ()


set_target_properties(imgui PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

1 change: 1 addition & 0 deletions vendor/imgui/imgui
Submodule imgui added at 37ea32

0 comments on commit cbc4ad4

Please sign in to comment.