New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Missing: FREETYPE_LIBRARY #36

Closed
kklouzal opened this Issue Dec 15, 2017 · 18 comments

Comments

3 participants
@kklouzal

kklouzal commented Dec 15, 2017

The cmake script does not currently give the user an input to configure their freetype.lib directory location.
https://i.imgur.com/p0VYrAV.png
It's quite possible I'm doing something wrong here.

@kklouzal

This comment has been minimized.

kklouzal commented Dec 15, 2017

I manually added the FREETYPE_LIBRARY entry in cmake-gui and pointed it to the library directory then had to set bot FREETYPE_INCLUDE_DIR_freetype2 and FREETYPE_INCLUDE_DIR_ft2build to the same directory and it moved to the next step. cmake now wants the directories for all freetype dependencies and that doesn't seem right since it's already compiled.

I'm thinking the freemake cmake script is a little wonky..
https://i.imgur.com/vFItW4O.png

@mosra

This comment has been minimized.

Owner

mosra commented Dec 15, 2017

Hi, can you remove modules/FindFreetype.cmake and try again?

The local copy of the FindFreetype module attempts to detect when the library is built as static and then tries to find all the dependencies as well. But by just briefly looking at it I doubt it ever worked correctly :/ Hopefully the upstream version of FindFreetype that's bundled with CMake behaves better. But even there I'm not sure if it will be able to find everything correctly. What's the value of FREETYPE_LIBRARY you had to manually add?

@mosra

This comment has been minimized.

Owner

mosra commented Dec 15, 2017

By the way, since you are apparently using vcpkg -- do you know about this? https://github.com/microsoft/vcpkg/tree/master/ports/magnum Someone contributed vcpkg packages of Corrade, Magnum and Magnum Plugins a while ago, but they are left pinned to some particular Git revision and not updated since.

@kklouzal

This comment has been minimized.

kklouzal commented Dec 15, 2017

Yes before going down the cmake rabbit-hole here I searched vcpkg for Magnum. For a project this large with so many configuration options I feel it's wise to build it on my own and like you said the vcpkg version uses an older version of Magnum 👎

Should I delete the FindFreetype.cmake file from within cmake? or from within magnum-plugins/modules?

Since you compartmentalize almost every aspect of Magnum I wouldn't mind using the vcpkg version if it built everything, otherwise using cmake is almost needed so you can pick and choose what gets generated. Using vcpkg I could just #include the headers I needed. vcpkg automatically copies over the needed .dll files to your projects working directory so it would be just that easy. One command line issued and bam you've got everything at your fingertips.

@mosra

This comment has been minimized.

Owner

mosra commented Dec 15, 2017

The local one from magnum-plugins, because it has the broken finding of zlib etc. Sorry for not being clear ;)

@kklouzal

This comment has been minimized.

kklouzal commented Dec 15, 2017

I deleted the magnum-plugins/FindFreetype.cmake and the same error appears.

CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.10/Modules/FindFreetype.cmake:157 (find_package_handle_standard_args)
  magnum-plugins/src/MagnumPlugins/FreeTypeFont/CMakeLists.txt:31 (find_package)

It seems like it was using the script within cmake from the beginning then. I did delete the cache to be safe.

To answer your previous question, the value I set for FREETYPE_LIBRARY was simply the path to the lib folder.

@mosra

This comment has been minimized.

Owner

mosra commented Dec 15, 2017

Interesting that the usage file in vcpkg says that it should "just work":

find_package(Freetype REQUIRED)
target_link_libraries(main PRIVATE ${FREETYPE_LIBRARIES})
target_include_directories(main PRIVATE ${FREETYPE_INCLUDE_DIRS})

Hmm. Looking at their docs, are you doing something like this? I think this should make things working.

cmake -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake
@kklouzal

This comment has been minimized.

kklouzal commented Dec 15, 2017

Okay beautiful, specifying the vcpkg toolchain fixed that problem completely and it now automatically populates the SDL2 paths 👍 💯 🥇
https://i.imgur.com/IFXuwGu.png
https://i.imgur.com/x8lQ8DM.png

But now cmake can't find magnum 👎

CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Magnum (missing: Sdl2Application)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  modules/FindMagnum.cmake:692 (find_package_handle_standard_args)
  D:/Documents/Desktop/vcpkg-master/scripts/buildsystems/vcpkg.cmake:159 (_find_package)
  src/CMakeLists.txt:1 (find_package)
@mosra

This comment has been minimized.

Owner

mosra commented Dec 15, 2017

Hmm. Was Magnum built with WITH_SDL2APPLICATION enabled? Otherwise, if you say it found SDL2, then it should also find the Sdl2Application library, if it's installed among all the other libraries.

EDIT: it's also possible that the toolchain messed up with the paths so bad it's now impossible to find libraries outside of vcpkg. But that's just a guess.

@kklouzal

This comment has been minimized.

kklouzal commented Dec 15, 2017

Oh dear, I forgot to check that box! I was so happy about freetype I forgot to select the SDL2APPLICATION hehe
Everything is working now! Thank you sir!

@mosra

This comment has been minimized.

Owner

mosra commented Dec 15, 2017

Awesome :)

Oh, you know what would be great? Having some minimal vcpkg howto in the docs, so others don't have to go through the same pain as you suffered here :) I haven't used vcpkg myself so I can't really write any guide for it, but if you have a time to write a few short notes about it for example here, that would be amazing. Thanks in advance 👍

@kklouzal

This comment has been minimized.

kklouzal commented Dec 15, 2017

I think these instructions will work, it's pretty step-by-step

Using VCPKG with CMake-GUI

VCPKG can be used to automatically download, build, and install project dependencies in a windows environment.

Download VCPKG from their github repository and extract the zip somewhere like C:\VCPKG
https://github.com/Microsoft/vcpkg
Run the bootstrap-vcpkg.bat file then open a PowerShell or CMD window and navigate to C:\VCPKG
run .\vcpkg integrate install
Now you're ready to search for projects
run .\vcpkg search and vcpkg will search for the project in it's database.
If found you can run .\vcpkg install and it will automatically download, compile, and install the project into visual studio.
All you need to do at this point is #include header files. Dll's are automatically copied into your projects working directory, paths are already set, and lib files are already defined. Just #include and you're off to the races!

You may want to use VCPKG to acquire dependencies for Magnum to save yourself time and headaches of gathering and compiling ancillary libraries. Just search for the library to make sure it's available then install it.
.\vcpkg search freetype
.\vcpkg search sdl2
.\vcpkg install freetype
.\vcpkg install sdl2
After VCPKG finnishes building you're ready to open cmake-gui.
After defining the source and build directories you're ready to run Configure.
When you run Configure for the first time you're presented with a window asking you to specify the generator for this project. At the bottom there are 4 radio buttons, make sure to click the radio button for 'Specify toolchain file for cross-compiling'.
This will allow us to tell CMake to use the libraries that VCPKG acquired for us.
Browse and select the following file
"C:\VCPKG\scripts\buildsystems\vcpkg.cmake"
Click finish.
Some amount of time will pass while cmake is configuring.
Go ahead and select all the appropriate build options for your environment once it finishes
Make sure to change "CMAKE_INSTALL_PREFIX" as this is where the "INSTALL" project will copy all .lib/.dll/.h files for you to convientley use in your projects.
Don't forget to select an APPLICATION type like "WITH_SDL2APPLICATION"
Press configure again and if everything went smoothly all the red lines will turn white and you can click Generate.
Ta-Da! You're ready to start using Magnum!
If you find you need more features in the future just acquire their dependencies with VCPKG and follow these steps again!

If I knew how to setup projects for vcpkg I would just fork magnum and make the changes so the entire library could be acquired with vcpkg. Saves a lot of windows users time and headache :P

@mosra mosra added this to TODO in Project management via automation Dec 16, 2017

@mosra mosra moved this from TODO to In Progress in Project management Dec 16, 2017

@ras0219-msft

This comment has been minimized.

ras0219-msft commented Dec 19, 2017

Sorry for potentially hijacking this thread, but we'd love to have a PR updating magnum!

The start is as simple as editing ports\magnum\portfile.cmake and changing the REF[1] to a newer version. Then, simply vcpkg remove magnum and vcpkg install magnum. You'll get a hash error the first time, but just copy-paste the new hash into the file :)

[1] https://github.com/Microsoft/vcpkg/blob/5ac69dd02bef426d71ed1e58923345c9042c37dc/ports/magnum/portfile.cmake#L5

@mosra

This comment has been minimized.

Owner

mosra commented Dec 19, 2017

@ras0219-msft Hey, thanks a lot for your continued effort :)

Unfortunately I have no access to a Windows machine at the moment, so either @kklouzal or maybe @Squareys could do that (thanks in advance!).

Curious: would there be a possibility to have the REF somehow updating itself? Because this project is one of those "get the latest master for best experience" rolling-release libraries and unless someone is periodically refreshing the package, it inevitably gets stale :/ For example, the ArchLinux PKGBUILDs can have an optional pkgver() function that cam fetch the latest Git SHA-1 and uses that instead of the revision hardcoded in the file. Would be great to have something similar in vcpkg.

@ras0219-msft

This comment has been minimized.

ras0219-msft commented Dec 19, 2017

We do have that functionality for some packages (including magnum) via users explicitly passing --head during the install process:

>vcpkg install magnum --head

However, we do not use rolling-release automatically because we believe repeatable builds by default give a better user experience.

Ideally, updates to the stable baseline should be so trivial to do that they wouldn't be a burden to do once every few months. Given no breaking changes, the updates are as simple as changing the REF and SHA512 (which is automatically calculated and displayed to you upon mismatch when running vcpkg install).

@mosra

This comment has been minimized.

Owner

mosra commented Dec 19, 2017

Ah, awesome, very useful to know. Thank you!

@mosra

This comment has been minimized.

Owner

mosra commented Jan 11, 2018

Vcpkg updates were kindly submitted by @jclay in Microsoft/vcpkg#2548, the FindFreetype.cmake was removed in 4de1015 and I'm now onto integrating the vcpkg instructions into the documentation.

Sorry for the terrible delays on my side.

@mosra

This comment has been minimized.

Owner

mosra commented Jan 14, 2018

Documentation for vcpkg done in mosra/magnum@4acb40f. Closing as resolved, sorry for the delays.

@mosra mosra closed this Jan 14, 2018

Project management automation moved this from In Progress to Done Jan 14, 2018

@mosra mosra added this to the 2018.02 milestone Feb 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment