cginternals / globjects

C++ library strictly wrapping OpenGL objects.
https://globjects.org
MIT License
539 stars 58 forks source link

Building globjects with GLM 0.9.9.9 #409

Open pineapplemachine opened 1 year ago

pineapplemachine commented 1 year ago

I had a hell of a time figuring out how to build from source with GLM 0.9.9.9, i.e. latest master of https://github.com/g-truc/glm, which seems to include quite a few new fixes since the 0.9.9.8 release from 2020. I'm documenting the steps I took here for anyone else who is struggling because GLM's glmConfig.cmake keeps moving around. (#402)

These steps are Windows and MinGW specific, because that is how I troubleshooted and tested these steps, but I expect them to apply to other platforms as well with minor changes. (Specifically, by dropping the -G "MinGW Makefiles" in cmake arguments and changing e.g. set "var=path" to export var="path" in the globjects build steps.)

These steps worked for me as of the current latest GLM commit: https://github.com/g-truc/glm/commit/47585fde0c49fa77a2bf2fb1d2ead06999fd4b6e

In these example steps, each git repository was cloned into E:/git. In the steps for downloading and building globjects, change E:/git to wherever you have downloaded and built each dependency.


First, download and build glbinding. In this example I am building latest master for the sake of simplicity, but generally you may want to use a tagged release, e.g. v3.3.0.

git clone https://github.com/cginternals/glbinding
cd glbinding
cmake -S . -B build -G "MinGW Makefiles"
cmake --build build --config Release

Then, setup GLM. It is apparently necessary to build it and then, what was very surprising to me, to install in the build directory. Unfortunately the repository's documentation does not seem to have been updated to reflect this, at least not that I could find:

git clone https://github.com/g-truc/glm
cd glm
cmake -S . -B build -G "MinGW Makefiles"
cmake --build build
cmake --install build --prefix build

Finally, download and build globjects.

git clone https://github.com/cginternals/globjects
cd globjects
set "glbinding_DIR=E:/git/glbinding"
set "glm_DIR=E:/git/glm/build/lib/cmake/glm"
cmake -S . -B build -G "MinGW Makefiles"
cmake --build build
scheibel commented 1 year ago

Thanks for investigating.

I can confirm that the setup for the glmConfig.cmake changed and the following paths works for glm 0.9.9.9:

CMAKE_PREFIX_PATH="<glm_install_root>/"
CMAKE_PREFIX_PATH="<glm_install_root>/.." (if installed in a directory called "glm")
CMAKE_PREFIX_PATH="<glm_install_root>/lib/cmake"
CMAKE_PREFIX_PATH="<glm_install_root>/lib/cmake/glm"

glm_DIR="<glm_install_root>/"
glm_DIR="<glm_install_root>/.." (if installed in a directory called "glm")
glm_DIR="<glm_install_root>/lib/cmake"
glm_DIR="<glm_install_root>/lib/cmake/glm"

To make this test complete, the following paths work for glm 0.9.9.8 and below:

CMAKE_PREFIX_PATH="<glm_source_root>/cmake"
CMAKE_PREFIX_PATH="<glm_source_root>/cmake/glm"

glm_DIR="<glm_source_root>/cmake"
glm_DIR="<glm_source_root>/cmake/glm"

Unfortunately, those path setups are not compatible, i.e., there is no common setup for either CMAKE_PREFIX_PATH or glm_DIR that accommodates for both versions.