Closed crjaensch closed 4 years ago
@crjaensch I closed my issue https://github.com/oprypin/crsfml/issues/29 too early. Forgot to try rebuilding VoidCSFML after upgrading. You can try the workaround I detail there.
Here's the old FindSFML.cmake: https://raw.githubusercontent.com/SFML/SFML/5c20c67469e2be17a727bf6cfe3f5672bf50df83/cmake/Modules/FindSFML.cmake
@andrewoconnor I am not sure what you are trying to tell me. Does closing https://github.com/oprypin/crsfml/issues/29 too early mean that it's still not working for you?
As I explained, it's the changed cmake structure and/or content introduced in SFML 2.5.1 that is most likely causing the problem. Unfortunately, I don't know enough about cmake to fix it myself.
As I stated previously, I got around it, by pulling an older SFML homebrew formula from the repo (https://github.com/Homebrew/homebrew-core) and installing that. More specifically, I created a formula file with the filename sfml@2.4.2.rb
and ran that locally using the command: brew install --build-from-source <formula-filename.rb>
.
I would love to install the most recent version of SFML (i.e. 2.5.1), sadly that's not working for me so far.
For the sake of completeness, I am showing the content of sfml@2.4.2.rb
below:
class SfmlAT242 < Formula
# Don't update SFML until there's a corresponding CSFML release
desc "Multi-media library with bindings for multiple languages"
homepage "https://www.sfml-dev.org/"
url "https://www.sfml-dev.org/files/SFML-2.4.2-sources.zip"
sha256 "8ba04f6fde6a7b42527d69742c49da2ac529354f71f553409f9f821d618de4b6"
revision 1
head "https://github.com/SFML/SFML.git"
bottle do
cellar :any
rebuild 1
sha256 "1c5fc7fdb1a59664f2128d309c3a198fffd60cb9f930fbe8ed7f8eb52753250b" => :mojave
sha256 "ed02627dfaff55b60f9271379256d99adfb010df3f4842b0e33fd366eb62df6e" => :high_sierra
sha256 "76c3949dad4b907b87d219f10eb2dae44d43cb76963a083f70935f138832d13c" => :sierra
sha256 "976560145b126bd482696148767f333ceda470d847064a5682abcd5c329937bd" => :el_capitan
sha256 "43dbf56a522f7bce55db7e5354ee0810b7abad63b97178a1ed7a73356c52577c" => :yosemite
end
depends_on "cmake" => :build
depends_on "doxygen" => :build
depends_on "flac"
depends_on "freetype"
depends_on "jpeg"
depends_on "libogg"
depends_on "libvorbis"
# https://github.com/Homebrew/homebrew/issues/40301
def install
# Install pkg-config files, adding the CMake flag below isn't enough, as
# the CMakeLists.txt file currently doesn't consider MacOS X.
# This was fixed upstream for the future 2.5.0 release on 2016-12-19 in:
# https://github.com/SFML/SFML/commit/5fe5e5d6d7792e37685a437551ffa8ed5161fcc1
inreplace "CMakeLists.txt",
"if(SFML_OS_LINUX OR SFML_OS_FREEBSD)",
"if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)"
# Always remove the "extlibs" to avoid install_name_tool failure
# (https://github.com/Homebrew/homebrew/pull/35279) but leave the
# headers that were moved there in https://github.com/SFML/SFML/pull/795
rm_rf Dir["extlibs/*"] - ["extlibs/headers"]
system "cmake", ".", *std_cmake_args,
"-DSFML_INSTALL_PKGCONFIG_FILES=TRUE",
"-DSFML_BUILD_DOC=TRUE"
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include "Time.hpp"
int main() {
sf::Time t1 = sf::milliseconds(10);
return 0;
}
EOS
system ENV.cxx, "-I#{include}/SFML/System", "-L#{lib}", "-lsfml-system",
testpath/"test.cpp", "-o", "test"
system "./test"
end
end
@crjaensch 2.5.1 works for me with the workaround I explain in that issue. You need to recreate the directory structure so that it matches 2.4. This solves the linking issues.
cd /usr/local/opt/sfml/share/sfml
mkdir cmake
cd cmake
ln -s /usr/local/opt/sfml/lib/cmake/SFML Modules
Then drop the FindSFML.cmake I linked above in /usr/local/opt/sfml/lib/cmake/SFML
@andrewoconnor Thanks for the clarification. I will try that :-)
FYI, I added Crystal language support for the QuickLook plugin QLColorCode (https://github.com/anthonygelibert/QLColorCode) and the associated highlight library. Just waiting to get the GitHub pull request / GitLab merge request approved.
I should say, the build on Travis has been consistently failing as well with the good old
Undefined symbols for architecture x86_64:
"sf::Mouse::getPosition(sf::Window const&)", referenced from:
_sfml_mouse_getposition_JRh in window.cpp.o
https://travis-ci.org/oprypin/crsfml/jobs/540323730
But I still don't know what it wants
@oprypin @andrewoconnor @crjaensch I also meet the problem that CrSFML 2.5.1 can't be installed properly on Mac. Should I use the 2.4.2 instead of 2.5.1?
:( I'm still really sad that this doesn't work and I still don't know what to do with it. Sure, I didn't put in nearly enough effort, but yeah...
Yes, you probably can use 2.4.2
I still think this is a problem specifically with Homebrew, so perhaps now that you have all the deps through homebrew, maybe you can make install
"normally".
I have not found any relevant changes in CSFML, which presumably would've needed to adapt here if something really changed. Also not found changes in Homebrew.
So I presume that it (e.g. CSFML) works because std_cmake_args
have been passed all along.
Could someone try supplying these CMake options?
Uhh you'd need to figure out what prefix
means.
I suppose if you don't want to dig through code (but can instead modify Homebrew's code) then you can add a debug output by replacing #{prefix}
with #{puts("!!!", prefix)}
and then installing e.g. CSFML in Homebrew
@oprypin Thank you. But I am still confused about how to install the old version of sfml by homebrew. Do you mean I go to the official website to download 2.4.2 and install ?
No don't do that. Maybe it's not even possible, but you can try to find generic instructions how to install an old version of something with Homebrew.
May be easier to just use the workaround https://github.com/oprypin/crsfml/issues/30#issuecomment-470306277
@oprypin OK, I will have a try!
@oprypin Investigated a little further. With this modification the linking is solved:
https://github.com/andrewoconnor/crsfml/commit/28c9b455af944db7645485e3e2d4dddb30c2a8cb
built with these options:
cmake -DSFML_DIR=/usr/local/opt/sfml/lib/cmake/SFML -DSFML_INCLUDE_DIR=/usr/local/opt/sfml/include . && make
Thanks. The modification isn't supposed to change anything though? It's only removing the indirection of variables, and the only real change is that it removes dependencies. Or are those variables broken?
${SFML_${depend}_LIBRARY}
${SFML_${depend}_DEPENDENCIES}
both these variables seem to be empty when I added some debug messages
Yea OK, your change is perfectly in line with recommendations in https://en.sfml-dev.org/forums/index.php?topic=24070.0
${SFML_LIBRARIES}, ${SFML_DEPENDENCIES} and ${SFML_INCLUDE_DIR} don't exist anymore
This is now mostly automated. The include directory no longer needs to be manually set, so this step can be completely removed. As for the libraries, all you need to specify is the dependencies on the highest level in a dependency tree. Meaning, if you want sfml-graphics, you only need to search for the graphics module and link the sfml-graphics library, CMake will take care of resolving the additionally dependencies like sfml-window or sfml-system. Even for static libraries, you don't need to specify the dependencies as CMake will do it for your.
Mm I just looked into this issue and got a vague recollection that ${SFML_${depend}_DEPENDENCIES}
business doesn't work anymore and that a simpler approach worked.
I did not realize that my memory is actually from @andrewoconnor 's investigation :man_facepalming: -- sorry. Credits to him.
I tried to install CrSFML on a MacBook Pro 2017 running Mac OS Mojave 10.14.3
I followed the installation instructions for Approach 1 described in https://github.com/oprypin/crsfml .
I started with the installation of SFML using homebrew. A week ago that installed SFML 2.4.2 and most recently (a day or two ago) that changed to installing SFML 2.5.1. This change broke everything!!!
It should be noted that the SFML 2.5.1 installation changed significantly, especially regarding the location and content of the cmake Modules.
Homebrew installs SFML 2.4.2 in the following directories:
with the following subdirectories:
Moreover, soft links are created in the following directories:
NOTE: with the SFML 2.4.2 directory setup described above, the CrSFML installation (using Approach 1, i.e. running the command: cmake . && make from the crsfml directory) works just fine :-).
In contrast, when SFML 2.5.1 is installed via homebrew, it seems to break the CrSFML cmake installation procedure. Homebrew install the newest SFML version in the following directories:
with the following subdirectories:
Moreover, soft links are created in the following directories:
In summary, the main differences are: 1) all cmake files are now stored in the lib/cmake/SFML subdirectory of the homebrew cellar. 2) these cmake files are now accessible via soft links via /usr/local/lib/cmake/SFML.
As a consequence, the installation of CrSFML (using Approach 1) fails as follows:
The above error message clearly indicates that a SFML include header is not found and in fact looked up in the wrong directory. In order to fix this, I tried the cmake options explanation provided in: https://github.com/oprypin/crsfml/blob/master/voidcsfml/README.md#cmake-options .
When I ran the following command:
the installation managed to find the SFML header files. But now the installation fails to resolve the location of the SFML dynamic libraries (libsfml-*.dylib). The associated cmd output is shown below:
I finally tried the following command, hoping that explicitly setting the cmake module path might help. But I still get the same message as shown above, i.e. it fails to resolve the SFML library path during linkage.
NOTE: I have no experience with cmake, otherwise I would have fixed this. Obviously, the linkage step fails to resolve the SFML library path and this despite the fact that all libraries are accessible from /usr/local/lib through soft links.
For now, the only way I managed to install CrSFML is using SFML 2.4.2. This wouldn't be half as bad, if homebrew still offered to install a previous version of SFML out-of-the-box. I took me a few hours to finally figure out how to trick homebrew to do so.
I hope you can offer some help on getting CrSFML installed with SFML 2.5.1. Any help is highly appreciated!!!