Skip to content

[imgui-sfml] cmake ... contains: OpenGL::GL but the target was not found ... #44123

@pascal754

Description

@pascal754

Describe the bug

> cmake -B Debug
-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC 19.44.34823.2
-- The CXX compiler identification is MSVC 19.44.34823.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.44.34823/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.44.34823/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 3.0.0 in C:/vcpkg/installed/x64-windows/share/sfml
-- Found SFML 3.0.0 in C:/vcpkg/installed/x64-windows/share/sfml
-- Configuring done (3.8s)
CMake Error at C:/vcpkg/installed/x64-windows/share/imgui-sfml/ImGui-SFMLConfig.cmake:63 (set_target_properties):
  The link interface of target "ImGui-SFML::ImGui-SFML" contains:

    OpenGL::GL

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  C:/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
  CMakeLists.txt:11 (find_package)


-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

Environment

  • OS: Windows 11
  • Compiler: Visual Studio Community 2022 (64-bit) Version 17.14.0 Preview 1.1

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install imgui imgui-sfml sfml
imgui-sfml:x64-windows                            3.0     
imgui:x64-windows                                 1.91.8#4
sfml:x64-windows                                  3.0.0
  1. CMakeLists.txt and the code
cmake_minimum_required(VERSION 3.26)

set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")

# imgui sfml minimal example
project(ex)

set(CMAKE_CXX_STANDARD 23)

find_package(imgui CONFIG REQUIRED)
find_package(ImGui-SFML CONFIG REQUIRED)
find_package(SFML COMPONENTS Graphics CONFIG REQUIRED)

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(
  ${PROJECT_NAME}
  PRIVATE
    imgui::imgui
    ImGui-SFML::ImGui-SFML
    SFML::Graphics
)
#include "imgui.h" // necessary for ImGui::*, imgui-SFML.h doesn't include imgui.h

#include "imgui-SFML.h" // for ImGui::SFML::* functions and SFML-specific overloads

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode({640, 480}), "ImGui + SFML = <3");
    window.setFramerateLimit(60);
    if (!ImGui::SFML::Init(window))
        return -1;

    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    sf::Clock deltaClock;
    while (window.isOpen())
    {
        while (const auto event = window.pollEvent())
        {
            ImGui::SFML::ProcessEvent(window, *event);

            if (event->is<sf::Event::Closed>())
            {
                window.close();
            }
        }

        ImGui::SFML::Update(window, deltaClock.restart());

        ImGui::ShowDemoWindow();

        ImGui::Begin("Hello, world!");
        ImGui::Button("Look at this pretty button");
        ImGui::End();

        window.clear();
        window.draw(shape);
        ImGui::SFML::Render(window);
        window.display();
    }

    ImGui::SFML::Shutdown();
}

Additional context

  • On Linux, the code builds and runs.

Metadata

Metadata

Assignees

Labels

category:port-bugThe issue is with a library, which is something the port should already support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions