Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
260 changes: 134 additions & 126 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,146 +1,154 @@
cmake_minimum_required(VERSION 3.18)
project(PyMeshLab)

# MeshLab directory
set(MESHLAB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/meshlab/src")

# general meshlab build settings that apply also in pymeshlab:
include("${MESHLAB_SRC_DIR}/cmake/meshlab_global_settings.cmake")
set(PYMESHLAB_BUILD_DISTRIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/distrib/pymeshlab)

## Required libraries:
# - OpenGL (ToDo: remove this)
# - Qt5 - OpenGL, Xml
# - Glew (with fallback) (ToDo: remove this)
# - Eigen3 (with fallback)
# - OpenMP (not required)
# - Python
# MeshLab directory
find_package(meshlab CONFIG)
if(TARGET meshlab::meshlab-common)
message(STATUS "- meshlab - using system-provided library")
# Historically, meshlab was float and PyMeshLab double.
# Here, we have no choice and use whatever meshlab was compiled with.
message(WARNING "meshlab system library might be using single precision floats")
else()
set(MESHLAB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/meshlab/src")

find_package(OpenGL REQUIRED)
find_package(
Qt5
COMPONENTS OpenGL Xml Network
REQUIRED)
# general meshlab build settings that apply also in pymeshlab:
include("${MESHLAB_SRC_DIR}/cmake/meshlab_global_settings.cmake")

message(STATUS "Searching for required components with bundled fallback")
## Required libraries:
# - OpenGL (ToDo: remove this)
# - Qt5 - OpenGL, Xml
# - Glew (with fallback) (ToDo: remove this)
# - Eigen3 (with fallback)
# - OpenMP (not required)
# - Python

find_package(GLEW)
find_package(Eigen3 QUIET)
find_package(OpenMP)
find_package(OpenGL REQUIRED)
find_package(
Qt5
COMPONENTS OpenGL Xml Network
REQUIRED)

### Build settings
set(PYMESHLAB_BUILD_DISTRIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/distrib/pymeshlab)
message(STATUS "Searching for required components with bundled fallback")

list(APPEND CMAKE_MODULE_PATH "${MESHLAB_SRC_DIR}/cmake")
add_definitions(-DMESHLAB_SCALAR=double)
set(MESHLAB_BUILD_WITH_DOUBLE_SCALAR ON)
find_package(GLEW)
find_package(Eigen3 QUIET)
find_package(OpenMP)

set(EXTERNAL_DIR ${MESHLAB_SRC_DIR}/external)
### Build settings
list(APPEND CMAKE_MODULE_PATH "${MESHLAB_SRC_DIR}/cmake")
add_definitions(-DMESHLAB_SCALAR=double)
set(MESHLAB_BUILD_WITH_DOUBLE_SCALAR ON)

if (APPLE AND PYMESHLAB_BUILD_DUMMY_BIN_MAC_DEPLOY)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/utilities/dummy_bin_mac_deploy)
endif()
set(EXTERNAL_DIR ${MESHLAB_SRC_DIR}/external)

set(MESHLAB_BUILD_ONLY_LIBRARIES ON)
set(MESHLAB_USE_DEFAULT_BUILD_AND_INSTALL_DIRS OFF)
if (APPLE AND PYMESHLAB_BUILD_DUMMY_BIN_MAC_DEPLOY)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/utilities/dummy_bin_mac_deploy)
endif()

### Build directories
if (NOT PYMESHLAB_BUILD_DUMMY_BIN_MAC_DEPLOY)
set(MESHLAB_BUILD_DISTRIB_DIR ${PYMESHLAB_BUILD_DISTRIB_DIR}/lib)
if (NOT APPLE)
set(MESHLAB_PLUGIN_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/plugins)
set(MESHLAB_BUILD_ONLY_LIBRARIES ON)
set(MESHLAB_USE_DEFAULT_BUILD_AND_INSTALL_DIRS OFF)

### Build directories
if (NOT PYMESHLAB_BUILD_DUMMY_BIN_MAC_DEPLOY)
set(MESHLAB_BUILD_DISTRIB_DIR ${PYMESHLAB_BUILD_DISTRIB_DIR}/lib)
if (NOT APPLE)
set(MESHLAB_PLUGIN_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/plugins)
else()
set(MESHLAB_PLUGIN_OUTPUT_DIR ${PYMESHLAB_BUILD_DISTRIB_DIR}/PlugIns)
endif()
else()
set(MESHLAB_PLUGIN_OUTPUT_DIR ${PYMESHLAB_BUILD_DISTRIB_DIR}/PlugIns)
set(MESHLAB_BUILD_DISTRIB_DIR ${PYMESHLAB_BUILD_DISTRIB_DIR}/dummybin.app/Contents/Frameworks)
set(MESHLAB_PLUGIN_OUTPUT_DIR ${PYMESHLAB_BUILD_DISTRIB_DIR}/dummybin.app/Contents/PlugIns)
endif()
else()
set(MESHLAB_BUILD_DISTRIB_DIR ${PYMESHLAB_BUILD_DISTRIB_DIR}/dummybin.app/Contents/Frameworks)
set(MESHLAB_PLUGIN_OUTPUT_DIR ${PYMESHLAB_BUILD_DISTRIB_DIR}/dummybin.app/Contents/PlugIns)
endif()
set(MESHLAB_LIB_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR})

### Install directories
MESSAGE( STATUS "CMAKE_INSTALL_PREFIX: " ${CMAKE_INSTALL_PREFIX} )

if (WIN32)
set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
set(MESHLAB_PLUGIN_INSTALL_DIR ${MESHLAB_LIB_INSTALL_DIR}/lib/plugins)
elseif(NOT APPLE)
set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(MESHLAB_PLUGIN_INSTALL_DIR ${MESHLAB_LIB_INSTALL_DIR}/plugins)
else(APPLE)
if(PYMESHLAB_BUILD_DUMMY_BIN_MAC_DEPLOY)
set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/dummybin.app/Contents/Frameworks)
set(MESHLAB_PLUGIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/dummybin.app/Contents/PlugIns)
else()
set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/Frameworks)
set(MESHLAB_PLUGIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/PlugIns)
set(MESHLAB_LIB_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR})

### Install directories
MESSAGE( STATUS "CMAKE_INSTALL_PREFIX: " ${CMAKE_INSTALL_PREFIX} )

if (WIN32)
set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
set(MESHLAB_PLUGIN_INSTALL_DIR ${MESHLAB_LIB_INSTALL_DIR}/lib/plugins)
elseif(NOT APPLE)
set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(MESHLAB_PLUGIN_INSTALL_DIR ${MESHLAB_LIB_INSTALL_DIR}/plugins)
else(APPLE)
if(PYMESHLAB_BUILD_DUMMY_BIN_MAC_DEPLOY)
set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/dummybin.app/Contents/Frameworks)
set(MESHLAB_PLUGIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/dummybin.app/Contents/PlugIns)
else()
set(MESHLAB_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/Frameworks)
set(MESHLAB_PLUGIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/PlugIns)
endif()
endif()
endif()

set(MESHLAB_PLUGINS
# IO plugins
meshlabplugins/io_3ds
meshlabplugins/io_3mf
meshlabplugins/io_base
meshlabplugins/io_bre
meshlabplugins/io_collada
meshlabplugins/io_ctm
meshlabplugins/io_e57
meshlabplugins/io_expe
meshlabplugins/io_json
meshlabplugins/io_gltf
meshlabplugins/io_pdb
meshlabplugins/io_tri
meshlabplugins/io_txt
meshlabplugins/io_u3d
meshlabplugins/io_x3d

# Filter plugins
meshlabplugins/filter_sample
meshlabplugins/filter_createiso
meshlabplugins/filter_geodesic
meshlabplugins/filter_sample_gpu
meshlabplugins/filter_ao
meshlabplugins/filter_camera
meshlabplugins/filter_clean
meshlabplugins/filter_color_projection
meshlabplugins/filter_colorproc
meshlabplugins/filter_create
meshlabplugins/filter_cubization
meshlabplugins/filter_developability
meshlabplugins/filter_dirt
meshlabplugins/filter_embree
meshlabplugins/filter_fractal
meshlabplugins/filter_func
meshlabplugins/filter_icp
meshlabplugins/filter_img_patch_param
meshlabplugins/filter_io_nxs
meshlabplugins/filter_isoparametrization
meshlabplugins/filter_layer
meshlabplugins/filter_measure
meshlabplugins/filter_mesh_booleans
meshlabplugins/filter_mesh_alpha_wrap
meshlabplugins/filter_meshing
meshlabplugins/filter_mls
meshlabplugins/filter_mutualglobal
meshlabplugins/filter_mutualinfo
meshlabplugins/filter_parametrization
meshlabplugins/filter_plymc
meshlabplugins/filter_qhull
meshlabplugins/filter_quality
meshlabplugins/filter_sampling
meshlabplugins/filter_screened_poisson
meshlabplugins/filter_sdfgpu
meshlabplugins/filter_select
meshlabplugins/filter_sketchfab
meshlabplugins/filter_ssynth
meshlabplugins/filter_texture
meshlabplugins/filter_texture_defragmentation
meshlabplugins/filter_trioptimize
meshlabplugins/filter_unsharp
meshlabplugins/filter_voronoi
)

add_subdirectory(meshlab)
set(MESHLAB_PLUGINS
# IO plugins
meshlabplugins/io_3ds
meshlabplugins/io_3mf
meshlabplugins/io_base
meshlabplugins/io_bre
meshlabplugins/io_collada
meshlabplugins/io_ctm
meshlabplugins/io_e57
meshlabplugins/io_expe
meshlabplugins/io_json
meshlabplugins/io_gltf
meshlabplugins/io_pdb
meshlabplugins/io_tri
meshlabplugins/io_txt
meshlabplugins/io_u3d
meshlabplugins/io_x3d

# Filter plugins
meshlabplugins/filter_sample
meshlabplugins/filter_createiso
meshlabplugins/filter_geodesic
meshlabplugins/filter_sample_gpu
meshlabplugins/filter_ao
meshlabplugins/filter_camera
meshlabplugins/filter_clean
meshlabplugins/filter_color_projection
meshlabplugins/filter_colorproc
meshlabplugins/filter_create
meshlabplugins/filter_cubization
meshlabplugins/filter_developability
meshlabplugins/filter_dirt
meshlabplugins/filter_embree
meshlabplugins/filter_fractal
meshlabplugins/filter_func
meshlabplugins/filter_icp
meshlabplugins/filter_img_patch_param
meshlabplugins/filter_io_nxs
meshlabplugins/filter_isoparametrization
meshlabplugins/filter_layer
meshlabplugins/filter_measure
meshlabplugins/filter_mesh_booleans
meshlabplugins/filter_mesh_alpha_wrap
meshlabplugins/filter_meshing
meshlabplugins/filter_mls
meshlabplugins/filter_mutualglobal
meshlabplugins/filter_mutualinfo
meshlabplugins/filter_parametrization
meshlabplugins/filter_plymc
meshlabplugins/filter_qhull
meshlabplugins/filter_quality
meshlabplugins/filter_sampling
meshlabplugins/filter_screened_poisson
meshlabplugins/filter_sdfgpu
meshlabplugins/filter_select
meshlabplugins/filter_sketchfab
meshlabplugins/filter_ssynth
meshlabplugins/filter_texture
meshlabplugins/filter_texture_defragmentation
meshlabplugins/filter_trioptimize
meshlabplugins/filter_unsharp
meshlabplugins/filter_voronoi
)

add_subdirectory(meshlab)
endif()


add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pymeshlab)
20 changes: 15 additions & 5 deletions src/pymeshlab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${MESHLAB_SRC_DIR})

#pybind11
add_subdirectory(pybind11)
find_package(pybind11 CONFIG)
if(NOT TARGET pybind11::module)
add_subdirectory(pybind11)
endif()
if ((NOT PYMESHLAB_BUILD_DEBUG) AND (NOT PYMESHLAB_UPDATE_DOC))
pybind11_add_module(${PYMESHLAB_MODULE_NAME} ${HEADERS} ${SOURCES})
endif()
Expand Down Expand Up @@ -126,10 +129,17 @@ if (NOT WIN32 AND NOT APPLE)
endif()

#Qt
target_link_libraries(${PYMESHLAB_MODULE_NAME} PRIVATE Qt5::OpenGL Qt5::Xml external-glew)
target_link_libraries(
${PYMESHLAB_MODULE_NAME}
PUBLIC meshlab-common)
target_link_libraries(${PYMESHLAB_MODULE_NAME} PRIVATE Qt5::OpenGL Qt5::Xml)
if(TARGET GLEW::GLEW)
target_link_libraries(${PYMESHLAB_MODULE_NAME} PRIVATE GLEW::GLEW)
else()
target_link_libraries(${PYMESHLAB_MODULE_NAME} PRIVATE external-glew)
endif()
if(TARGET meshlab::meshlab-common)
target_link_libraries(${PYMESHLAB_MODULE_NAME} PUBLIC meshlab::meshlab-common)
else()
target_link_libraries(${PYMESHLAB_MODULE_NAME} PUBLIC meshlab-common)
endif()

### Build directories
if (NOT PYMESHLAB_BUILD_DUMMY_BIN_MAC_DEPLOY)
Expand Down
Loading