Skip to content

Commit

Permalink
imgui as lib
Browse files Browse the repository at this point in the history
  • Loading branch information
OphirCarmi committed Sep 13, 2023
1 parent d0e5449 commit a4e5403
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ find_package(OpenGL REQUIRED)
add_subdirectory(3rdparty/clip)
add_subdirectory(3rdparty/protobuf)
add_subdirectory(your_schema)
add_subdirectory(imgui)
add_subdirectory(protobuf-editor)
21 changes: 21 additions & 0 deletions imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.16.0)

project(imgui)

option(DEBUG "Compile with O0" OFF)

include_directories(${CMAKE_BINARY_DIR}/../3rdparty/imgui/)
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/imgui/backends/)
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/imgui/misc/)

file(GLOB SOURCES ${CMAKE_BINARY_DIR}/../3rdparty/imgui/misc/cpp/*.cpp
${CMAKE_BINARY_DIR}/../3rdparty/imgui/backends/imgui_impl_glfw.cpp
${CMAKE_BINARY_DIR}/../3rdparty/imgui/backends/imgui_impl_opengl3.cpp
${CMAKE_BINARY_DIR}/../3rdparty/imgui/*.cpp
)

add_library(${PROJECT_NAME} STATIC ${SOURCES})

target_link_libraries(${PROJECT_NAME} LINK_PUBLIC glfw)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC OpenGL::GL)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${CMAKE_DL_LIBS})
18 changes: 3 additions & 15 deletions protobuf-editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,15 @@ set(PBE_CXX_FLAGS "-Wuseless-cast \
-Wunused-parameter \
-Wshadow \
-Wpedantic \
-Werror \
")
# -Werror \

include_directories(${CMAKE_BINARY_DIR}/../your_schema/)
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/)
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/imgui/)
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/imgui/backends/)
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/imgui/misc/)
# include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/icecream-cpp/)
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/protobuf/src/)
include_directories(${CMAKE_BINARY_DIR}/../3rdparty/protobuf/third_party/abseil-cpp/)

file(GLOB SOURCES *.cpp
../3rdparty/imgui/misc/cpp/*.cpp
../3rdparty/imgui/backends/imgui_impl_glfw.cpp
../3rdparty/imgui/backends/imgui_impl_opengl3.cpp
../3rdparty/imgui/*.cpp
)
file(GLOB SOURCES *.cpp)

if(DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
Expand All @@ -52,9 +42,7 @@ add_executable(${PROJECT_NAME} ${SOURCES})

add_dependencies(${PROJECT_NAME} schema)

target_link_libraries(${PROJECT_NAME} LINK_PUBLIC glfw)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC OpenGL::GL)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${CMAKE_DL_LIBS})
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC libprotobuf)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC clip)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC schema)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC imgui)
2 changes: 1 addition & 1 deletion protobuf-editor/protobuf_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "system.h"

static bool is_not_set(::google::protobuf::Message* msg, const ::google::protobuf::FieldDescriptor* field_desc) {
return !msg->GetReflection()->HasField(*msg, field_desc);
return !field_desc->is_required() && !msg->GetReflection()->HasField(*msg, field_desc);
}

int ProtobufEditor::Init() {
Expand Down

0 comments on commit a4e5403

Please sign in to comment.