SFML community forums

Help => General => Topic started by: Rhubarb on June 23, 2024, 09:06:21 pm

Title: Check if SFML is installed
Post by: Rhubarb on June 23, 2024, 09:06:21 pm
Hello, is there any #ifdef to check if libsfml-dev is installed? Thanks.
Title: Re: Check if SFML is installed
Post by: eXpl0it3r on June 24, 2024, 08:58:09 am
Not really.

If you use CMake to build your application, you could search for it with find_package, which should find it, if it's installed (whatever you definition of "installed" is).
Title: Re: Check if SFML is installed
Post by: Garwin on June 24, 2024, 11:13:20 am
You can use macros not exactly what you ask but still can help you to detect certain header file.
#if __has_include
https://en.cppreference.com/w/cpp/preprocessor/include (https://en.cppreference.com/w/cpp/preprocessor/include)

eg.:
#if __has_include("SFML/System/Vector2.hpp")
    #include <SFML/System/Vector2.hpp>
    #define has_sfVector 1
#else if
    #define has_sfVector 0
#endif // __has_include("SFML/System/Vector2.hpp")


 

Title: Re: Check if SFML is installed
Post by: kojack on June 26, 2024, 08:25:16 pm
I use __has_include for exactly this. My vector maths class checks for SFML, Box2D and Imgui headers to add casting operators if the required headers are present.