I think there is a CMake related bug.
When I use SFML, or any other dependency on a project using CMake, I put a version in my project repository and use CMake
Which build CMake for SFML.
The problem is that the current CMake files assume that it's the only project being built.
First error is line 14 of the root SFML CMakeList.txt file:
# include the configuration fileinclude(${CMAKE_SOURCE_DIR}/cmake/Config.cmake
) ${CMAKE_SOURCE_DIR} is the directory of the CMakeLists.txt file that is at the root of the cmake command. So in my case I have:
myproject/CMakeLists.txt
myproject/dependencies/CMakeLists.txt
myproject/dependencies/sfml/*all files in the current V2 branch - I checked out few minutes ago*
So the include cannot find the directory. It shouldn't be relative to the cmake call directory, but to the CMakeFiles.txt being executed directory.
Solution:
NEVER use ${CMAKE_SOURCE_DIR} but use
${CMAKE_CURRENT_SOURCE_DIR} instead.
This problem appear at several places in the CMake files, where what you want is not the current file directory, but the root directory of SFML sources.
To solve this the simplest way (that I use in my projects) is to define exactly where it is, in the root CMakeLists.txt file :
set( SFML_SOURCES_ROOT_DIR
${CMAKE_CURRENT_SOURCE_DIR} ) In the root directory of the library, then use it in all CMake scripts that need a directory relative to that directory.
I made a patch (attached) that does this, apparently fix the problem on CMake generation but I didn't try yet to compile the generated projects because...well, it's late.
I think it should be reviewed with care before admission.
Also, while I'm on the CMake subject:
- why don't you use module paths declaration instead of including modules by hand? I see you do use module paths sometimes, but only in depths of the files. It would have been simpler to set the module dir in the root scripts and then just use modules where you need them. Is there a specific reason for this?
- there is a lot of paths used that should be just the file name, because the file is in the same directory. Is it voluntary?
Maybe it just need some cleanup from CMake litterate people. It took me a full year to get to the level I can understand some CMake organisation patterns that work, but I'm far from being an expert.
[attachment deleted by admin]