@@ -220,9 +220,7 @@ if (NANOGUI_BUILD_GLFW)
220220 set (GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
221221 set (GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
222222 set (GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
223- set (GLFW_BUILD_INSTALL OFF CACHE BOOL " " FORCE)
224- set (GLFW_INSTALL OFF CACHE BOOL " " FORCE)
225- set (GLFW_USE_CHDIR OFF CACHE BOOL " " FORCE)
223+ set (GLFW_INSTALL NANOGUI_INSTALL CACHE BOOL " " FORCE) # install GLFW if nanogui install requested
226224 set (BUILD_SHARED_LIBS ${NANOGUI_BUILD_SHARED} CACHE BOOL " " FORCE)
227225
228226 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
@@ -231,18 +229,11 @@ if (NANOGUI_BUILD_GLFW)
231229 endif ()
232230
233231 add_subdirectory (ext /glfw)
234-
235- # Two targets have now been defined: `glfw_objects`, which will be merged into
236- # NanoGUI at the end, and `glfw`. The `glfw` target is the library itself
237- # (e.g., libglfw.so), but can be skipped as we do not need to link against it
238- # (because we merge `glfw_objects` into NanoGUI). Skipping is required for
239- # XCode, but preferable for all build systems (reduces build artifacts).
240- set_target_properties (glfw PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
232+ list (APPEND NANOGUI_LIBS glfw)
241233
242234 mark_as_advanced (
243- GLFW_BUILD_DOCS GLFW_BUILD_EXAMPLES GLFW_BUILD_INSTALL GLFW_BUILD_TESTS
244- GLFW_DOCUMENT_INTERNALS GLFW_INSTALL GLFW_USE_CHDIR GLFW_USE_MENUBAR
245- GLFW_USE_OSMESA GLFW_VULKAN_STATIC GLFW_USE_RETINA GLFW_USE_MIR
235+ GLFW_BUILD_DOCS GLFW_BUILD_EXAMPLES GLFW_BUILD_TESTS
236+ GLFW_INSTALL GLFW_USE_OSMESA GLFW_VULKAN_STATIC
246237 BUILD_SHARED_LIBS USE_MSVC_RUNTIME_LIBRARY_DLL)
247238endif ()
248239
@@ -302,9 +293,10 @@ elseif (APPLE)
302293 list (APPEND NANOGUI_EXTRA src/darwin.mm src/autorelease.mm)
303294 set_property (SOURCE src/autorelease.mm PROPERTY COMPILE_FLAGS -fno-objc-arc)
304295elseif (CMAKE_SYSTEM MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "BSD" )
305- list (APPEND NANOGUI_LIBS X11 pthread)
296+ list (APPEND NANOGUI_LIBS pthread)
306297 if (NANOGUI_BACKEND STREQUAL "OpenGL" )
307- list (APPEND NANOGUI_LIBS GL)
298+ find_package (OpenGL REQUIRED COMPONENTS OpenGL)
299+ list (APPEND NANOGUI_LIBS OpenGL::OpenGL)
308300 elseif (NANOGUI_BACKEND STREQUAL "GLES 2" )
309301 list (APPEND NANOGUI_LIBS GLESv2)
310302 elseif (NANOGUI_BACKEND STREQUAL "GLES 3" )
@@ -379,10 +371,6 @@ if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
379371 add_compile_options (-fobjc-arc)
380372endif ()
381373
382- if (NANOGUI_BUILD_GLFW)
383- list (APPEND NANOGUI_EXTRA $<TARGET_OBJECTS:glfw_objects>)
384- endif ()
385-
386374# Compile main NanoGUI library
387375add_library (nanogui ${NANOGUI_LIBRARY_TYPE}
388376 # Merge NanoVG into the NanoGUI library
@@ -515,11 +503,6 @@ if (NANOGUI_INSTALL)
515503 install (DIRECTORY ext /nanovg/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /nanovg
516504 FILES_MATCHING PATTERN "*.h" )
517505
518- if (NANOGUI_BUILD_GLFW)
519- install (DIRECTORY ext /glfw/include /GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
520- FILES_MATCHING PATTERN "*.h" )
521- endif ()
522-
523506 if (NANOGUI_BUILD_GLAD)
524507 install (DIRECTORY ext /glad/include / DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /glad
525508 FILES_MATCHING PATTERN "*.h" )
@@ -564,10 +547,10 @@ if (NANOGUI_BUILD_EXAMPLES)
564547 add_executable (example4 src/example4.cpp)
565548 add_executable (example_icons src/example_icons.cpp)
566549
567- target_link_libraries (example1 nanogui)
550+ target_link_libraries (example1 nanogui glfw )
568551 target_link_libraries (example2 nanogui)
569552 target_link_libraries (example3 nanogui ${NANOGUI_LIBS} ) # For OpenGL
570- target_link_libraries (example4 nanogui)
553+ target_link_libraries (example4 nanogui glfw )
571554 target_link_libraries (example_icons nanogui)
572555
573556 # Copy icons for example application
0 commit comments