diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e034d9d --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt new file mode 100644 index 0000000..ef964d8 --- /dev/null +++ b/vendor/CMakeLists.txt @@ -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) diff --git a/vendor/glew-cmake b/vendor/glew-cmake new file mode 160000 index 0000000..9758219 --- /dev/null +++ b/vendor/glew-cmake @@ -0,0 +1 @@ +Subproject commit 9758219375d923a008feef93c0955931d801740f diff --git a/vendor/glfw b/vendor/glfw new file mode 160000 index 0000000..3eaf125 --- /dev/null +++ b/vendor/glfw @@ -0,0 +1 @@ +Subproject commit 3eaf1255b29fdf5c2895856c7be7d7185ef2b241 diff --git a/vendor/imgui/CMakeLists.txt b/vendor/imgui/CMakeLists.txt new file mode 100644 index 0000000..d8b3ce0 --- /dev/null +++ b/vendor/imgui/CMakeLists.txt @@ -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) + diff --git a/vendor/imgui/imgui b/vendor/imgui/imgui new file mode 160000 index 0000000..37ea320 --- /dev/null +++ b/vendor/imgui/imgui @@ -0,0 +1 @@ +Subproject commit 37ea320b96a4b77581986f5581707021a7be94c9