Repository: conan-io/conan-center-index

Issue:
[request] dime/0.9.1
### Package Details
  * Package Name/Version: **dime/0.9.1**
  * Website: **https://coin3d.github.io/dime/html/**
  * Source code: **https://github.com/coin3d/dime**


### Description Of The Library / Tool
Dime is a C++ class library for reading, constructing, manipulating, and writing DXF file data. The name is an acronym for DXF Import, Manipulation, and Export library.

The library is portable to any platform with a C++ compiler. It has no external dependencies. Dime is known to compile on Win32, Linux, IRIX, HP- UX, Solaris, BeOS and MacOS.




Discussion:

Resolving patch:
diff --git a/recipes/dime/all/conanfile.py b/recipes/dime/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/dime/all/conanfile.py
@@ -0,0 +1,96 @@
+from conans import ConanFile, CMake, tools
+from conan.tools.microsoft import is_msvc
+import os
+import functools
+
+required_conan_version = ">=1.33.0"
+
+class DimeConan(ConanFile):
+    name = "dime"
+    description = "DXF (Data eXchange Format) file format support library."
+    topics = ("dxf", "coin3d", "opengl", "graphics")
+    homepage = "https://github.com/coin3d/dime"
+    url = "https://github.com/conan-io/conan-center-index"
+    license = "BSD-3-Clause"
+    exports_sources = ["CMakeLists.txt"]
+    generators = "cmake",
+    settings = "os", "arch", "compiler", "build_type",
+    options = {
+        "fPIC": [True, False],
+        "shared": [True, False],
+        "fixbig": [True, False],
+    }
+    default_options = {
+        "fPIC": True,
+        "shared": False,
+        "fixbig": False,
+    }
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _build_subfolder(self):
+        return "build_subfolder"
+
+    def config_options(self):
+        if self.settings.os == "Windows":
+            del self.options.fPIC
+
+    def configure(self):
+        if self.options.shared:
+            del self.options.fPIC
+
+    def validate(self):
+        if self.settings.compiler.get_safe("cppstd"):
+            tools.check_min_cppstd(self, "11")
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version],
+            destination=self._source_subfolder, strip_root=True)
+
+    @functools.lru_cache(1)
+    def _configure_cmake(self):
+        cmake = CMake(self)
+        cmake.definitions["DIME_BUILD_SHARED_LIBS"] = self.options.shared
+        if self.options.fixbig:
+            cmake.definitions["CMAKE_CXX_FLAGS"] = "-DDIME_FIXBIG"
+        cmake.configure(build_folder=self._build_subfolder)
+        return cmake
+
+    def build(self):
+        tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
+            "configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME_LOWER}.pc.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME_LOWER}.pc @ONLY)",
+            "configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME_LOWER}.pc.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME_LOWER}.pc @ONLY)")
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy("COPYING", dst="licenses", src=self._source_subfolder)
+        cmake = self._configure_cmake()
+        cmake.install()
+        tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
+        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
+        if self.settings.os == "Windows" and is_msvc(self):
+            tools.remove_files_by_mask(self.package_folder, "*.pdb")
+
+    def package_info(self):
+        libname = "dime"
+        if self.settings.os == "Windows" and is_msvc(self):
+            libname = "{}{}{}{}".format(
+                libname,
+                tools.Version(self.version).major,
+                "" if self.options.shared else "s",
+                "d" if self.settings.build_type == "Debug" else "",
+                )
+        self.cpp_info.libs = [libname]
+
+        if self.settings.os == "Windows":
+            self.cpp_info.cxxflags.append("-DDIME_DLL" if self.options.shared else "-DDIME_NOT_DLL")
+        if self.options.fixbig:
+            self.cpp_info.cxxflags.append("-DDIME_FIXBIG")
+
+        bindir = os.path.join(self.package_folder, "bin")
+        self.output.info("Appending PATH environment variable: {}".format(bindir))
+        self.env_info.PATH.append(bindir)


Test patch:
diff --git a/recipes/dime/all/test_package/CMakeLists.txt b/recipes/dime/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/dime/all/test_package/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package CXX)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+find_package(dime CONFIG REQUIRED)
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_link_libraries(${PROJECT_NAME} dime::dime)
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
diff --git a/recipes/dime/all/test_package/conanfile.py b/recipes/dime/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/dime/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+import os
+from conans import ConanFile, CMake, tools
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake", "cmake_find_package_multi"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self):
+            bin_path = os.path.join("bin", "test_package")
+            dxf_path = os.path.join(self.source_folder, "testFile_Bug01.dxf")
+            self.run("{} {}".format(bin_path, dxf_path), run_environment=True)
diff --git a/recipes/dime/all/test_package/testFile_Bug01.dxf b/recipes/dime/all/test_package/testFile_Bug01.dxf
new file mode 100644
--- /dev/null
+++ b/recipes/dime/all/test_package/testFile_Bug01.dxf
@@ -0,0 +1,104 @@
+  0
+SECTION
+  2
+ENTITIES
+  0
+POLYLINE
+  5
+205
+  8
+0
+ 66
+     1
+ 10
+0.0
+ 20
+0.0
+ 30
+0.0
+  0
+VERTEX
+  5
+279
+  8
+0
+ 10
+-176.07272753254799
+ 20
+-907.11665722290854
+ 30
+0.0
+  0
+VERTEX
+  5
+27A
+  8
+0
+ 10
+-176.07272753254799
+ 20
+-157.11665722290871
+ 30
+0.0
+ 42
+-0.4142135623730951
+  0
+VERTEX
+  5
+27B
+  8
+0
+ 10
+73.927272467451957
+ 20
+92.883342777091343
+ 30
+0.0
+  0
+VERTEX
+  5
+27C
+  8
+0
+ 10
+573.92727246745198
+ 20
+92.883342777091343
+ 30
+0.0
+ 42
+0.4142135623730951
+  0
+VERTEX
+  5
+27D
+  8
+0
+ 10
+823.92727246745187
+ 20
+342.88334277709129
+ 30
+0.0
+  0
+VERTEX
+  5
+27E
+  8
+0
+ 10
+823.92727246745187
+ 20
+1092.883342777091
+ 30
+0.0
+  0
+SEQEND
+  5
+27F
+  8
+0
+  0
+ENDSEC
+  0
+EOF
diff --git a/recipes/dime/all/test_package/test_package.cpp b/recipes/dime/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/dime/all/test_package/test_package.cpp
@@ -0,0 +1,24 @@
+#include <iostream>
+
+#include <dime/Input.h>
+#include <dime/Model.h>
+#include <dime/State.h>
+
+int main(int argc, char* argv[]) {
+    if (argc < 2) {
+        return 1;
+    }
+    const char* filename = argv[1];
+
+    dimeInput in;
+
+    if (!in.setFile(filename)) {
+        std::cerr << "could not read dxf file : " << filename << std::endl;
+        return 1;
+    }
+
+    dimeModel model;
+    model.read(&in);
+
+    return 0;
+}