Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_package glfw when NANOGUI_BUILD_GLFW=OFF #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ add_library(nanogui ${NANOGUI_LIBRARY_TYPE}
include/nanogui/nanogui.h
)

# Defines various CMAKE_INSTALL_* variables used below in $<INSTALL_INTERFACE>.
if (NANOGUI_INSTALL)
include(GNUInstallDirs)
endif()

target_compile_definitions(nanogui
PUBLIC
${NANOGUI_BACKEND_DEFS}
Expand Down Expand Up @@ -497,6 +502,12 @@ if (EXISTS /opt/vc/include)
target_include_directories(nanogui PUBLIC /opt/vc/include)
endif()

# Find glfw if nanogui is not compiling it internally.
if (NOT NANOGUI_BUILD_GLFW)
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(nanogui PUBLIC glfw)
endif()

if (NANOGUI_INSTALL)
install(TARGETS nanogui
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand All @@ -522,6 +533,7 @@ if (NANOGUI_INSTALL)

set(NANOGUI_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/cmake/nanogui")

include(CMakePackageConfigHelpers)
configure_package_config_file(
resources/nanoguiConfig.cmake.in nanoguiConfig.cmake
INSTALL_DESTINATION ${NANOGUI_CMAKECONFIG_INSTALL_DIR})
Expand Down
7 changes: 7 additions & 0 deletions resources/nanoguiConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ check_required_components(nanogui)

include("${CMAKE_CURRENT_LIST_DIR}/nanoguiTargets.cmake")

# Find glfw if nanogui did not compile it internally.
if (NOT @NANOGUI_BUILD_GLFW@)
include(CMakeFindDependencyMacro)
find_dependency(glfw3 CONFIG)
target_link_libraries(nanogui INTERFACE glfw)
endif()

if(NOT nanogui_FIND_QUIETLY)
message(STATUS "Found nanogui: ${nanogui_INCLUDE_DIR} (found version \"${nanogui_VERSION}\" ${nanogui_VERSION_TYPE})")
endif()
Expand Down