Skip to content

Commit a98adf1

Browse files
committed
tweak cmakelists.txt to get wayland working
1 parent 82b2851 commit a98adf1

File tree

5 files changed

+13
-30
lines changed

5 files changed

+13
-30
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
url = https://github.com/wjakob/nanovg_metal
77
[submodule "ext/glfw"]
88
path = ext/glfw
9-
url = https://github.com/wjakob/glfw
9+
url = https://github.com/glfw/glfw
1010
[submodule "ext/nanobind"]
1111
path = ext/nanobind
1212
url = https://github.com/wjakob/nanobind

CMakeLists.txt

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
247238
endif()
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)
304295
elseif (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)
380372
endif()
381373

382-
if (NANOGUI_BUILD_GLFW)
383-
list(APPEND NANOGUI_EXTRA $<TARGET_OBJECTS:glfw_objects>)
384-
endif()
385-
386374
# Compile main NanoGUI library
387375
add_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

docs/compilation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ file as follows (this assumes that ``nanogui`` lives in the directory
7777
add_subdirectory(ext/nanogui)
7878
7979
# For reliability of parallel build, make the NanoGUI targets dependencies
80-
set_property(TARGET glfw glfw_objects nanogui PROPERTY FOLDER "dependencies")
80+
set_property(TARGET glfw nanogui PROPERTY FOLDER "dependencies")
8181
8282
Required Variables Exposed
8383
----------------------------------------------------------------------------------------

ext/glfw

Submodule glfw updated 112 files

src/python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if (NOT NANOGUI_BUILD_SHARED)
33
set_target_properties(nanogui PROPERTIES POSITION_INDEPENDENT_CODE ON)
44

55
if (NANOGUI_BUILD_GLFW)
6-
set_target_properties(glfw_objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
6+
set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON)
77
endif()
88
endif()
99

0 commit comments

Comments
 (0)