From 2ad479e667a0dae4e3fe279a0103414c7af7263c Mon Sep 17 00:00:00 2001 From: Lily <47812810+LilyWangL@users.noreply.github.com> Date: Wed, 24 Jun 2020 04:12:14 +0800 Subject: [PATCH] [openmesh] Fix install *.dll and add vcpkg-cmake-wrapper.cmake (#12007) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [openmesh] Fix *.dll export and add vcpkg-cmake-wrapper.cmake * Update ports/openmesh/portfile.cmake Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> --- ports/openmesh/CONTROL | 3 ++- ports/openmesh/portfile.cmake | 33 ++++++++++++++++++------ ports/openmesh/usage | 5 ++++ ports/openmesh/vcpkg-cmake-wrapper.cmake | 18 +++++++++++++ 4 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 ports/openmesh/usage create mode 100644 ports/openmesh/vcpkg-cmake-wrapper.cmake diff --git a/ports/openmesh/CONTROL b/ports/openmesh/CONTROL index d8a61f1f6d79a5..41b01d049760c3 100644 --- a/ports/openmesh/CONTROL +++ b/ports/openmesh/CONTROL @@ -1,3 +1,4 @@ Source: openmesh -Version: 8.0 +Version: 8.0-1 +Homepage: https://www.openmesh.org Description: A generic and efficient polygon mesh data structure diff --git a/ports/openmesh/portfile.cmake b/ports/openmesh/portfile.cmake index 04e624a033b2b6..294c98d91419d0 100644 --- a/ports/openmesh/portfile.cmake +++ b/ports/openmesh/portfile.cmake @@ -1,5 +1,3 @@ -include(vcpkg_common_functions) - set(VERSION 8.0) # Note: upstream GitLab instance at https://graphics.rwth-aachen.de:9000 often goes down @@ -15,14 +13,22 @@ vcpkg_extract_source_archive_ex( REF "${VERSION}" ) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(OPENMESH_BUILD_SHARED ON) +else() + set(OPENMESH_BUILD_SHARED OFF) +endif() + vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA # Disable this option if project cannot be built with Ninja - OPTIONS -DBUILD_APPS=OFF - # [TODO]: add apps as feature, requires qt5 and freeglut - # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2 - # OPTIONS_RELEASE -DOPTIMIZE=1 - # OPTIONS_DEBUG -DDEBUGGABLE=1 + OPTIONS + -DBUILD_APPS=OFF + -DOPENMESH_BUILD_SHARED=${OPENMESH_BUILD_SHARED} + # [TODO]: add apps as feature, requires qt5 and freeglut + # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2 + # OPTIONS_RELEASE -DOPTIMIZE=1 + # OPTIONS_DEBUG -DDEBUGGABLE=1 ) vcpkg_install_cmake() @@ -30,6 +36,17 @@ vcpkg_copy_pdbs() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/OpenMesh/Tools/VDPM/xpm) +# Only move dynamic libraries to bin on Windows +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/bin) + file(RENAME ${CURRENT_PACKAGES_DIR}/OpenMeshCore.dll ${CURRENT_PACKAGES_DIR}/bin/OpenMeshCore.dll) + file(RENAME ${CURRENT_PACKAGES_DIR}/OpenMeshTools.dll ${CURRENT_PACKAGES_DIR}/bin/OpenMeshTools.dll) + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/OpenMeshCored.dll ${CURRENT_PACKAGES_DIR}/debug/bin/OpenMeshCored.dll) + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/OpenMeshToolsd.dll ${CURRENT_PACKAGES_DIR}/debug/bin/OpenMeshToolsd.dll) +endif() +configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY) +file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) # Handle copyright -file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/openmesh RENAME copyright) +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/openmesh/usage b/ports/openmesh/usage new file mode 100644 index 00000000000000..1bfc821f505db2 --- /dev/null +++ b/ports/openmesh/usage @@ -0,0 +1,5 @@ +The package openmesh provides CMake targets: + + find_package(openmesh REQUIRED) + target_include_directories(main PRIVATE ${OPENMESH_INCLUDE_DIRS}) + target_link_libraries(main PRIVATE ${OPENMESH_LIBRARIES}) diff --git a/ports/openmesh/vcpkg-cmake-wrapper.cmake b/ports/openmesh/vcpkg-cmake-wrapper.cmake new file mode 100644 index 00000000000000..ee59349e2e5209 --- /dev/null +++ b/ports/openmesh/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,18 @@ +include(FindPackageHandleStandardArgs) +include(SelectLibraryConfigurations) + +find_path(OPENMESHCORE_INCLUDE_DIR EigenVectorT.hh PATH_SUFFIXES OpenMesh/Core/Geometry) +get_filename_component(OPENMESHCORE_INCLUDE_DIR ${OPENMESHCORE_INCLUDE_DIR} DIRECTORY) +get_filename_component(OPENMESHCORE_INCLUDE_DIR ${OPENMESHCORE_INCLUDE_DIR} DIRECTORY) +get_filename_component(OPENMESHCORE_INCLUDE_DIR ${OPENMESHCORE_INCLUDE_DIR} DIRECTORY) + +find_library(OPENMESHCORE_LIBRARY_DEBUG NAMES OpenMeshCored libOpenMeshCored NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH REQUIRED) +find_library(OPENMESHCORE_LIBRARY_RELEASE NAMES OpenMeshCore libOpenMeshCore NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH REQUIRED) +find_library(OPENMESHTOOLS_LIBRARY_DEBUG NAMES OpenMeshToolsd libOpenMeshToolsd NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH REQUIRED) +find_library(OPENMESHTOOLS_LIBRARY_RELEASE NAMES OpenMeshTools libOpenMeshTools NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH REQUIRED) + +select_library_configurations(OPENMESHCORE) +select_library_configurations(OPENMESHTOOLS) + +set(OPENMESH_INCLUDE_DIRS ${OPENMESHCORE_INCLUDE_DIR}) +set(OPENMESH_LIBRARIES ${OPENMESHCORE_LIBRARY} ${OPENMESHTOOLS_LIBRARY}) \ No newline at end of file