Merge pull request #303682 from SomeoneSerge/feat/imgui-cmake
imgui: ship vcpkg' (cmake) distribution info
This commit is contained in:
commit
7781c1a927
@ -25,6 +25,8 @@
|
||||
|
||||
## Other Notable Changes {#sec-release-24.11-notable-changes}
|
||||
|
||||
- Create the first release note entry in this section!
|
||||
|
||||
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
||||
|
||||
- To facilitate dependency injection, the `imgui` package now builds a static archive using vcpkg' CMake rules.
|
||||
The derivation now installs "impl" headers selectively instead of by a wildcard.
|
||||
Use `imgui.src` if you just want to access the unpacked sources.
|
||||
|
56
pkgs/by-name/im/imnodes/package.nix
Normal file
56
pkgs/by-name/im/imnodes/package.nix
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
fetchpatch,
|
||||
cmake,
|
||||
imgui,
|
||||
SDL2,
|
||||
xorg,
|
||||
imnodes,
|
||||
withExamples ? false,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "imnodes";
|
||||
version = "unstable-2024-03-12";
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Nelarius";
|
||||
repo = "imnodes";
|
||||
rev = "8563e1655bd9bb1f249e6552cc6274d506ee788b";
|
||||
hash = "sha256-E7NNCxYq9dyVvutWbpl2a+D2Ap2ErvdYHBDqpX0kb0c=";
|
||||
};
|
||||
patches = [
|
||||
# CMake install rules
|
||||
(fetchpatch {
|
||||
url = "https://github.com/Nelarius/imnodes/commit/ff20336fcd82ce07c39fabd76d5bc9fa0a08b3bc.patch";
|
||||
hash = "sha256-JHOUjwMofDwt2kg6SLPFZmuQC4bOfjGa3qHFr5MdPIE=";
|
||||
})
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs =
|
||||
[ imgui ]
|
||||
++ lib.optionals withExamples [
|
||||
SDL2
|
||||
xorg.libXext
|
||||
];
|
||||
|
||||
cmakeFlags = [ (lib.cmakeBool "IMNODES_EXAMPLES" withExamples) ];
|
||||
|
||||
passthru.tests.examples = imnodes.override { withExamples = true; };
|
||||
|
||||
meta = {
|
||||
description = "A small, dependency-free node editor for dear imgui";
|
||||
homepage = "https://github.com/Nelarius/imnodes";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ SomeoneSerge ];
|
||||
mainProgram = "imnodes";
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
}
|
81
pkgs/by-name/im/implot/demos/default.nix
Normal file
81
pkgs/by-name/im/implot/demos/default.nix
Normal file
@ -0,0 +1,81 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
fetchpatch,
|
||||
cmake,
|
||||
pkg-config,
|
||||
darwin,
|
||||
fmt,
|
||||
gtk3,
|
||||
iir1,
|
||||
imgui,
|
||||
imnodes,
|
||||
implot,
|
||||
openssl,
|
||||
curl,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "implot-demos";
|
||||
version = "unstable-2023-08-20";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "epezent";
|
||||
repo = "implot_demos";
|
||||
rev = "f33219d3ade192a2333d4a32e749842010952a29";
|
||||
hash = "sha256-Xq0kVk8qncj/BzQyIX/l1OLvPSQJU8ckTxIIfLZdO/g=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Resolve "undefined symbols" (GetWindowContentRegionWidth &c)
|
||||
(fetchpatch {
|
||||
url = "https://github.com/epezent/implot_demos/commit/85a59612c102f8da97d6ead04f528f4c88f4ef9a.patch";
|
||||
hash = "sha256-HRhfC3TUwz9Mv+1ODabaDxTWUaj4Nx1iH7C6vjUPo2s=";
|
||||
})
|
||||
|
||||
# CMake: make FetchContent optional, add install targets
|
||||
(fetchpatch {
|
||||
url = "https://github.com/epezent/implot_demos/commit/4add0433a46ed5e2099e1af1a77e8055e49230d0.patch";
|
||||
hash = "sha256-jYdM8NuwbZk7INKo2wqMAbjLMTPdrAdM4Kr3xmtquIY=";
|
||||
})
|
||||
|
||||
# CMake: link libGL from the "app" target
|
||||
(fetchpatch {
|
||||
url = "https://github.com/epezent/implot_demos/commit/6742e4202858eb85bd0d67ca5fa15a7a07e6b618.patch";
|
||||
hash = "sha256-h4EJ9u1iHLYkGHgxSynskkuCGmY6mmvKdZSRwHJKerY=";
|
||||
})
|
||||
];
|
||||
|
||||
cmakeFlags = [ (lib.cmakeBool "FETCHCONTENT_FULLY_DISCONNECTED" true) ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
[
|
||||
curl
|
||||
fmt
|
||||
iir1
|
||||
imgui
|
||||
imnodes
|
||||
implot
|
||||
openssl
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [ gtk3 ]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.AppKit ];
|
||||
|
||||
meta = {
|
||||
description = "Standalone ImPlot Demos";
|
||||
homepage = "https://github.com/epezent/implot_demos";
|
||||
broken =
|
||||
stdenv.hostPlatform.isAarch64 # Target "mandel" relies on AVX2
|
||||
|| stdenv.isDarwin;
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ SomeoneSerge ];
|
||||
mainProgram = "implot-demos";
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
}
|
41
pkgs/by-name/im/implot/package.nix
Normal file
41
pkgs/by-name/im/implot/package.nix
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
callPackage,
|
||||
cmake,
|
||||
vcpkg,
|
||||
imgui,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "implot";
|
||||
version = "0.16";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "epezent";
|
||||
repo = "implot";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-/wkVsgz3wiUVZBCgRl2iDD6GWb+AoHN+u0aeqHHgem0=";
|
||||
};
|
||||
|
||||
cmakeRules = "${vcpkg.src}/ports/implot";
|
||||
postPatch = ''
|
||||
cp "$cmakeRules"/CMakeLists.txt ./
|
||||
'';
|
||||
|
||||
buildInputs = [ imgui ];
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
passthru.tests = {
|
||||
implot-demos = callPackage ./demos { };
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Immediate Mode Plotting";
|
||||
homepage = "https://github.com/epezent/implot";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ SomeoneSerge ];
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
}
|
@ -53,6 +53,11 @@ stdenv.mkDerivation rec {
|
||||
--replace "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0"
|
||||
'';
|
||||
|
||||
# glfw may dlopen libwayland-client.so:
|
||||
postFixup = lib.optionalString stdenv.isLinux ''
|
||||
patchelf ''${!outputLib}/lib/libglfw.so --add-rpath ${lib.getLib wayland}/lib
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
|
||||
homepage = "https://www.glfw.org/";
|
||||
|
@ -1,8 +1,67 @@
|
||||
{ stdenv, lib, fetchFromGitHub }:
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
applyPatches,
|
||||
callPackage,
|
||||
cmake,
|
||||
fetchFromGitHub,
|
||||
fetchpatch,
|
||||
darwin,
|
||||
glfw,
|
||||
libGL,
|
||||
SDL2,
|
||||
vcpkg,
|
||||
vulkan-headers,
|
||||
vulkan-loader,
|
||||
|
||||
# The intent is to mirror vcpkg's flags[^1],
|
||||
# but we only actually support Linux and glfw3 until someone contributes the rest
|
||||
# [^1]: https://github.com/microsoft/vcpkg/blob/095ee06e7f60dceef7d713e3f8b1c2eb10d650d7/ports/imgui/CMakeLists.txt#L33-L108
|
||||
IMGUI_BUILD_ALLEGRO5_BINDING ? false,
|
||||
IMGUI_BUILD_ANDROID_BINDING ? stdenv.hostPlatform.isAndroid,
|
||||
IMGUI_BUILD_DX9_BINDING ? false,
|
||||
IMGUI_BUILD_DX10_BINDING ? false,
|
||||
IMGUI_BUILD_DX11_BINDING ? false,
|
||||
IMGUI_BUILD_DX12_BINDING ? false,
|
||||
IMGUI_BUILD_GLFW_BINDING ? !stdenv.isDarwin,
|
||||
IMGUI_BUILD_GLUT_BINDING ? false,
|
||||
IMGUI_BUILD_METAL_BINDING ? stdenv.isDarwin,
|
||||
IMGUI_BUILD_OPENGL2_BINDING ? false,
|
||||
IMGUI_BUILD_OPENGL3_BINDING ?
|
||||
IMGUI_BUILD_SDL2_BINDING || IMGUI_BUILD_GLFW_BINDING || IMGUI_BUILD_GLUT_BINDING,
|
||||
IMGUI_BUILD_OSX_BINDING ? stdenv.isDarwin,
|
||||
IMGUI_BUILD_SDL2_BINDING ?
|
||||
!IMGUI_BUILD_GLFW_BINDING && !stdenv.isDarwin,
|
||||
IMGUI_BUILD_SDL2_RENDERER_BINDING ? IMGUI_BUILD_SDL2_BINDING,
|
||||
IMGUI_BUILD_VULKAN_BINDING ? false,
|
||||
IMGUI_BUILD_WIN32_BINDING ? false,
|
||||
IMGUI_FREETYPE ? false,
|
||||
IMGUI_FREETYPE_LUNASVG ? false,
|
||||
IMGUI_USE_WCHAR32 ? false,
|
||||
}@args:
|
||||
|
||||
let
|
||||
vcpkgSource = applyPatches {
|
||||
inherit (vcpkg) src;
|
||||
patches = [
|
||||
# Install imgui into split outputs:
|
||||
(fetchpatch {
|
||||
url = "https://github.com/microsoft/vcpkg/commit/e91750f08383112e8850f209e55ed2f960181fa6.patch";
|
||||
hash = "sha256-T+DN42PRl2gWGM8zJb9wZEsDl7+XNT6CFypNX3lBHNc=";
|
||||
})
|
||||
];
|
||||
};
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "imgui";
|
||||
version = "1.90.6";
|
||||
outputs = [
|
||||
# Note: no "dev" because vcpkg installs include/ and imgui-config.cmake
|
||||
# into different prefixes but expects the merged layout at import time
|
||||
"out"
|
||||
"lib"
|
||||
];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ocornut";
|
||||
@ -11,22 +70,75 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "sha256-FSob6FPfg0tF0n72twA5/moLvEaB251BPkIDJUXhYbg=";
|
||||
};
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/include/imgui
|
||||
|
||||
cp *.h $out/include/imgui
|
||||
cp *.cpp $out/include/imgui
|
||||
cp -a backends $out/include/imgui/
|
||||
cp -a misc $out/include/imgui/
|
||||
cmakeRules = "${vcpkgSource}/ports/imgui";
|
||||
postPatch = ''
|
||||
cp "$cmakeRules"/{CMakeLists.txt,*.cmake.in} ./
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
darwin.apple_sdk.frameworks.ApplicationServices
|
||||
];
|
||||
|
||||
propagatedBuildInputs =
|
||||
lib.optionals (IMGUI_BUILD_OPENGL2_BINDING || IMGUI_BUILD_OPENGL3_BINDING) [ libGL ]
|
||||
++ lib.optionals IMGUI_BUILD_GLFW_BINDING [ glfw ]
|
||||
++ lib.optionals IMGUI_BUILD_SDL2_BINDING [ SDL2 ]
|
||||
++ lib.optionals IMGUI_BUILD_VULKAN_BINDING [
|
||||
vulkan-headers
|
||||
vulkan-loader
|
||||
]
|
||||
++ lib.optionals IMGUI_BUILD_METAL_BINDING [ darwin.apple_sdk.frameworks.Metal ];
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeBool "IMGUI_BUILD_GLFW_BINDING" IMGUI_BUILD_GLFW_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_ALLEGRO5_BINDING" IMGUI_BUILD_ALLEGRO5_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_ANDROID_BINDING" IMGUI_BUILD_ANDROID_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_DX9_BINDING" IMGUI_BUILD_DX9_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_DX10_BINDING" IMGUI_BUILD_DX10_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_DX11_BINDING" IMGUI_BUILD_DX11_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_DX12_BINDING" IMGUI_BUILD_DX12_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_GLFW_BINDING" IMGUI_BUILD_GLFW_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_GLUT_BINDING" IMGUI_BUILD_GLUT_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_METAL_BINDING" IMGUI_BUILD_METAL_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_OPENGL2_BINDING" IMGUI_BUILD_OPENGL2_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_OPENGL3_BINDING" IMGUI_BUILD_OPENGL3_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_OSX_BINDING" IMGUI_BUILD_OSX_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_SDL2_BINDING" IMGUI_BUILD_SDL2_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_SDL2_RENDERER_BINDING" IMGUI_BUILD_SDL2_RENDERER_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_VULKAN_BINDING" IMGUI_BUILD_VULKAN_BINDING)
|
||||
(lib.cmakeBool "IMGUI_BUILD_WIN32_BINDING" IMGUI_BUILD_WIN32_BINDING)
|
||||
(lib.cmakeBool "IMGUI_FREETYPE" IMGUI_FREETYPE)
|
||||
(lib.cmakeBool "IMGUI_FREETYPE_LUNASVG" IMGUI_FREETYPE_LUNASVG)
|
||||
(lib.cmakeBool "IMGUI_USE_WCHAR32" IMGUI_USE_WCHAR32)
|
||||
];
|
||||
|
||||
passthru = {
|
||||
tests = {
|
||||
demo = callPackage ./demo { };
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
# These flags haven't been tested:
|
||||
broken =
|
||||
IMGUI_FREETYPE
|
||||
|| IMGUI_FREETYPE_LUNASVG
|
||||
|| IMGUI_BUILD_DX9_BINDING
|
||||
|| IMGUI_BUILD_DX10_BINDING
|
||||
|| IMGUI_BUILD_DX11_BINDING
|
||||
|| IMGUI_BUILD_DX12_BINDING
|
||||
|| IMGUI_BUILD_WIN32_BINDING
|
||||
|| IMGUI_BUILD_ALLEGRO5_BINDING
|
||||
|| IMGUI_BUILD_ANDROID_BINDING;
|
||||
description = "Bloat-free Graphical User interface for C++ with minimal dependencies";
|
||||
homepage = "https://github.com/ocornut/imgui";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ wolfangaukang ];
|
||||
platforms = platforms.all;
|
||||
license = lib.licenses.mit; # vcpkg licensed as MIT too
|
||||
maintainers = with lib.maintainers; [
|
||||
SomeoneSerge
|
||||
wolfangaukang
|
||||
];
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
}
|
||||
|
11
pkgs/development/libraries/imgui/demo/CMakeLists.txt
Normal file
11
pkgs/development/libraries/imgui/demo/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
project(ImguiDemo LANGUAGES CXX)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
add_executable(demo ./main.cpp)
|
||||
|
||||
find_package(imgui REQUIRED)
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(demo PRIVATE imgui glfw OpenGL::GL)
|
||||
|
||||
install(TARGETS demo RUNTIME DESTINATION bin)
|
29
pkgs/development/libraries/imgui/demo/default.nix
Normal file
29
pkgs/development/libraries/imgui/demo/default.nix
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
cmake,
|
||||
imgui,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "${imgui.pname}-demo";
|
||||
inherit (imgui) version;
|
||||
|
||||
src = "${imgui.src}/examples/example_glfw_opengl3";
|
||||
postPatch = ''
|
||||
rm Makefile*
|
||||
cp ${./CMakeLists.txt} CMakeLists.txt
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = [ (imgui.override { IMGUI_BUILD_GLFW_BINDING = true; }) ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Standalone ImPlot Demos";
|
||||
homepage = "https://github.com/ocornut/imgui/tree/master/examples/example_glfw_opengl3";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ SomeoneSerge ];
|
||||
mainProgram = "demo";
|
||||
platforms = lib.platforms.linux;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user