diff --git a/CMake/FindMMESH.cmake b/CMake/FindMMESH.cmake new file mode 100644 index 00000000..e2a714a5 --- /dev/null +++ b/CMake/FindMMESH.cmake @@ -0,0 +1,94 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindMMESH +-------- + +Find the native MMESH includes and library. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``MMESH::MMESH``, if +MMESH has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + MMESH_INCLUDE_DIRS - where to find meshdecimation.h, etc. + MMESH_LIBRARIES - List of libraries when using mmesh. + MMESH_FOUND - True if mmesh found. + +Hints +^^^^^ + +A user may set ``MMESH_ROOT`` to a mmesh installation root to tell this +module where to look. +#]=======================================================================] + +set(_MMESH_SEARCHES) + +# Search MMESH_ROOT first if it is set. +if(MMESH_ROOT) + set(_MMESH_SEARCH_ROOT PATHS ${MMESH_ROOT} NO_DEFAULT_PATH) + list(APPEND _MMESH_SEARCHES _MMESH_SEARCH_ROOT) +endif() + +set(MMESH_NAMES mmesh) + +# Try each search configuration. +foreach(search ${_MMESH_SEARCHES}) + find_path(MMESH_INCLUDE_DIR NAMES meshdecimation.h ${${search}} PATH_SUFFIXES include include/mmesh mmesh) +endforeach() + +# Allow MMESH_LIBRARY to be set manually, as the location of the openNURBS library +if(NOT MMESH_LIBRARY) + foreach(search ${_MMESH_SEARCHES}) + find_library(MMESH_LIBRARY NAMES ${MMESH_NAMES} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) + endforeach() +endif() + +unset(MMESH_NAMES) + +mark_as_advanced(MMESH_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MMESH REQUIRED_VARS MMESH_LIBRARY MMESH_INCLUDE_DIR) + +if(MMESH_FOUND) + set(MMESH_INCLUDE_DIRS ${MMESH_INCLUDE_DIR}) + + if(NOT MMESH_LIBRARIES) + set(MMESH_LIBRARIES ${MMESH_LIBRARY}) + endif() + + if(NOT TARGET MMESH::MMESH) + add_library(MMESH::MMESH UNKNOWN IMPORTED) + set_target_properties(MMESH::MMESH PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MMESH_INCLUDE_DIRS}") + + if(MMESH_LIBRARY_RELEASE) + set_property(TARGET MMESH::MMESH APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(MMESH::MMESH PROPERTIES + IMPORTED_LOCATION_RELEASE "${MMESH_LIBRARY_RELEASE}") + endif() + + if(MMESH_LIBRARY_DEBUG) + set_property(TARGET MMESH::MMESH APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(MMESH::MMESH PROPERTIES + IMPORTED_LOCATION_DEBUG "${MMESH_LIBRARY_DEBUG}") + endif() + + if(NOT MMESH_LIBRARY_RELEASE AND NOT MMESH_LIBRARY_DEBUG) + set_property(TARGET MMESH::MMESH APPEND PROPERTY + IMPORTED_LOCATION "${MMESH_LIBRARY}") + endif() + endif() +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index e9c256a5..8bfcdbcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -639,6 +639,10 @@ add_project(pugixml GROUPS "BRLCAD;APPLESEED") # https://github.com/assimp/assimp add_project(assetimport GROUPS "BRLCAD") +# mmesh - mesh optimization and decimation library +# https://github.com/BRL-CAD/mmesh +add_project(mmesh GROUPS "BRLCAD") + # OpenCV - Open Source Computer Vision Library # http://opencv.org add_project(opencv GROUPS "BRLCAD_EXTRA") diff --git a/mmesh/CMakeLists.txt b/mmesh/CMakeLists.txt new file mode 100644 index 00000000..716bbc69 --- /dev/null +++ b/mmesh/CMakeLists.txt @@ -0,0 +1,50 @@ +cad_enable(MMESH "librt") + +bext_enable(MMESH) + +# Decision made + +if (ENABLE_MMESH) + + git_submodule_init(mmesh src/mmcore.c) + + TargetDeps(MMESH) + + ExternalProject_Add(MMESH_BLD + URL "${CMAKE_CURRENT_SOURCE_DIR}/mmesh" + BUILD_ALWAYS ${EXT_BUILD_ALWAYS} ${LOG_OPTS} + #PATCH_COMMAND ${PATCH_EXECUTABLE};-E;-p1;${PATCH_OPTIONS};-i;${CMAKE_CURRENT_SOURCE_DIR}/mmesh.patch + CMAKE_ARGS + ${BUILD_TYPE_SPECIFIER} + -DBIN_DIR=${BIN_DIR} + -DLIB_DIR=${LIB_DIR} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BUNDLE_INSTALL_PREFIX} + -DCMAKE_INSTALL_LIBDIR:PATH=${LIB_DIR} + -DCMAKE_INSTALL_RPATH=${CMAKE_BUNDLE_INSTALL_PREFIX}/${LIB_DIR} + LOG_CONFIGURE ${EXT_BUILD_QUIET} + LOG_BUILD ${EXT_BUILD_QUIET} + LOG_INSTALL ${EXT_BUILD_QUIET} + LOG_OUTPUT_ON_FAILURE ${EXT_BUILD_QUIET} + STEP_TARGETS install + ) + + TargetInstallDeps(MMESH MMESH_DEPENDS) + + # Copy the license into position in CMAKE_BUNDLE_INSTALL_PREFIX + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/mmesh/LICENSE + ${DOC_LICENSE_DIR}/mmesh.txt + COPYONLY + ) + +endif (ENABLE_MMESH) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + diff --git a/mmesh/mmesh.deps b/mmesh/mmesh.deps new file mode 100644 index 00000000..ecdeab5f --- /dev/null +++ b/mmesh/mmesh.deps @@ -0,0 +1,2 @@ +PATCH +