diff --git a/ports/v-hacd/CMakeLists.txt b/ports/v-hacd/CMakeLists.txt new file mode 100644 index 0000000000..f4451ecaa8 --- /dev/null +++ b/ports/v-hacd/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/ports/v-hacd/CONTROL b/ports/v-hacd/CONTROL new file mode 100644 index 0000000000..533ea6e097 --- /dev/null +++ b/ports/v-hacd/CONTROL @@ -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 diff --git a/ports/v-hacd/fix-cmake.patch b/ports/v-hacd/fix-cmake.patch new file mode 100644 index 0000000000..17ee4bbeb7 --- /dev/null +++ b/ports/v-hacd/fix-cmake.patch @@ -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 ++ $) ++ ++target_include_directories(vhacd PRIVATE + $ + $ # /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 diff --git a/ports/v-hacd/portfile.cmake b/ports/v-hacd/portfile.cmake new file mode 100644 index 0000000000..3e4cdefa32 --- /dev/null +++ b/ports/v-hacd/portfile.cmake @@ -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)