diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d7a69a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,60 @@ +# Created by https://www.toptal.com/developers/gitignore/api/conan,venv,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=conan,venv,visualstudiocode + +### Conan ### +# Conan build information +conan.lock +conanbuildinfo.* +conaninfo.txt +graph_info.json +build/ + +## Various built-in generators +# cmake_find_package generator https://docs.conan.io/en/latest/reference/generators/cmake_find_package.html +Find*.cmake + +# cmake_paths generator https://docs.conan.io/en/1.4/integrations/cmake/cmake_paths_generator.html +conan_paths.* + +# Environment activation scripts produced by https://docs.conan.io/en/latest/mastering/virtualenv.html#virtualenv-generator +activate_run.ps1 +activate_run.sh +deactivate_run.ps1 +deactivate_run.sh +environment_run.ps1.env +environment_run.sh.env + +### venv ### +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +.Python +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +.venv +pip-selfcheck.json + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/conan,venv,visualstudiocode \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index f74abc1..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "3rdparty/svgpp"] - path = 3rdparty/svgpp - url = https://github.com/svgpp/svgpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 00582ce..a110d47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,91 +5,18 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) project (svgfill) -cmake_policy(SET CMP0074 NEW) # find_package() uses _ROOT variables. -if (POLICY CMP0144) -cmake_policy(SET CMP0144 NEW) # find_package() uses upper-case _ROOT variables. -endif() - -include(GNUInstallDirs) - -# Specify paths to install files -if(NOT BINDIR) - set(BINDIR bin) -endif() -if(NOT IS_ABSOLUTE ${BINDIR}) - set(BINDIR ${CMAKE_INSTALL_BINDIR}) -endif() -message(STATUS "BINDIR: ${BINDIR}") - -if(NOT INCLUDEDIR) - set(INCLUDEDIR include) -endif() -if(NOT IS_ABSOLUTE ${INCLUDEDIR}) - set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) -endif() -message(STATUS "INCLUDEDIR: ${INCLUDEDIR}") - -if(NOT LIBDIR) - set(LIBDIR lib) -endif() -if(NOT IS_ABSOLUTE ${LIBDIR}) - set(LIBDIR ${CMAKE_INSTALL_LIBDIR}) -endif() -message(STATUS "LIBDIR: ${LIBDIR}") - -set(CGAL_LIBRARY_NAMES libCGAL_Core libCGAL_ImageIO libCGAL) - -if("${CGAL_INCLUDE_DIR}" STREQUAL "") - set(CGAL_INCLUDE_DIR "/usr/include/" CACHE FILEPATH "CGAL header files") - message(STATUS "Looking for CGAL include files in: ${CGAL_INCLUDE_DIR}") - message(STATUS "Use CGAL_INCLUDE_DIR to specify another directory") -else() - set(CGAL_INCLUDE_DIR ${CGAL_INCLUDE_DIR} CACHE FILEPATH "CGAL header files") - message(STATUS "Looking for CGAL include files in: ${CGAL_INCLUDE_DIR}") -endif() - -if(NOT "${CGAL_LIBRARY_DIR}" STREQUAL "") - set(CGAL_LIBRARY_DIR ${CGAL_LIBRARY_DIR} CACHE FILEPATH "CGAL library files") - message(STATUS "Looking for CGAL library files in: ${CGAL_LIBRARY_DIR}") -endif() - if(WASM_BUILD) set(CMAKE_FIND_ROOT_PATH_BACKUP "${CMAKE_FIND_ROOT_PATH}") set(CMAKE_FIND_ROOT_PATH "") endif() -find_library(libCGAL NAMES CGAL PATHS ${CGAL_LIBRARY_DIR} NO_DEFAULT_PATH) - -if(libCGAL) - message(STATUS "CGAL library files found") - foreach(lib ${CGAL_LIBRARY_NAMES}) - string(REPLACE libCGAL "${lib}" lib_path "${libCGAL}") - list(APPEND CGAL_LIBRARIES "${lib_path}") - endforeach() -else() - if(NOT "${CGAL_LIBRARY_DIR}" STREQUAL "") - file(GLOB CGAL_LIBRARIES ${CGAL_LIBRARY_DIR}/CGAL*.lib) - list(LENGTH CGAL_LIBRARY_NAMES num_cgal_library_names) - list(LENGTH CGAL_LIBRARIES num_cgal_libraries) - link_directories("${CGAL_LIBRARY_DIR}") - if(NOT "${num_cgal_library_names}" STREQUAL "${num_cgal_libraries}") - message(FATAL_ERROR "Unable to find CGAL library files, aborting") - endif() - message(STATUS "CGAL library files found") - endif() -endif() - -find_library(libGMP NAMES gmp mpir PATHS ${GMP_LIBRARY_DIR} NO_DEFAULT_PATH) -find_library(libMPFR NAMES mpfr PATHS ${MPFR_LIBRARY_DIR} NO_DEFAULT_PATH) -if(NOT libGMP) - message(FATAL_ERROR "Unable to find GMP library files, aborting") -endif() -if(NOT libMPFR) - message(FATAL_ERROR "Unable to find MPFR library files, aborting") -endif() +find_package(Boost REQUIRED CONFIG) +find_package(svgpp REQUIRED CONFIG) +find_package(libxml2 REQUIRED CONFIG) +find_package(CGAL REQUIRED CONFIG) +find_package(gmp REQUIRED CONFIG) +find_package(mpfr REQUIRED CONFIG) -list(APPEND CGAL_LIBRARIES "${libMPFR}") -list(APPEND CGAL_LIBRARIES "${libGMP}") if(WIN32 AND ("$ENV{CONDA_BUILD}" STREQUAL "")) set(Boost_USE_STATIC_LIBS ON) @@ -112,31 +39,24 @@ if (MSVC) add_definitions(-bigobj) endif() -find_package(Boost) -message(STATUS "Boost include files found in ${Boost_INCLUDE_DIRS}") - if(WASM_BUILD) set(CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH_BACKUP}") endif() - -include_directories(${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} - ${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/svgpp/include -) - file(GLOB LIB_H_FILES src/*.h) +message(STATUS "Found header files: ${LIB_H_FILES}") file(GLOB LIB_CPP_FILES src/svgfill.cpp src/arrange_polygons.cpp) -set(LIB_SRC_FILES ${LIB_H_FILES} ${LIB_CPP_FILES}) -add_library(svgfill ${LIB_SRC_FILES}) -target_link_libraries(svgfill ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES} ${CGAL_LIBRARIES}) + +add_library(svgfill ${LIB_H_FILES} ${LIB_CPP_FILES}) +target_link_libraries(svgfill Boost::boost svgpp::svgpp LibXml2::LibXml2 CGAL::CGAL) add_executable(svgfill_exe src/main.cpp) target_link_libraries(svgfill_exe svgfill) set_property(TARGET svgfill_exe PROPERTY OUTPUT_NAME svgfill) if(WIN32) # both the library and the executable now result in a file with basename svgfill, - # on linux the the library is prefixed with lib as libsvgfill.a. Windows does not + # on linux the library is prefixed with lib as libsvgfill.a. Windows does not # have this mechanism, so on windows the linker would be created an import library # for the executable, also named svgfill.lib. This naming conflict results in: # LINK : fatal error LNK1149: output filename matches input filename @@ -145,6 +65,11 @@ if(WIN32) target_link_options(svgfill_exe PRIVATE "/NOIMPLIB") endif() -install(TARGETS svgfill_exe DESTINATION ${BINDIR}) -install(TARGETS svgfill DESTINATION ${LIBDIR}) -install(FILES ${LIB_H_FILES} DESTINATION ${INCLUDEDIR}) +set_target_properties(svgfill PROPERTIES PUBLIC_HEADER "src/svgfill.h;src/progress.h") +install(TARGETS svgfill) + +install(TARGETS svgfill_exe DESTINATION "." + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + ) \ No newline at end of file diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..b71bce0 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,76 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy +import os + +required_conan_version = ">=2.0.9" + +class SvgfillConan(ConanFile): + name = "svgfill" + version = "0.1.0" + description = "An application to fill areas bounded by unconnected lines in SVG" + license = "LGPL-2.1-or-later" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/IfcOpenShell/svgfill" + topics = ("svg", "ifc") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + implements = ["auto_shared_fpic"] + + exports_sources = "CMakeLists.txt", "src/**" + + # no exports_sources attribute, but export_sources(self) method instead + # def export_sources(self): + # export_conandata_patches(self) + + def layout(self): + cmake_layout(self, src_folder="") + + def requirements(self): + self.requires("svgpp/1.3.1") + self.requires("cgal/6.0.1") + self.requires("boost/1.88.0", override=True, transitive_headers=True) + self.requires("libxml2/2.13.8") + self.requires("nlohmann_json/3.12.0") + self.requires("gmp/6.3.0") + self.requires("mpfr/4.2.1") + + def validate(self): + check_min_cppstd(self, 17) + + def build_requirements(self): + self.tool_requires("cmake/[>=3.16 <4]") + + # def source(self): + # get(self, **self.conan_data["sources"][self.version], strip_root=True) + # # Using patches is always the last resort to fix issues. If possible, try to fix the issue in the upstream project. + # apply_conandata_patches(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["svgfill"] + \ No newline at end of file