mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 10:21:07 +08:00
[v-hacd] Add new port (#11606)
* Add v-hacd * [v-hacd] Fix portfile features * [v-hacd] Only support static linkage * [v-hacd] Fix patchfile * [v-hacd] Remove ARM as a supported platform * [v-hacd] Update ports/v-hacd/portfile.cmake Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com>
This commit is contained in:
parent
2c35ce16bb
commit
cb0e14cadf
19
ports/v-hacd/CMakeLists.txt
Normal file
19
ports/v-hacd/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
|
||||
|
||||
project(VHACD)
|
||||
|
||||
# Determine if VHACD is built as a subproject (using add_subdirectory)
|
||||
# or if it is the master project.
|
||||
set(MASTER_PROJECT OFF)
|
||||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(MASTER_PROJECT ON)
|
||||
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
||||
endif ()
|
||||
|
||||
option(NO_OPENCL "NO_OPENCL" OFF)
|
||||
option(NO_OPENMP "NO_OPENMP" OFF)
|
||||
|
||||
message("NO_OPENCL " ${NO_OPENCL})
|
||||
message("NO_OPENMP " ${NO_OPENMP})
|
||||
|
||||
add_subdirectory(src)
|
12
ports/v-hacd/CONTROL
Normal file
12
ports/v-hacd/CONTROL
Normal file
@ -0,0 +1,12 @@
|
||||
Source: v-hacd
|
||||
Version: 3.2.0
|
||||
Homepage: https://github.com/kmammou/v-hacd
|
||||
Description: The V-HACD library decomposes a 3D surface into a set of "near" convex parts.
|
||||
Supports: !arm
|
||||
|
||||
Feature: opencl
|
||||
Description: Builds opencl enabled lib
|
||||
Build-Depends: opencl
|
||||
|
||||
Feature: openmp
|
||||
Description: Builds openmp enabled lib
|
126
ports/v-hacd/fix-cmake.patch
Normal file
126
ports/v-hacd/fix-cmake.patch
Normal file
@ -0,0 +1,126 @@
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 2bbb283..2f7eb52 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -1,12 +1 @@
|
||||
-cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
|
||||
-project(VHACD)
|
||||
-option(NO_OPENCL "NO_OPENCL" OFF)
|
||||
-option(NO_OPENMP "NO_OPENMP" OFF)
|
||||
-
|
||||
-message("NO_OPENCL " ${NO_OPENCL})
|
||||
-message("NO_OPENMP " ${NO_OPENMP})
|
||||
-
|
||||
-#set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/output" CACHE PATH "project install prefix" FORCE)
|
||||
-set(CMAKE_COMMON_INC "${CMAKE_SOURCE_DIR}/../scripts/cmake_common.cmake")
|
||||
-add_subdirectory ("${CMAKE_SOURCE_DIR}/VHACD_Lib")
|
||||
-add_subdirectory ("${CMAKE_SOURCE_DIR}/test")
|
||||
+add_subdirectory ("${CMAKE_CURRENT_SOURCE_DIR}/VHACD_Lib")
|
||||
\ No newline at end of file
|
||||
diff --git a/src/VHACD_Lib/CMakeLists.txt b/src/VHACD_Lib/CMakeLists.txt
|
||||
index 46fc1b1..2260fdc 100644
|
||||
--- a/src/VHACD_Lib/CMakeLists.txt
|
||||
+++ b/src/VHACD_Lib/CMakeLists.txt
|
||||
@@ -1,34 +1,36 @@
|
||||
+cmake_minimum_required(VERSION 3.10.0)
|
||||
+
|
||||
project(VHACD_LIB CXX C)
|
||||
-include(${CMAKE_COMMON_INC})
|
||||
+include("${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/cmake_common.cmake")
|
||||
+
|
||||
+set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
+set(LIB_TYPE "STATIC" CACHE STRING "STATIC, SHARED or MODULE?")
|
||||
+message("[VHACD] \t LIB_TYPE " ${LIB_TYPE})
|
||||
+add_library(vhacd ${LIB_TYPE} ${PROJECT_CPP_FILES} ${PROJECT_C_FILES} ${PROJECT_INC_FILES} ${PROJECT_INL_FILES} ${PROJECT_CL_FILES})
|
||||
|
||||
if (NOT NO_OPENCL)
|
||||
#include(FindOpenCL OPTIONAL)
|
||||
- find_package(OpenCL)
|
||||
+ find_package(OpenCL REQUIRED)
|
||||
endif()
|
||||
if (NOT NO_OPENMP)
|
||||
#include(FindOpenMP OPTIONAL)
|
||||
- find_package(OpenMP)
|
||||
+ find_package(OpenMP REQUIRED)
|
||||
endif()
|
||||
if(OPENMP_FOUND)
|
||||
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
|
||||
+ target_link_libraries(vhacd PRIVATE OpenMP::OpenMP_CXX)
|
||||
endif()
|
||||
-set(LIB_TYPE "STATIC" CACHE STRING "STATIC, SHARED or MODULE?")
|
||||
-message("[VHACD] \t LIB_TYPE " ${LIB_TYPE})
|
||||
-add_library(vhacd ${LIB_TYPE} ${PROJECT_CPP_FILES} ${PROJECT_C_FILES} ${PROJECT_INC_FILES} ${PROJECT_INL_FILES} ${PROJECT_CL_FILES})
|
||||
|
||||
if (OpenCL_FOUND)
|
||||
- target_include_directories(vhacd PRIVATE "${OpenCL_INCLUDE_DIR}")
|
||||
- target_link_libraries(vhacd PRIVATE "${OpenCL_LIBRARY}")
|
||||
+ target_link_libraries(vhacd PRIVATE OpenCL::OpenCL)
|
||||
target_compile_definitions(vhacd PRIVATE -DOPENCL_FOUND=1 )
|
||||
target_compile_definitions(vhacd PRIVATE -DOPENCL_CL_FILES="${PROJECT_CL_FILES}" )
|
||||
endif()
|
||||
|
||||
-
|
||||
target_include_directories(vhacd PUBLIC
|
||||
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/public/>)
|
||||
+
|
||||
+target_include_directories(vhacd PRIVATE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc/>
|
||||
$<INSTALL_INTERFACE:include/> # <prefix>/include/mylib
|
||||
)
|
||||
@@ -43,32 +45,32 @@ install(FILES ${PROJECT_INL_FILES} DESTINATION include)
|
||||
set(VHACD_LIB_VERSION 3.2.0)
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config-version.cmake"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/vhacd/v-hacd-config-version.cmake"
|
||||
VERSION ${VHACD_LIB_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
-export(EXPORT vhacd-targets NAMESPACE ::
|
||||
- FILE "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-targets.cmake"
|
||||
+export(EXPORT vhacd-targets NAMESPACE vhacd::
|
||||
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/vhacd/v-hacd-targets.cmake"
|
||||
)
|
||||
|
||||
configure_file(cmake/vhacd-config.cmake
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config.cmake"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/vhacd/v-hacd-config.cmake"
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
set(ConfigPackageLocation lib/cmake/vhacd)
|
||||
install(EXPORT vhacd-targets
|
||||
FILE
|
||||
- vhacd-targets.cmake
|
||||
+ v-hacd-targets.cmake
|
||||
DESTINATION
|
||||
${ConfigPackageLocation}
|
||||
- NAMESPACE ::
|
||||
+ NAMESPACE vhacd::
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config.cmake"
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config-version.cmake"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/vhacd/v-hacd-config.cmake"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/vhacd/v-hacd-config-version.cmake"
|
||||
DESTINATION
|
||||
${ConfigPackageLocation}
|
||||
COMPONENT
|
||||
diff --git a/src/VHACD_Lib/cmake/vhacd-config.cmake b/src/VHACD_Lib/cmake/vhacd-config.cmake
|
||||
index 8fc5c58..7677f58 100644
|
||||
--- a/src/VHACD_Lib/cmake/vhacd-config.cmake
|
||||
+++ b/src/VHACD_Lib/cmake/vhacd-config.cmake
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
find_package(OpenCL)
|
||||
find_package(OpenMP)
|
||||
-include("${CMAKE_CURRENT_LIST_DIR}/vhacd-targets.cmake")
|
||||
\ No newline at end of file
|
||||
+include("${CMAKE_CURRENT_LIST_DIR}/v-hacd-targets.cmake")
|
||||
\ No newline at end of file
|
47
ports/v-hacd/portfile.cmake
Normal file
47
ports/v-hacd/portfile.cmake
Normal file
@ -0,0 +1,47 @@
|
||||
vcpkg_fail_port_install(ON_ARCH "arm")
|
||||
|
||||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
|
||||
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO kmammou/v-hacd
|
||||
REF 1a49edf29c69039df15286181f2f27e17ceb9aef
|
||||
SHA512 14157e5fd9cbfeb44735dc2952d7b4f43337ea2243f3b690125dda27e3bb8328cc38050415c7150cf11fbd85c5258c3aaa8899f306ce118f78a4d5e6139ef0f0
|
||||
HEAD_REF master
|
||||
PATCHES
|
||||
fix-cmake.patch
|
||||
)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
||||
|
||||
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
||||
set(LIB_TYPE "SHARED")
|
||||
else()
|
||||
set(LIB_TYPE "STATIC")
|
||||
endif()
|
||||
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
INVERTED_FEATURES
|
||||
openmp NO_OPENMP
|
||||
opencl NO_OPENCL
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
${FEATURE_OPTIONS}
|
||||
-DLIB_TYPE=${LIB_TYPE}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
|
||||
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/vhacd)
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
# Handle copyright
|
||||
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
|
Loading…
x
Reference in New Issue
Block a user