[nanogui] Add new port (#8302)

* [nanogui]Add new port.

* [nanogui]Repatch.

* [nanovg]Update the CONTROL version of the nanovg port.
This commit is contained in:
Alvin 2019-09-27 08:04:10 +08:00 committed by Curtis J Bezault
parent 2e9a0c4173
commit ee0bfad1cf
5 changed files with 105 additions and 2 deletions

5
ports/nanogui/CONTROL Normal file
View File

@ -0,0 +1,5 @@
Source: nanogui
Version: 2019-09-23
Homepage: https://github.com/wjakob/nanogui
Description: NanoGUI is a minimalistic cross-platform widget library for OpenGL 3.x or higher.
Build-Depends: glfw3, nanovg, eigen3

View File

@ -0,0 +1,72 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c59277..3fe6f5d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,11 +11,7 @@ if (POLICY CMP0058)
cmake_policy(SET CMP0058 NEW)
endif()
-if (NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw/src")
- message(FATAL_ERROR "The NanoGUI dependency repositories (GLFW, etc.) are missing! "
- "You probably did not clone the project with --recursive. It is possible to recover "
- "by calling \"git submodule update --init --recursive\"")
-endif()
+
if (WIN32)
set(NANOGUI_USE_GLAD_DEFAULT ON)
@@ -78,13 +74,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
endif()
-add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw" "ext_build/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)
# Python support: add NANOGUI_PYTHON flag to all targets
if (NANOGUI_BUILD_PYTHON)
@@ -310,7 +304,6 @@ add_definitions(${NANOGUI_EXTRA_DEFS})
# Compile main NanoGUI library
add_library(nanogui-obj OBJECT
# Merge NanoVG into the NanoGUI library
- ext/nanovg/src/nanovg.c
# Merge GLAD into the NanoGUI library (only if needed)
${LIBNANOGUI_EXTRA_SOURCE}
# Fonts etc.
@@ -352,6 +345,11 @@ add_library(nanogui-obj OBJECT
src/serializer.cpp
)
+find_path(EIGEN_INCLUDE_DIR Eigen/Core)
+target_include_directories(nanogui-obj PRIVATE ${EIGEN_INCLUDE_DIR})
+find_path(STB_INCLUDE_DIR stb_image.h)
+target_include_directories(nanogui-obj PRIVATE ${STB_INCLUDE_DIR})
+
# XCode has a serious bug where the XCode project produces an invalid target
# that will not get linked if it consists only of objects from object libraries,
# it will not generate any products (executables, libraries). The only work
@@ -363,15 +361,18 @@ if (CMAKE_GENERATOR STREQUAL Xcode)
add_library(nanogui ${NANOGUI_LIBRARY_TYPE}
${XCODE_DUMMY}
$<TARGET_OBJECTS:nanogui-obj>
- $<TARGET_OBJECTS:glfw_objects>
)
else()
add_library(nanogui ${NANOGUI_LIBRARY_TYPE}
$<TARGET_OBJECTS:nanogui-obj>
- $<TARGET_OBJECTS:glfw_objects>
)
endif()
+find_package(nanovg CONFIG REQUIRED)
+find_package(Eigen3 CONFIG REQUIRED)
+find_package(glfw3 CONFIG REQUIRED)
+target_link_libraries(nanogui glfw nanovg::nanovg Eigen3::Eigen)
+
if (NANOGUI_BUILD_SHARED)
set_property(TARGET nanogui-obj PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()

View File

@ -0,0 +1,26 @@
include(vcpkg_common_functions)
if(VCPKG_TARGET_IS_UWP)
message(FATAL_ERROR "nanogui doesn't support UWP.")
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO wjakob/nanogui
REF e9ec8a1a9861cf578d9c6e85a6420080aa715c03 #Commits on Sep 23, 2019
SHA512 36c93bf977862ced2df4030211e2b83625e60a11fc9fdb6c1f2996bb234758331d3f41a7fbafd25a5bca0239ed9bac9c93446a4a7fac4c5e6d7943af2be3e14a
HEAD_REF master
PATCHES
fix-cmakelists.patch
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
# Handle copyright
file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.11)
project(nanovg C)
set(NANOVG_SOURCES src/nanovg.c)
set(NANOVG_HEADERS src/nanovg.h src/nanovg_gl.h src/nanovg_gl_utils.h)
set(NANOVG_HEADERS src/nanovg.h src/nanovg_gl.h src/nanovg_gl_utils.h src/stb_image.h)
add_library(nanovg STATIC ${NANOVG_SOURCES} ${NANOVG_HEADERS})
set_target_properties(nanovg PROPERTIES PUBLIC_HEADER "${NANOVG_HEADERS}")
target_include_directories(nanovg PRIVATE 3rdparty/nanovg/src)

View File

@ -1,4 +1,4 @@
Source: nanovg
Version: 2019-8-30
Version: 2019-8-30-1
Homepage: https://github.com/memononen/nanovg
Description: NanoVG is small antialiased vector graphics rendering library for OpenGL.