Skip to content

FindGLUT: Find debug/release variants on Windows

Kohányi Róbert requested to merge kohanyi.robert/cmake:findglutd-msvc into master
  • Separate find_library calls to find Release and Debug libs.
  • Using select_library_configurations to properly populate required variables (similar to FindZLIB).
  • Setting Release and Debug specific properties (IMPORTED_CONFIGURATIONS_ and IMPORTED_LOCATION_).
  • Falling back to setting just IMPORTED_LOCATION if GLUT_glut_LIBRARY_RELEASE or GLUT_glut_LIBRARY_DEBUG are not defined.

This enables proper linking on Windows

Given a simple CMakeLists.txt like

find_package(glut MODULE REQUIRED) add_executable(a a.c) target_link_libraries(a PRIVATE GLUT::GLUT)

compilation with

cmake --build . --config Release cmake --build . --config Debug

works: freeglut.lib and freeglutd.lib is linked respectively.

Fixes: #17037 (closed)
Topic-rename: FindGLUT-windows-debug

Edited by Brad King

Merge request reports