Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
71aec64
Remove excess dependency
oitel Sep 13, 2022
1638f97
Optional clip dependency
oitel Sep 13, 2022
776e787
Fix dependency
oitel Sep 13, 2022
a8bbfb6
Optional podofo dependency
oitel Sep 13, 2022
05b6735
Optional cpr, curl dependencies
oitel Sep 13, 2022
5991ff8
Optional python dependency
oitel Sep 13, 2022
0425b8c
Fix typo
oitel Sep 13, 2022
0d03c36
Optional gdcm dependency
oitel Sep 13, 2022
913278a
Optional openctm dependency
oitel Sep 14, 2022
0a6bb64
Optional freetype dependency
oitel Sep 14, 2022
6fa1686
Optional turbojpeg, png dependencies
oitel Sep 14, 2022
8d56235
Optional openvdb dependency
oitel Sep 14, 2022
fcff888
Fix linking
oitel Sep 14, 2022
dc2b6e5
Merge branch 'master' into minimal_build
oitel Sep 16, 2022
6995c37
Fix MinGW build
oitel Sep 16, 2022
6bd2d5f
Fix MinGW build
oitel Sep 16, 2022
f4a8426
Fix macOS build
oitel Sep 19, 2022
99686c0
Fix macOS build
oitel Sep 19, 2022
517ff43
Fix macOS build
oitel Sep 19, 2022
20da117
Fix macOS build
oitel Sep 19, 2022
9a265d2
Merge branch 'master' into minimal_build
oitel Sep 19, 2022
5c5318a
Merge branch 'master' into minimal_build
oitel Sep 20, 2022
ee52fb3
Fix build
oitel Sep 21, 2022
0cdbb88
Merge branch 'master' into minimal_build
Fedr Sep 21, 2022
b1db457
prevent calling utf8string(...) with strings
Fedr Sep 22, 2022
e623060
Merge branch 'master' into minimal_build
oitel Sep 23, 2022
790171f
Disable features for Emscripten explicitly
oitel Sep 23, 2022
2d2b9f9
Do not compile unsupported methods
oitel Sep 23, 2022
24e2bb5
Rework old libc++ support
oitel Sep 23, 2022
9da75f2
Fix disabling OpenCTM support
oitel Sep 23, 2022
f03d49d
Fallback (de-)serialization
oitel Sep 23, 2022
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
151 changes: 116 additions & 35 deletions source/MRMesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,123 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project (MRMesh CXX)
project(MRMesh CXX)

option(MRMESH_NO_CLIPBOARD "Disable clipboard support for Linux and Mac" OFF)
option(MRMESH_NO_PDF "Disable PDF support" OFF)
option(MRMESH_NO_CPR "Disable CPR tests" OFF)
option(MRMESH_NO_PYTHON "Disable Python bindings" OFF)
option(MRMESH_NO_DICOM "Disable DICOM image support" OFF)
option(MRMESH_NO_OPENCTM "Disable OpenCTM support" OFF)
option(MRMESH_NO_LABEL "Disable support of label objects" OFF)
option(MRMESH_NO_JPEG "Disable JPEG support" OFF)
option(MRMESH_NO_PNG "Disable PNG support" OFF)
option(MRMESH_NO_VOXEL "Disable voxel support" OFF)

file(GLOB SOURCES "*.cpp")
file(GLOB HEADERS "*.h")

add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})

include_directories(${MESHLIB_THIRDPARTY_INCLUDE_DIR})
set(MRMESH_OPTIONAL_DEPENDENCIES "")

IF(MRMESH_NO_OPENCTM)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_OPENCTM)
ELSE()
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES OpenCTM)
ENDIF()

IF(NOT MR_EMSCRIPTEN)
IF(MRMESH_NO_CLIPBOARD)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_CLIPBOARD)
ELSE()
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES clip)
ENDIF()

IF(MRMESH_NO_PDF)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_PDF)
ELSE()
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES podofo)
ENDIF()

IF(MRMESH_NO_CPR)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_CPR)
ELSE()
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES cpr)

IF(NOT APPLE)
set(CPR_DIR ${MESHLIB_THIRDPARTY_INCLUDE_DIR}/cpr)
target_include_directories(${PROJECT_NAME} PUBLIC ${CPR_DIR}/include)
target_include_directories(${PROJECT_NAME} PUBLIC ${MESHLIB_THIRDPARTY_LIB_DIR}/cpr/cpr_generated_includes)

set(CURL_INCLUDES ${THIRDPARTY_LIB_DIR}/_deps/curl-src/include/)
target_include_directories(${PROJECT_NAME} PUBLIC ${CURL_INCLUDES})
ENDIF()
ENDIF()

IF(MRMESH_NO_PYTHON)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_PYTHON)
ELSE()
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES ${PYTHON_LIB})
ENDIF()

IF(MRMESH_NO_DICOM)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_DICOM)
ELSE()
find_package(GDCM CONFIG REQUIRED)
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES gdcmIOD gdcmDICT gdcmDSED gdcmMEXD gdcmMSFF)
ENDIF()

IF(MRMESH_NO_LABEL)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_LABEL)
ELSE()
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES freetype)
ENDIF()

IF(MRMESH_NO_JPEG)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_JPEG)
ELSE()
IF(APPLE)
target_include_directories(${PROJECT_NAME} PUBLIC ${HOMEBREW_PREFIX}/opt/jpeg-turbo/include)
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES ${HOMEBREW_PREFIX}/opt/jpeg-turbo/lib/libturbojpeg.dylib)
ELSE()
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES turbojpeg)
ENDIF()
ENDIF()

IF(MRMESH_NO_PNG)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_PNG)
ELSE()
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES png)
ENDIF()

IF(MRMESH_NO_VOXEL)
target_compile_definitions(${PROJECT_NAME} PRIVATE MRMESH_NO_VOXEL)
ELSE()
IF(APPLE)
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES OpenVDB)
ELSE()
target_include_directories(${PROJECT_NAME} PUBLIC ${MESHLIB_THIRDPARTY_LIB_DIR}/openvdb/openvdb/openvdb)
target_include_directories(${PROJECT_NAME} PUBLIC ${MESHLIB_THIRDPARTY_LIB_DIR}/openvdb/openvdb/openvdb/openvdb)
list(APPEND MRMESH_OPTIONAL_DEPENDENCIES openvdb)
ENDIF()
ENDIF()
ELSE()
target_compile_definitions(${PROJECT_NAME}
PRIVATE
MRMESH_NO_PDF
MRMESH_NO_CPR
MRMESH_NO_PYTHON
MRMESH_NO_DICOM
MRMESH_NO_JPEG
MRMESH_NO_VOXEL
)
ENDIF()

IF(NOT MR_EMSCRIPTEN)
find_package(GDCM CONFIG REQUIRED)
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
find_package(Boost COMPONENTS REQUIRED )
find_package( TBB REQUIRED )
pkg_check_modules(JSONCPP jsoncpp)
Expand All @@ -35,70 +140,46 @@ IF(APPLE OR MR_EMSCRIPTEN)

target_include_directories(
${PROJECT_NAME} PUBLIC
${MESHLIB_THIRDPARTY_INCLUDE_DIR}/expected/include
${HOMEBREW_PREFIX}/opt/jpeg-turbo/include)
${MESHLIB_THIRDPARTY_INCLUDE_DIR}/expected/include)

IF (NOT MR_EMSCRIPTEN)
find_library(COCOA_LIBRARY Cocoa ONLY)

target_link_libraries(${PROJECT_NAME} PRIVATE
OpenVDB
OpenCTM
spdlog
gtest gtest_main
zip
freetype
pthread
gdcmIOD gdcmDICT gdcmDSED gdcmMEXD gdcmMSFF
Boost::boost
jsoncpp
cpr
${PYTHON_LIB}
podofo
${HOMEBREW_PREFIX}/opt/jpeg-turbo/lib/libturbojpeg.dylib
png
fmt
tbb
clip
${MRMESH_OPTIONAL_DEPENDENCIES}
${COCOA_LIBRARY}
)
ELSE()
target_link_libraries(${PROJECT_NAME} PRIVATE
OpenCTM
gtest gtest_main
zip
freetype
pthread
jsoncpp
tbb
${MRMESH_OPTIONAL_DEPENDENCIES}
)
ENDIF()
ELSE()
find_package(tl-expected REQUIRED)
set(CPR_DIR ${MESHLIB_THIRDPARTY_INCLUDE_DIR}/cpr)
target_include_directories(${PROJECT_NAME} PUBLIC ${CPR_DIR}/include)
target_include_directories(${PROJECT_NAME} PUBLIC ${MESHLIB_THIRDPARTY_LIB_DIR}/cpr/cpr_generated_includes)
target_include_directories(${PROJECT_NAME} PUBLIC ${MESHLIB_THIRDPARTY_LIB_DIR}/openvdb/openvdb/openvdb)
target_include_directories(${PROJECT_NAME} PUBLIC ${MESHLIB_THIRDPARTY_LIB_DIR}/openvdb/openvdb/openvdb/openvdb)

set(CURL_INCLUDES ${THIRDPARTY_LIB_DIR}/_deps/curl-src/include/)
target_include_directories(${PROJECT_NAME} PUBLIC ${CURL_INCLUDES})

target_link_libraries(${PROJECT_NAME} PRIVATE
openvdb
OpenCTM tl::expected
tl::expected
fmt
spdlog
gtest gtest_main
zip
freetype
pthread
gdcmIOD gdcmDICT gdcmDSED gdcmMEXD gdcmMSFF
Boost::boost
jsoncpp
cpr
${PYTHON_LIB}
podofo
turbojpeg
clip
tbb
${MRMESH_OPTIONAL_DEPENDENCIES}
)
ENDIF()
4 changes: 3 additions & 1 deletion source/MRMesh/MRAlignTextToMesh.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifndef MRMESH_NO_LABEL
#include "MRAlignTextToMesh.h"
#include "MRMesh.h"
#include "MRBox.h"
Expand Down Expand Up @@ -60,4 +61,5 @@ tl::expected<Mesh, std::string> alignTextToMesh(
return std::move( textMesh );
}

}
}
#endif
5 changes: 4 additions & 1 deletion source/MRMesh/MRAlignTextToMesh.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once

#ifndef MRMESH_NO_LABEL
#include "MRMeshFwd.h"
#include <tl/expected.hpp>
#include "MRId.h"
Expand Down Expand Up @@ -29,4 +31,5 @@ struct TextMeshAlignParams : SymbolMeshParams
};

MRMESH_API tl::expected<Mesh, std::string> alignTextToMesh( const Mesh& mesh, const AffineXf3f& xf, const TextMeshAlignParams& params );
}
}
#endif
2 changes: 1 addition & 1 deletion source/MRMesh/MRBoolean.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_VOXEL )
#include "MRBoolean.h"
#include "MRMesh.h"
#include "MRObjectMesh.h"
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRBoolean.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_VOXEL )
#include "MRVDBConversions.h"
#include "MRAffineXf3.h"

Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRCPRTests.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_CPR )
#include <cpr/cpr.h>
#include "MRPch/MRSpdlog.h"
#include "MRGTest.h"
Expand Down
3 changes: 3 additions & 0 deletions source/MRMesh/MRChangeLabelAction.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once

#ifndef MRMESH_NO_LABEL
#include "MRMesh/MRMeshFwd.h"
#include "MRHistoryAction.h"
#include "MRMesh/MRPositionedText.h"
Expand Down Expand Up @@ -49,3 +51,4 @@ class ChangeLabelAction : public HistoryAction
};

}
#endif
6 changes: 3 additions & 3 deletions source/MRMesh/MRDistanceMapLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ tl::expected<DistanceMap, std::string> loadRaw( const std::filesystem::path& pat
if ( path.empty() )
return tl::make_unexpected( "Path is empty" );

auto ext = path.extension().u8string();
auto ext = utf8string( path.extension() );
for ( auto& c : ext )
c = ( char )tolower( c );

if ( ext != u8".raw" )
if ( ext != ".raw" )
{
std::stringstream ss;
ss << "Extension is not correct, expected \".raw\" current \"" << asString( ext ) << "\"" << std::endl;
ss << "Extension is not correct, expected \".raw\" current \"" << ext << "\"" << std::endl;
return tl::make_unexpected( ss.str() );
}

Expand Down
6 changes: 3 additions & 3 deletions source/MRMesh/MRDistanceMapSave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ tl::expected<void, std::string> saveRAW( const std::filesystem::path& path, cons
if ( path.empty() )
return tl::make_unexpected( "Path is empty" );

auto ext = path.extension().u8string();
auto ext = utf8string( path.extension() );
for ( auto& c : ext )
c = ( char )tolower( c );

if ( ext != u8".raw" )
if ( ext != ".raw" )
{
std::stringstream ss;
ss << "Extension is not correct, expected \".raw\" current \"" << asString( ext ) << "\"" << std::endl;
ss << "Extension is not correct, expected \".raw\" current \"" << ext << "\"" << std::endl;
return tl::make_unexpected( ss.str() );
}

Expand Down
6 changes: 3 additions & 3 deletions source/MRMesh/MREmbeddedPython.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_PYTHON )
#include "MREmbeddedPython.h"
#include "MRPython.h"
#include "MRStringConvert.h"
Expand Down Expand Up @@ -102,11 +102,11 @@ bool EmbeddedPython::isPythonScript( const std::filesystem::path& path )
if ( !std::filesystem::is_regular_file( path, ec ) )
return false;

auto ext = path.extension().u8string();
auto ext = utf8string( path.extension() );
for ( auto& c : ext )
c = (char) tolower( c );

if ( ext != u8".py" )
if ( ext != ".py" )
return false;

return true;
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MREmbeddedPython.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_PYTHON )
#include "MRMeshFwd.h"
#include <string>
#include <filesystem>
Expand Down
1 change: 1 addition & 0 deletions source/MRMesh/MRFile.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "MRFile.h"
#include "MRStringConvert.h"
#include <cstring>

namespace MR
{
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRFixUndercuts.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_VOXEL )
#include "MRFixUndercuts.h"
#include "MRMesh.h"
#include "MRMatrix3.h"
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRFixUndercuts.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_VOXEL )
#include "MRMeshFwd.h"
#include "MRVector3.h"
#include "MRVector2.h"
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRFloatGrid.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_VOXEL )
#include "MRFloatGrid.h"
#include "MRVector3.h"
#include "MRBitSet.h"
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRFloatGrid.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_VOXEL )
// this header includes the whole OpenVDB, so please include it from .cpp files only

#include "MRMeshFwd.h"
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRFloatGridComponents.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_VOXEL )
#include "MRFloatGridComponents.h"
#include "MRUnionFind.h"
#include "MRFloatGrid.h"
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRFloatGridComponents.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#ifndef __EMSCRIPTEN__
#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_VOXEL )
#include "MRMeshFwd.h"

namespace MR
Expand Down
Loading