Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add imgui 1.74 #625

Merged
merged 8 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions recipes/imgui/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 2.8.11)
project(imgui CXX)

include(conanbuildinfo.cmake)
conan_basic_setup()

if (WIN32 AND MSVC AND BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
Hopobcn marked this conversation as resolved.
Show resolved Hide resolved
endif(WIN32 AND MSVC AND BUILD_SHARED_LIBS)

set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder)
set(MISC_DIR ${SOURCE_DIR}/misc)
set(EXTRA_FONTS_DIR ${MISC_DIR}/fonts)

file(GLOB SOURCE_FILES ${SOURCE_DIR}/*.cpp)
file(GLOB HEADER_FILES ${SOURCE_DIR}/*.h)
file(GLOB EXTRA_FONTS_FILES ${EXTRA_FONTS_DIR}/*.ttf)
if (MSVC)
file(GLOB EXTRA_NATVIS_FILES ${MISC_DIR}/natvis/*.natvis)
endif()

set(BINARY_TO_COMPRESSED_BIN binary_to_compressed_c)

add_executable(${BINARY_TO_COMPRESSED_BIN} ${EXTRA_FONTS_DIR}/binary_to_compressed_c.cpp)

add_library(${PROJECT_NAME} ${SOURCE_FILES})
target_include_directories(${PROJECT_NAME} PRIVATE ${SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC ${CONAN_LIBS})

include(GNUInstallDirs)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${BINARY_TO_COMPRESSED_BIN}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
install(FILES ${EXTRA_FONTS_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/res/fonts
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
if (MSVC)
install(FILES ${EXTRA_NATVIS_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/res/natvis
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
endif()
4 changes: 4 additions & 0 deletions recipes/imgui/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.74":
url: "https://github.com/ocornut/imgui/archive/v1.74.tar.gz"
sha256: "2f5f2b789edb00260aa71f03189da5f21cf4b5617c4fbba709e9fbcfc76a2f1e"
55 changes: 55 additions & 0 deletions recipes/imgui/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import os
from conans import ConanFile, CMake, tools


class IMGUIConan(ConanFile):
name = "imgui"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/ocornut/imgui"
description = "Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies"
topics = ("conan", "imgui", "gui", "graphical")
license = "MIT"

exports_sources = ["CMakeLists.txt"]
generators = "cmake"

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False]
}
default_options = {
"shared": False,
"fPIC": True
}

@property
def _source_subfolder(self):
return "source_subfolder"

def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
cmake = CMake(self)
cmake.configure()
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder)
self.copy(pattern="examples/imgui_impl_*", dst="res/bindings", src=self._source_subfolder, keep_path=False)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
10 changes: 10 additions & 0 deletions recipes/imgui/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project(test_package)
cmake_minimum_required(VERSION 2.8.11)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

file(GLOB SOURCE_FILES *.cpp)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
16 changes: 16 additions & 0 deletions recipes/imgui/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from conans import ConanFile, CMake, tools
import os

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
33 changes: 33 additions & 0 deletions recipes/imgui/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <imgui.h>
#include <stdio.h>

int main(int, char**)
{
ImGuiContext* context =ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();

// Build atlas
unsigned char* tex_pixels = NULL;
int tex_w, tex_h;
io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h);

for (int n = 0; n < 50; n++)
{
printf("NewFrame() %d\n", n);
io.DisplaySize = ImVec2(1920, 1080);
io.DeltaTime = 1.0f / 60.0f;
ImGui::NewFrame();

static float f = 0.0f;
ImGui::Text("Hello, world!");
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGui::ShowDemoWindow(NULL);

ImGui::Render();
}

printf("DestroyContext()\n");
ImGui::DestroyContext(context);
return 0;
}
3 changes: 3 additions & 0 deletions recipes/imgui/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.74":
folder: all