Use resources dir for occt shared lib
This commit is contained in:
parent
7d3f0b4b32
commit
1fd4659f0e
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,3 +18,4 @@ local-lib
|
|||||||
build-linux/*
|
build-linux/*
|
||||||
deps/build-linux/*
|
deps/build-linux/*
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
|
resources/plugins
|
||||||
|
@ -33,6 +33,7 @@ option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1)
|
|||||||
option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1)
|
option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1)
|
||||||
option(SLIC3R_PERL_XS "Compile XS Perl module and enable Perl unit and integration tests" 0)
|
option(SLIC3R_PERL_XS "Compile XS Perl module and enable Perl unit and integration tests" 0)
|
||||||
option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)
|
option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)
|
||||||
|
option(SLIC3R_ENABLE_FORMAT_STEP "Enable compilation of STEP file support" 1)
|
||||||
# If SLIC3R_FHS is 1 -> SLIC3R_DESKTOP_INTEGRATION is always 0, othrewise variable.
|
# If SLIC3R_FHS is 1 -> SLIC3R_DESKTOP_INTEGRATION is always 0, othrewise variable.
|
||||||
CMAKE_DEPENDENT_OPTION(SLIC3R_DESKTOP_INTEGRATION "Allow perfoming desktop integration during runtime" 1 "NOT SLIC3R_FHS" 0)
|
CMAKE_DEPENDENT_OPTION(SLIC3R_DESKTOP_INTEGRATION "Allow perfoming desktop integration during runtime" 1 "NOT SLIC3R_FHS" 0)
|
||||||
|
|
||||||
|
@ -17,7 +17,10 @@ add_subdirectory(hints)
|
|||||||
add_subdirectory(qoi)
|
add_subdirectory(qoi)
|
||||||
add_subdirectory(libnest2d)
|
add_subdirectory(libnest2d)
|
||||||
add_subdirectory(libslic3r)
|
add_subdirectory(libslic3r)
|
||||||
add_subdirectory(occt_wrapper)
|
|
||||||
|
if (SLIC3R_ENABLE_FORMAT_STEP)
|
||||||
|
add_subdirectory(occt_wrapper)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (SLIC3R_GUI)
|
if (SLIC3R_GUI)
|
||||||
add_subdirectory(imgui)
|
add_subdirectory(imgui)
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
#include "libslic3r/TriangleMesh.hpp"
|
#include "libslic3r/TriangleMesh.hpp"
|
||||||
|
#include "libslic3r/Utils.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -24,8 +27,10 @@ LoadStepFn get_load_step_fn()
|
|||||||
constexpr const char* fn_name = "load_step_internal";
|
constexpr const char* fn_name = "load_step_internal";
|
||||||
|
|
||||||
if (!load_step_fn) {
|
if (!load_step_fn) {
|
||||||
|
auto libpath = boost::filesystem::path(resources_dir()) / "plugins";
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HMODULE module = LoadLibraryW(L"OCCTWrapper.dll");
|
libpath /= "OCCTWrapper.dll";
|
||||||
|
HMODULE module = LoadLibraryW(libpath.wstring().c_str());
|
||||||
if (module == NULL)
|
if (module == NULL)
|
||||||
throw Slic3r::RuntimeError("Cannot load OCCTWrapper.dll");
|
throw Slic3r::RuntimeError("Cannot load OCCTWrapper.dll");
|
||||||
|
|
||||||
@ -42,18 +47,17 @@ LoadStepFn get_load_step_fn()
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void *plugin_ptr = dlopen("OCCTWrapper.so", RTLD_NOW | RTLD_GLOBAL);
|
libpath /= "OCCTWrapper.so";
|
||||||
|
void *plugin_ptr = dlopen(libpath.c_str(), RTLD_NOW | RTLD_GLOBAL);
|
||||||
|
|
||||||
if (plugin_ptr) {
|
if (plugin_ptr) {
|
||||||
load_step_fn = reinterpret_cast<LoadStepFn>(dlsym(plugin_ptr, "load_step_internal"));
|
load_step_fn = reinterpret_cast<LoadStepFn>(dlsym(plugin_ptr, fn_name));
|
||||||
if (!load_step_fn) {
|
if (!load_step_fn) {
|
||||||
dlclose(plugin_ptr);
|
dlclose(plugin_ptr);
|
||||||
throw Slic3r::RuntimeError("Cannot load function from OCCTWrapper.so");
|
BOOST_LOG_TRIVIAL(error) << dlerror();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw Slic3r::RuntimeError(
|
BOOST_LOG_TRIVIAL(error) << dlerror();
|
||||||
std::string("Cannot load function from OCCTWrapper.dll: ") +
|
|
||||||
fn_name + "\n\nError code: " + dlerror());
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ add_library(OCCTWrapper MODULE OCCTWrapper.cpp)
|
|||||||
|
|
||||||
set_target_properties(OCCTWrapper
|
set_target_properties(OCCTWrapper
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/src"
|
LIBRARY_OUTPUT_DIRECTORY "${SLIC3R_RESOURCES_DIR}/plugins"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/src"
|
RUNTIME_OUTPUT_DIRECTORY "${SLIC3R_RESOURCES_DIR}/plugins"
|
||||||
PREFIX ""
|
PREFIX ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user