Skip to content

Commit

Permalink
(conan-io#23434) implot: bump imgui for consistency with other packages
Browse files Browse the repository at this point in the history
* implot: don't build and link implot_demo.cpp

* implot: IMGUI_DEFINE_MATH_OPERATORS does not need to be defined since v0.16

* implot: bump imgui versions to latest supported ones

* implot: make v0.14 compatible with imgui/1.90.x

* implot: restore implot_demo.cpp, add a comment

* implot: bump imgui
  • Loading branch information
valgur authored and franramirez688 committed Apr 23, 2024
1 parent c1e8829 commit 8f8443e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
6 changes: 4 additions & 2 deletions recipes/implot/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
cmake_minimum_required(VERSION 3.4)
cmake_minimum_required(VERSION 3.15)
project(implot LANGUAGES CXX)

file(GLOB HEADER_FILES ${IMPLOT_SRC_DIR}/*.h)

add_library(${PROJECT_NAME}
${IMPLOT_SRC_DIR}/implot.cpp
${IMPLOT_SRC_DIR}/implot_items.cpp
# implot_demo.cpp is included so that user can use it to display the main documentation of implot.
# Note that these functions are not declared by the public headers.
# https://github.com/conan-io/conan-center-index/pull/20374
${IMPLOT_SRC_DIR}/implot_demo.cpp
)
target_include_directories(${PROJECT_NAME} PRIVATE ${IMPLOT_SRC_DIR})
Expand All @@ -14,7 +17,6 @@ find_package(imgui CONFIG REQUIRED)

target_link_libraries(${PROJECT_NAME} PUBLIC imgui::imgui)

target_compile_definitions(${PROJECT_NAME} PRIVATE IMGUI_DEFINE_MATH_OPERATORS)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)

Expand Down
21 changes: 15 additions & 6 deletions recipes/implot/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import get, copy
from conan.tools.files import get, copy, replace_in_file
from conan.tools.scm import Version
from conan.tools.microsoft import is_msvc
import os
Expand Down Expand Up @@ -31,17 +31,15 @@ def export_sources(self):

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC # rm_safe not needed
del self.options.fPIC

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def requirements(self):
if Version(self.version) >= "0.15":
self.requires("imgui/1.90", transitive_headers=True)
elif Version(self.version) >= "0.14":
self.requires("imgui/1.89.4", transitive_headers=True)
if Version(self.version) >= "0.14":
self.requires("imgui/1.90.5", transitive_headers=True)
elif Version(self.version) >= "0.13":
# imgui 1.89 renamed ImGuiKeyModFlags_* to ImGuiModFlags_*
self.requires("imgui/1.88", transitive_headers=True)
Expand All @@ -61,11 +59,22 @@ def source(self):
def generate(self):
tc = CMakeToolchain(self)
tc.variables["IMPLOT_SRC_DIR"] = self.source_folder.replace("\\", "/")
if Version(self.version) < "0.16":
# Set in code since v0.16 https://github.com/epezent/implot/commit/33c5a965f55f80057f197257d1d1cdb06523e963
tc.preprocessor_definitions["IMGUI_DEFINE_MATH_OPERATORS"] = ""
tc.generate()
deps = CMakeDeps(self)
deps.generate()

def _patch_sources(self):
if Version(self.version) == "0.14" and Version(self.dependencies["imgui"].ref.version) >= "1.89.7":
# https://github.com/ocornut/imgui/commit/51f564eea6333bae9242f40c983a3e29d119a9c2
replace_in_file(self, os.path.join(self.source_folder, "implot.cpp"),
"ImGuiButtonFlags_AllowItemOverlap",
"ImGuiButtonFlags_AllowOverlap")

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir))
cmake.build()
Expand Down

0 comments on commit 8f8443e

Please sign in to comment.