From a98adf1c62cf6e1881a640b984e763d9f3bcc8a3 Mon Sep 17 00:00:00 2001 From: ashpil Date: Tue, 1 Nov 2022 01:22:22 -0400 Subject: [PATCH] tweak cmakelists.txt to get wayland working --- .gitmodules | 2 +- CMakeLists.txt | 35 +++++++++-------------------------- docs/compilation.rst | 2 +- ext/glfw | 2 +- src/python/CMakeLists.txt | 2 +- 5 files changed, 13 insertions(+), 30 deletions(-) diff --git a/.gitmodules b/.gitmodules index 3263a3c9..895e79d2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/wjakob/nanovg_metal [submodule "ext/glfw"] path = ext/glfw - url = https://github.com/wjakob/glfw + url = https://github.com/glfw/glfw [submodule "ext/nanobind"] path = ext/nanobind url = https://github.com/wjakob/nanobind diff --git a/CMakeLists.txt b/CMakeLists.txt index e14c4018..0d7fdea2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,9 +220,7 @@ if (NANOGUI_BUILD_GLFW) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE) set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE) - set(GLFW_BUILD_INSTALL OFF CACHE BOOL " " FORCE) - set(GLFW_INSTALL OFF CACHE BOOL " " FORCE) - set(GLFW_USE_CHDIR OFF CACHE BOOL " " FORCE) + set(GLFW_INSTALL NANOGUI_INSTALL CACHE BOOL " " FORCE) # install GLFW if nanogui install requested set(BUILD_SHARED_LIBS ${NANOGUI_BUILD_SHARED} CACHE BOOL " " FORCE) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -231,18 +229,11 @@ if (NANOGUI_BUILD_GLFW) endif() add_subdirectory(ext/glfw) - - # Two targets have now been defined: `glfw_objects`, which will be merged into - # NanoGUI at the end, and `glfw`. The `glfw` target is the library itself - # (e.g., libglfw.so), but can be skipped as we do not need to link against it - # (because we merge `glfw_objects` into NanoGUI). Skipping is required for - # XCode, but preferable for all build systems (reduces build artifacts). - set_target_properties(glfw PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + list(APPEND NANOGUI_LIBS glfw) mark_as_advanced( - GLFW_BUILD_DOCS GLFW_BUILD_EXAMPLES GLFW_BUILD_INSTALL GLFW_BUILD_TESTS - GLFW_DOCUMENT_INTERNALS GLFW_INSTALL GLFW_USE_CHDIR GLFW_USE_MENUBAR - GLFW_USE_OSMESA GLFW_VULKAN_STATIC GLFW_USE_RETINA GLFW_USE_MIR + GLFW_BUILD_DOCS GLFW_BUILD_EXAMPLES GLFW_BUILD_TESTS + GLFW_INSTALL GLFW_USE_OSMESA GLFW_VULKAN_STATIC BUILD_SHARED_LIBS USE_MSVC_RUNTIME_LIBRARY_DLL) endif() @@ -302,9 +293,10 @@ elseif (APPLE) list(APPEND NANOGUI_EXTRA src/darwin.mm src/autorelease.mm) set_property(SOURCE src/autorelease.mm PROPERTY COMPILE_FLAGS -fno-objc-arc) elseif (CMAKE_SYSTEM MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "BSD") - list(APPEND NANOGUI_LIBS X11 pthread) + list(APPEND NANOGUI_LIBS pthread) if (NANOGUI_BACKEND STREQUAL "OpenGL") - list(APPEND NANOGUI_LIBS GL) + find_package(OpenGL REQUIRED COMPONENTS OpenGL) + list(APPEND NANOGUI_LIBS OpenGL::OpenGL) elseif (NANOGUI_BACKEND STREQUAL "GLES 2") list(APPEND NANOGUI_LIBS GLESv2) elseif (NANOGUI_BACKEND STREQUAL "GLES 3") @@ -379,10 +371,6 @@ if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-fobjc-arc) endif() -if (NANOGUI_BUILD_GLFW) - list(APPEND NANOGUI_EXTRA $) -endif() - # Compile main NanoGUI library add_library(nanogui ${NANOGUI_LIBRARY_TYPE} # Merge NanoVG into the NanoGUI library @@ -515,11 +503,6 @@ if (NANOGUI_INSTALL) install(DIRECTORY ext/nanovg/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nanovg FILES_MATCHING PATTERN "*.h") - if (NANOGUI_BUILD_GLFW) - install(DIRECTORY ext/glfw/include/GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING PATTERN "*.h") - endif() - if (NANOGUI_BUILD_GLAD) install(DIRECTORY ext/glad/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glad FILES_MATCHING PATTERN "*.h") @@ -564,10 +547,10 @@ if (NANOGUI_BUILD_EXAMPLES) add_executable(example4 src/example4.cpp) add_executable(example_icons src/example_icons.cpp) - target_link_libraries(example1 nanogui) + target_link_libraries(example1 nanogui glfw) target_link_libraries(example2 nanogui) target_link_libraries(example3 nanogui ${NANOGUI_LIBS}) # For OpenGL - target_link_libraries(example4 nanogui) + target_link_libraries(example4 nanogui glfw) target_link_libraries(example_icons nanogui) # Copy icons for example application diff --git a/docs/compilation.rst b/docs/compilation.rst index b36db2bf..7720485c 100644 --- a/docs/compilation.rst +++ b/docs/compilation.rst @@ -77,7 +77,7 @@ file as follows (this assumes that ``nanogui`` lives in the directory add_subdirectory(ext/nanogui) # For reliability of parallel build, make the NanoGUI targets dependencies - set_property(TARGET glfw glfw_objects nanogui PROPERTY FOLDER "dependencies") + set_property(TARGET glfw nanogui PROPERTY FOLDER "dependencies") Required Variables Exposed ---------------------------------------------------------------------------------------- diff --git a/ext/glfw b/ext/glfw index e130e55a..7482de60 160000 --- a/ext/glfw +++ b/ext/glfw @@ -1 +1 @@ -Subproject commit e130e55a990998c78fd323f21076e798e0efe8a4 +Subproject commit 7482de6071d21db77a7236155da44c172a7f6c9e diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 4b3fa5b4..77e05ec6 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT NANOGUI_BUILD_SHARED) set_target_properties(nanogui PROPERTIES POSITION_INDEPENDENT_CODE ON) if (NANOGUI_BUILD_GLFW) - set_target_properties(glfw_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() endif()