I have an issue with the new CMake Build Tool. It basically works, but there is a catch.
My CMakeLists.txt file of my SFML-Program looks as follows:
cmake_minimum_required(VERSION 3.10)
project(observer4)
set(CMAKE_CXX_STANDARD 17)
set(SFML_DIR "C:/SFML")
find_package(SFML COMPONENTS graphics window system)
add_executable(observer4 main.cpp )
target_link_libraries(observer4 sfml-graphics sfml-audio)
When run CMake everything works smoothly.
-- Found SFML 2.5.1 in C:/SFML
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Nextcloud/C++/observer4/cmake-build-debug
1. When I compile SFML Source-Code (v.2.5.1.) with CMAKE_BUILD_TYPE set to Debug and put everything to C:/SFML, and copy all newly created dll-files...
sfml-graphics-d-2.dll
sfml-audio-d-2.dll
sfml-network-d-2.dll
sfml-system-d-2.dll
sfml-window-d-2.dll
...to the cmake-build-debug-folder of my SFML-Program where the binary that is compiled in debug-mode will get created, everything works fine; the SFML-Application starts without hassle.
But when i now repeat compiling SFML with CMAKE_BUILD_TYPE set to Release, which adds the corresponding compiled "release-SFML-Files" to C:/SFML, the compilation of the SFML-Program in debug-mode suddenly breaks.
The compilation in debug-mode fails with:
Process finished with exit code -1073741515 (0xC0000135)
In the folder C:/SFML/libs this files resides:
libsfml-audio-d.a
libsfml-graphics-d.a
libsfml-main-d.a
libsfml-network-d.a
libsfml-system-d.a
libsfml-window-d.a
[all release and debug DLL-Files]
libsfml-audio.a
libsfml-graphics.a
libsfml-main.a
libsfml-network.a
libsfml-system.a
libsfml-window.a
I did not touch the debug-dll-files in the cmake-build-debug-folder of my SFML-Program where the binary is being compiled.
When i delete
libsfml-audio.a
libsfml-graphics.a
libsfml-main.a
libsfml-network.a
libsfml-system.a
libsfml-window.a
in C:/SFML/libs, which should be no problem, because i compile the SFML-Application in debug mode, the compiler throws this error:
mingw32-make.exe[2]: *** No rule to make target 'C:/SFML/lib/libsfml-graphics.a', needed by 'observer4.exe'. Stop.
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:75: CMakeFiles/observer4.dir/all] Error 2
mingw32-make.exe: *** [Makefile:83: all] Error 2
Why does the compiler need C:/SFML/lib/libsfml-graphics.a' ? Im compiling in debug-mode...he should rely on C:/SFML/lib/libsfml-graphics-d.a'. Same goes for the other files. when i return libsfml-graphics.a from trash, he asks for libsfml-window.a, when i return the file, he asks for libsfml-system.a etc. until it finally throws
Process finished with exit code -1073741515 (0xC0000135)
when all release-files (libsfml-audio.a, libsfml-graphics.a, etc. are back.
The weirdest thing is:
Process finished with exit code -1073741515 (0xC0000135)
goes away and the SFMl-Program starts when i copy the release-dll-files (sfml-graphics-2.dll, sfml-window-2.dll etc.) to the cmake-build-debug-folder. In fact, i can even delete all the debug-dll-files.
The Application only needs the release-files though i compiled it in debug-mode.
This is default behaviour out of the box which does not occure when i use a FindSFML.cmake file. When using FindSFML.cmake i can have all SFML-files (debug & release) in C:/SFML/libs in one place and just use the debug-dll-files for the debug build and the release-dll-files for my release-build.