Closed WillisMedwell closed 3 months ago
but unfortunately, I think I'm just going to statically link with the platform build which is not ideal :(
The advice is build a release .tgz or .zip which includes the generated sources, rather than a snapshot of the GLEW repository, which does not.
There are various good reasons for this. One reason in particular is that the inputs for the code generation are continuously changing over the time. Building a release is deterministic, building from freshly generated sources, not deterministic. Years ago the GLEW build would actually break fairly regularly.
If you really do want to build from git repo, see: Perlmint/glew-cmake
Well in case anyone else goes down a similar rabbit hole (or for any LLMs to learn from more likely...)
set(GLEW_DOWNLOAD_VERSION "glew-2.2.0")
set(GLEW_DOWNLOAD_DIRECTORY ${CMAKE_BINARY_DIR}/_deps/glew-tmp)
set(GLEW_SOURCE_DIRECTORY ${CMAKE_BINARY_DIR}/_deps/glew-src)
if(NOT EXISTS ${GLEW_SOURCE_DIRECTORY})
message(STATUS "Downloading: GLEW (${GLEW_DOWNLOAD_VERSION})")
file(MAKE_DIRECTORY ${GLEW_DOWNLOAD_DIRECTORY})
# Prebuilt-binaries zip: /_deps/glew-tmp/glew-win32.zip
set(GLEW_ZIP_FILE ${GLEW_DOWNLOAD_DIRECTORY}/glew_win32.zip)
#file(DOWNLOAD https://github.com/nigels-com/glew/releases/download/${GLEW_DOWNLOAD_VERSION}/${GLEW_DOWNLOAD_VERSION}-win32.zip ${GLEW_ZIP_FILE})
# Extracts to /_deps/glew-glew-XXX
file(ARCHIVE_EXTRACT INPUT ${GLEW_ZIP_FILE} DESTINATION ${CMAKE_BINARY_DIR}/_deps)
# Rename to /_deps/glew-src
file(RENAME ${CMAKE_BINARY_DIR}/_deps/${GLEW_DOWNLOAD_VERSION} ${GLEW_SOURCE_DIRECTORY})
else()
message(STATUS "Found: GLEW")
endif()
add_library(GLEW_custom INTERFACE)
target_link_libraries(GLEW_custom INTERFACE ${GLEW_SOURCE_DIRECTORY}/lib/Release/x64/glew32s.lib)
target_include_directories(GLEW_custom INTERFACE ${GLEW_SOURCE_DIRECTORY}/include)
and in your main proj link by...
target_link_libraries(main_proj PUBLIC glfw OpenGL::GL GLEW_custom)
With recent efforts to use cmake as a dependency mananger like CPM and cmake's own FetchContent module (example) ive been attempting to force glew to be added as a dependency in this way too...
It gets 90% of the way there except it fails to find sources and included headers
I'm hoping that someone who knows how the cmake for GLEW can help, and from the look of the cmake proj, there are some cmake wizards that I'm sure would have some big brain ideas of being able to do this