Skip to content

Commit

Permalink
Feature: Fix conan build
Browse files Browse the repository at this point in the history
  • Loading branch information
zjiefee committed Jan 26, 2024
1 parent 8a3f3ba commit 11303cf
Show file tree
Hide file tree
Showing 53 changed files with 29,472 additions and 146 deletions.
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ project(CuraEngine)
find_package(standardprojectsettings REQUIRED) # imports the cmake module https://github.com/Ultimaker/conan-ultimaker-index/recipes/standardprojectsettings
AssureOutOfSourceBuilds()

option(ENABLE_ARCUS "Enable support for ARCUS" ON)
option(ENABLE_ARCUS "Enable support for ARCUS" OFF)
option(ENABLE_TESTING "Build with unit tests" OFF)
option(EXTENSIVE_WARNINGS "Build with all warnings" ON)
option(EXTENSIVE_WARNINGS "Build with all warnings" OFF)
option(ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS "Enable more optimization flags" ON)
option(USE_SYSTEM_LIBS "Use the system libraries if available" OFF)

Expand Down Expand Up @@ -183,8 +183,19 @@ if (ENABLE_ARCUS)
target_link_libraries(_CuraEngine PRIVATE arcus::arcus protobuf::libprotobuf)
endif ()

find_package(clipper REQUIRED)
find_package(RapidJSON REQUIRED)
set(engine_libs_include
libs/clipper
libs/rapidjson
)

add_library(clipper STATIC libs/clipper/clipper.cpp)
target_link_libraries(_CuraEngine PUBLIC clipper)

include_directories("${CMAKE_CURRENT_BINARY_DIR}" libs ${engine_libs_include})


#find_package(clipper REQUIRED)
#find_package(RapidJSON REQUIRED)
find_package(stb REQUIRED)
find_package(Boost REQUIRED)
find_package(spdlog REQUIRED)
Expand All @@ -200,8 +211,6 @@ target_link_libraries(_CuraEngine
spdlog::spdlog
range-v3::range-v3
fmt::fmt
clipper::clipper
rapidjson
stb::stb
boost::boost
$<$<BOOL:${ENABLE_TESTING}>:GTest::gtest>)
Expand Down
150 changes: 18 additions & 132 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,146 +1,32 @@
# Copyright (c) 2022 Ultimaker B.V.
# CuraEngine is released under the terms of the AGPLv3 or higher

from os import path

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import AutoPackager, copy, mkdir
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version

required_conan_version = ">=1.50.0"


class CuraEngineConan(ConanFile):
name = "curaengine"
license = "AGPL-3.0"
author = "Ultimaker B.V."
url = "https://github.com/Ultimaker/CuraEngine"
description = "Powerful, fast and robust engine for converting 3D models into g-code instructions for 3D printers. It is part of the larger open source project Cura."
topics = ("cura", "protobuf", "gcode", "c++", "curaengine", "libarcus", "gcode-generation", "3D-printing")
build_policy = "missing"
exports = "LICENSE*"
class CompressorRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"

python_requires = "umbase/[>=0.1.7]@ultimaker/stable"
python_requires_extend = "umbase.UMBaseConanfile"

options = {
"enable_arcus": [True, False],
"enable_openmp": [True, False],
"enable_testing": [True, False],
"enable_benchmarks": [True, False],
"enable_extensive_warnings": [True, False]
}
default_options = {
"enable_arcus": False,
"enable_openmp": True,
"enable_testing": False,
"enable_benchmarks": False,
"enable_extensive_warnings": False,
}
scm = {
"type": "git",
"subfolder": ".",
"url": "auto",
"revision": "auto"
}

def set_version(self):
if self.version is None:
self.version = self._umdefault_version()

def config_options(self):
if self.settings.os == "Macos":
del self.options.enable_openmp
def requirements(self):
self.requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
self.requires("stb/cci.20200203")
self.requires("boost/1.79.0")
self.requires("spdlog/1.10.0")
self.requires("fmt/8.1.1")
self.requires("range-v3/0.12.0")
self.requires("llvm-openmp/12.0.1")

def configure(self):
self.options["boost"].header_only = True
self.options["clipper"].shared = False
self.options["fmt"].shared = False
self.options["spdlog"].shared = False
if self.options.enable_arcus:
self.options["arcus"].shared = True
self.options["protobuf"].shared = True

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 20)
if self.version:
if Version(self.version) <= Version("4"):
raise ConanInvalidConfiguration("only versions 5+ are supported")

def build_requirements(self):
if self.options.enable_arcus:
for req in self._um_data()["build_requirements_arcus"]:
self.tool_requires(req)
if self.options.enable_testing:
for req in self._um_data()["build_requirements_testing"]:
self.test_requires(req)
if self.options.enable_benchmarks:
for req in self._um_data()["build_requirements_benchmarks"]:
self.test_requires(req)

def requirements(self):
self.requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
for req in self._um_data()["requirements"]:
self.requires(req)
if self.options.enable_arcus:
for req in self._um_data()["requirements_arcus"]:
self.requires(req)

def generate(self):
deps = CMakeDeps(self)
deps.generate()

tc = CMakeToolchain(self)
tc.variables["CURA_ENGINE_VERSION"] = self.version
tc.variables["ENABLE_ARCUS"] = self.options.enable_arcus
tc.variables["ENABLE_TESTING"] = self.options.enable_testing
tc.variables["ENABLE_BENCHMARKS"] = self.options.enable_benchmarks
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
if self.settings.os != "Macos":
tc.variables["ENABLE_OPENMP"] = self.options.enable_openmp
tc.generate()

for dep in self.dependencies.values():
if len(dep.cpp_info.libdirs) > 0:
copy(self, "*.dylib", dep.cpp_info.libdirs[0], self.build_folder)
copy(self, "*.dll", dep.cpp_info.libdirs[0], self.build_folder)
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], self.build_folder)
if self.options.enable_testing:
test_path = path.join(self.build_folder, "tests")
if not path.exists(test_path):
mkdir(self, test_path)
if len(dep.cpp_info.libdirs) > 0:
copy(self, "*.dylib", dep.cpp_info.libdirs[0], path.join(self.build_folder, "tests"))
copy(self, "*.dll", dep.cpp_info.libdirs[0], path.join(self.build_folder, "tests"))
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], path.join(self.build_folder, "tests"))

def layout(self):
cmake_layout(self)

self.cpp.build.includedirs = ["."] # To package the generated headers
self.cpp.package.libs = ["_CuraEngine"]

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
packager = AutoPackager(self)
packager.run()
copy(self, "CuraEngine*", src = self.build_folder, dst = path.join(self.package_folder, "bin"))
copy(self, "LICENSE*", src = self.source_folder, dst = path.join(self.package_folder, "license"))

def package_info(self):
ext = ".exe" if self.settings.os == "Windows" else ""
if self.in_local_cache:
self.conf_info.define("user.curaengine:curaengine", path.join(self.package_folder, "bin", f"CuraEngine{ext}"))
# We make the assumption that if the compiler is msvc the
# CMake generator is multi-config
if self.settings.get_safe("compiler") == "msvc":
multi = False
else:
self.conf_info.define("user.curaengine:curaengine", path.join(self.build_folder, f"CuraEngine{ext}"))
multi = False

self.folders.build = "build" if multi else f"build/{str(self.settings.build_type)}"
self.folders.generators = f"{self.folders.build}/generators"
146 changes: 146 additions & 0 deletions conanfile1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Copyright (c) 2022 Ultimaker B.V.
# CuraEngine is released under the terms of the AGPLv3 or higher

from os import path

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import AutoPackager, copy, mkdir
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version

required_conan_version = ">=1.50.0"


class CuraEngineConan(ConanFile):
name = "curaengine"
license = "AGPL-3.0"
author = "Ultimaker B.V."
url = "https://github.com/Ultimaker/CuraEngine"
description = "Powerful, fast and robust engine for converting 3D models into g-code instructions for 3D printers. It is part of the larger open source project Cura."
topics = ("cura", "protobuf", "gcode", "c++", "curaengine", "libarcus", "gcode-generation", "3D-printing")
build_policy = "missing"
exports = "LICENSE*"
settings = "os", "compiler", "build_type", "arch"

python_requires = "umbase/[>=0.1.7]@ultimaker/stable"
python_requires_extend = "umbase.UMBaseConanfile"

options = {
"enable_arcus": [True, False],
"enable_openmp": [True, False],
"enable_testing": [True, False],
"enable_benchmarks": [True, False],
"enable_extensive_warnings": [True, False]
}
default_options = {
"enable_arcus": False,
"enable_openmp": True,
"enable_testing": False,
"enable_benchmarks": False,
"enable_extensive_warnings": False,
}
scm = {
"type": "git",
"subfolder": ".",
"url": "auto",
"revision": "auto"
}

def set_version(self):
if self.version is None:
self.version = self._umdefault_version()

def config_options(self):
if self.settings.os == "Macos":
del self.options.enable_openmp

def configure(self):
self.options["boost"].header_only = True
self.options["clipper"].shared = False
self.options["fmt"].shared = False
self.options["spdlog"].shared = False
if self.options.enable_arcus:
self.options["arcus"].shared = True
self.options["protobuf"].shared = True

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 20)
if self.version:
if Version(self.version) <= Version("4"):
raise ConanInvalidConfiguration("only versions 5+ are supported")

def build_requirements(self):
if self.options.enable_arcus:
for req in self._um_data()["build_requirements_arcus"]:
self.tool_requires(req)
if self.options.enable_testing:
for req in self._um_data()["build_requirements_testing"]:
self.test_requires(req)
if self.options.enable_benchmarks:
for req in self._um_data()["build_requirements_benchmarks"]:
self.test_requires(req)

def requirements(self):
self.requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
for req in self._um_data()["requirements"]:
self.requires(req)
if self.options.enable_arcus:
for req in self._um_data()["requirements_arcus"]:
self.requires(req)

def generate(self):
deps = CMakeDeps(self)
deps.generate()

tc = CMakeToolchain(self)
tc.variables["CURA_ENGINE_VERSION"] = self.version
tc.variables["ENABLE_ARCUS"] = self.options.enable_arcus
tc.variables["ENABLE_TESTING"] = self.options.enable_testing
tc.variables["ENABLE_BENCHMARKS"] = self.options.enable_benchmarks
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
if self.settings.os != "Macos":
tc.variables["ENABLE_OPENMP"] = self.options.enable_openmp
tc.generate()

for dep in self.dependencies.values():
if len(dep.cpp_info.libdirs) > 0:
copy(self, "*.dylib", dep.cpp_info.libdirs[0], self.build_folder)
copy(self, "*.dll", dep.cpp_info.libdirs[0], self.build_folder)
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], self.build_folder)
if self.options.enable_testing:
test_path = path.join(self.build_folder, "tests")
if not path.exists(test_path):
mkdir(self, test_path)
if len(dep.cpp_info.libdirs) > 0:
copy(self, "*.dylib", dep.cpp_info.libdirs[0], path.join(self.build_folder, "tests"))
copy(self, "*.dll", dep.cpp_info.libdirs[0], path.join(self.build_folder, "tests"))
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], path.join(self.build_folder, "tests"))

def layout(self):
cmake_layout(self)

self.cpp.build.includedirs = ["."] # To package the generated headers
self.cpp.package.libs = ["_CuraEngine"]

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
packager = AutoPackager(self)
packager.run()
copy(self, "CuraEngine*", src = self.build_folder, dst = path.join(self.package_folder, "bin"))
copy(self, "LICENSE*", src = self.source_folder, dst = path.join(self.package_folder, "license"))

def package_info(self):
ext = ".exe" if self.settings.os == "Windows" else ""
if self.in_local_cache:
self.conf_info.define("user.curaengine:curaengine", path.join(self.package_folder, "bin", f"CuraEngine{ext}"))
else:
self.conf_info.define("user.curaengine:curaengine", path.join(self.build_folder, f"CuraEngine{ext}"))
2 changes: 1 addition & 1 deletion include/utils/Coord_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


//Include Clipper to get the ClipperLib::IntPoint definition, which we reuse as Point definition.
#include <polyclipping/clipper.hpp>
#include <clipper.hpp>

namespace cura
{
Expand Down
2 changes: 1 addition & 1 deletion include/utils/IntPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Integer points are used to avoid floating point rounding errors, and because Cli
#define INLINE static inline

//Include Clipper to get the ClipperLib::IntPoint definition, which we reuse as Point definition.
#include <polyclipping/clipper.hpp>
#include <clipper.hpp>
#include <cmath>
#include <functional> // for hash function object
#include <iostream> // auto-serialization / auto-toString()
Expand Down
2 changes: 1 addition & 1 deletion include/utils/polygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <assert.h>
#include <float.h>
#include <algorithm>
#include <polyclipping/clipper.hpp>
#include <clipper.hpp>

#include <algorithm> // std::reverse, fill_n array
#include <unordered_map>
Expand Down
Loading

0 comments on commit 11303cf

Please sign in to comment.