Created a .cmake file that retrieves GLFW from the repository

The cmake file downloads GLFW into the project’s build dir, and builds the (static) library, and creates a cmake target for that build. It defaults to installing glfw into ${CMAKE_SOURCE_DIR}/lib but I have the following variables that can be set:

DEPENDENCY_DIR : the default is the ${CMAKE_SOURCE_DIR}/lib does not need a directory ending with glfw, it will already creates that, if it is added it will create a glfw folder inside of a glfw folder

GLFW_VERSION : this is the repository tag, since glfw’s repository’s tags are its versions, I felt that it was appropriate to call it version. The default is master

GLFW_BUILD_TYPE : CMake’s build type when it compiles GLFW, the default is Release

GLFW_CMAKE_ARGS : The CMake args that are passed into the cmake command building glfw, the default options are:
-DGLFW_BUILD_DOCS=OFF
-DGLFW_BUILD_TESTS=OFF
-DGLFW_BUILD_EXAMPLES=OFF
-DCMAKE_INSTALL_PREFIX={GLFW_DIR} (GLFW_DIR is an internal variable, it is set to {DEPENDENCY_DIR}/glfw)

GLFW_LIBRARY_NAME : This one shouldn’t really change unless if cmake’s version changes, or if the developer is using a previous version of glfw. This variable doesn’t change the output name of the library. The default is libglfw3.a

GLFW_GIT_REPOSITORY : The default is https://github.com/glfw/glfw.git

1 Like