I have a fairly simple SFML project that is also fairly simple in how I build it with CMake.
I use the standard CMake FindPackage command:
find_package(SFML 2.5 COMPONENTS graphics system window REQUIRED)
And then link it to my target:
target_link_libraries(${PROJECT_NAME} PRIVATE
sfml-graphics
sfml-system
sfml-window
)
This work just fine on Linux with the SFML package installed from my package manager and on Windows it also works fine, but only when using the Debug configuration. Building it in release mode like this:
cmake --build . --config Release
Fails to link as there is no Release directory in the prebuilt SFML .zip file I downloaded (64-bit VS 2017). The Debug build works fine since there is indeed a Debug directory where I assume CMake tells the linker to find the required .lib files. As far as I can tell, both the Debug and Release version of the libraries are in the root lib folder of the prebuilt SFML .zip file.
Am I missing something? This seems like the "normal" way to build CMake projects on Windows, but I must admit I'm not very experienced on that platform.
Thanks a lot.
@LucaCiucci
Thanks a lot for your reply.
I think I forgot the most useful information which is, that I was configuring CMake with:
cmake -DSFML_DIR="<path to SFML> <path to my CMakeLists.txt>"
Rereading the forum post where I originally found the instructions (https://en.sfml-dev.org/forums/index.php?topic=24070.0 (https://en.sfml-dev.org/forums/index.php?topic=24070.0)), that was clearly wrong as it states that I should set SFML_DIR to "<sfml root prefix>/lib/cmake/SFML".
Doing so works perfectly with both Debug and Release configurations.
So this was clearly just a mistake on my side, but thankfully I figured it out.
I generally don't think it should be necessary to mess around with environment variables for reasonably well written CMake projects, which SFML thankfully is. But if it works for you, then no reason to change anything of course :-)
Thanks once again. This can definitely be considered solved although I'm still wondering why it almost works when given the wrong path.