Skip to content

Fix RelWithDebInfo / MinSizeRel when using find_package(SFML)#3685

Open
Krishnayan-Bhatt wants to merge 1 commit into
SFML:masterfrom
Krishnayan-Bhatt:fix/relwithdebinfo-import-config
Open

Fix RelWithDebInfo / MinSizeRel when using find_package(SFML)#3685
Krishnayan-Bhatt wants to merge 1 commit into
SFML:masterfrom
Krishnayan-Bhatt:fix/relwithdebinfo-import-config

Conversation

@Krishnayan-Bhatt
Copy link
Copy Markdown

@Krishnayan-Bhatt Krishnayan-Bhatt commented Mar 22, 2026

Multi-config generators (e.g. Visual Studio) define RelWithDebInfo and MinSizeRel, but installed SFML package files only declare Debug and Release import locations. Set MAP_IMPORTED_CONFIG_* so those configurations use the Release libraries and avoid incorrect .lib selection and CRT mismatches at runtime.

Fixes #3424

Made-with: Cursor

Description

This PR is related to the issue #

Tasks

  • Tested on Linux
  • Tested on Windows
  • Tested on macOS
  • Tested on iOS
  • Tested on Android

How to test this PR?

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode({1280, 720}), "Minimal, complete and verifiable example");
    window.setFramerateLimit(60);

    while (window.isOpen())
    {
        while (const std::optional event = window.pollEvent())
        {
            if (event->is<sf::Event::Closed>())
                window.close();
        }

        window.clear();
        window.display();
    }
}

Multi-config generators (e.g. Visual Studio) define RelWithDebInfo and MinSizeRel, but installed SFML package files only declare Debug and Release import locations. Set MAP_IMPORTED_CONFIG_* so those configurations use the Release libraries and avoid incorrect .lib selection and CRT mismatches at runtime.

Fixes SFML#3424

Made-with: Cursor
@eXpl0it3r
Copy link
Copy Markdown
Member

If I understand this correctly, this merely maps MinSizeRel and RelWithDebInfo to Release, but doesn't actually provide the wanted configuration. Is that correct?

@Krishnayan-Bhatt
Copy link
Copy Markdown
Author

Yes. SFML’s installed targets only expose Debug and Release import locations; we don’t build separate MinSizeRel/RelWithDebInfo SFML libraries. This sets CMake’s MAP_IMPORTED_CONFIG_* so that when a consumer uses those MSVC configurations, they link the Release SFML import libs (correct optimization + CRT pairing) instead of CMake picking the wrong mapping. If we ever shipped distinct RelWithDebInfo SFML binaries, we’d add those to the export; until then, mapping to Release is the intended fix for find_package consumers.

@eXpl0it3r
Copy link
Copy Markdown
Member

What's stopping us from adding proper support for the configurations?

@Krishnayan-Bhatt
Copy link
Copy Markdown
Author

For true proper support, the installed/exported SFML::... targets would need to include RelWithDebInfo and MinSizeRel import locations (i.e. config-specific exported artifacts). Right now the SFML package only declares Debug/Release import locations, so CMake has nothing to bind RelWithDebInfo/MinSizeRel to. Given what’s shipped, mapping RelWithDebInfo/MinSizeRel to Release is the correct fix; adding full support would require building and exporting those extra configurations in the packaging/CI workflow.

@Krishnayan-Bhatt Krishnayan-Bhatt force-pushed the fix/relwithdebinfo-import-config branch from 04b4413 to f55fa1d Compare March 23, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SFML fails to use appropriate .lib files in RelWithDebInfo

2 participants