Skip to content

Commit aecc40a

Browse files
Use conan to manage dependencies
1 parent 37448e9 commit aecc40a

File tree

4 files changed

+151
-97
lines changed

4 files changed

+151
-97
lines changed

.gitignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/conan,venv,visualstudiocode
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=conan,venv,visualstudiocode
3+
4+
### Conan ###
5+
# Conan build information
6+
conan.lock
7+
conanbuildinfo.*
8+
conaninfo.txt
9+
graph_info.json
10+
build/
11+
12+
## Various built-in generators
13+
# cmake_find_package generator https://docs.conan.io/en/latest/reference/generators/cmake_find_package.html
14+
Find*.cmake
15+
16+
# cmake_paths generator https://docs.conan.io/en/1.4/integrations/cmake/cmake_paths_generator.html
17+
conan_paths.*
18+
19+
# Environment activation scripts produced by https://docs.conan.io/en/latest/mastering/virtualenv.html#virtualenv-generator
20+
activate_run.ps1
21+
activate_run.sh
22+
deactivate_run.ps1
23+
deactivate_run.sh
24+
environment_run.ps1.env
25+
environment_run.sh.env
26+
27+
### venv ###
28+
# Virtualenv
29+
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
30+
.Python
31+
[Bb]in
32+
[Ii]nclude
33+
[Ll]ib
34+
[Ll]ib64
35+
[Ll]ocal
36+
[Ss]cripts
37+
pyvenv.cfg
38+
.venv
39+
pip-selfcheck.json
40+
41+
### VisualStudioCode ###
42+
.vscode/*
43+
!.vscode/settings.json
44+
!.vscode/tasks.json
45+
!.vscode/launch.json
46+
!.vscode/extensions.json
47+
!.vscode/*.code-snippets
48+
49+
# Local History for Visual Studio Code
50+
.history/
51+
52+
# Built Visual Studio Code Extensions
53+
*.vsix
54+
55+
### VisualStudioCode Patch ###
56+
# Ignore all local history of files
57+
.history
58+
.ionide
59+
60+
# End of https://www.toptal.com/developers/gitignore/api/conan,venv,visualstudiocode

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 19 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -5,91 +5,18 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
55

66
project (svgfill)
77

8-
cmake_policy(SET CMP0074 NEW) # find_package() uses <PackageName>_ROOT variables.
9-
if (POLICY CMP0144)
10-
cmake_policy(SET CMP0144 NEW) # find_package() uses upper-case <PACKAGENAME>_ROOT variables.
11-
endif()
12-
13-
include(GNUInstallDirs)
14-
15-
# Specify paths to install files
16-
if(NOT BINDIR)
17-
set(BINDIR bin)
18-
endif()
19-
if(NOT IS_ABSOLUTE ${BINDIR})
20-
set(BINDIR ${CMAKE_INSTALL_BINDIR})
21-
endif()
22-
message(STATUS "BINDIR: ${BINDIR}")
23-
24-
if(NOT INCLUDEDIR)
25-
set(INCLUDEDIR include)
26-
endif()
27-
if(NOT IS_ABSOLUTE ${INCLUDEDIR})
28-
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
29-
endif()
30-
message(STATUS "INCLUDEDIR: ${INCLUDEDIR}")
31-
32-
if(NOT LIBDIR)
33-
set(LIBDIR lib)
34-
endif()
35-
if(NOT IS_ABSOLUTE ${LIBDIR})
36-
set(LIBDIR ${CMAKE_INSTALL_LIBDIR})
37-
endif()
38-
message(STATUS "LIBDIR: ${LIBDIR}")
39-
40-
set(CGAL_LIBRARY_NAMES libCGAL_Core libCGAL_ImageIO libCGAL)
41-
42-
if("${CGAL_INCLUDE_DIR}" STREQUAL "")
43-
set(CGAL_INCLUDE_DIR "/usr/include/" CACHE FILEPATH "CGAL header files")
44-
message(STATUS "Looking for CGAL include files in: ${CGAL_INCLUDE_DIR}")
45-
message(STATUS "Use CGAL_INCLUDE_DIR to specify another directory")
46-
else()
47-
set(CGAL_INCLUDE_DIR ${CGAL_INCLUDE_DIR} CACHE FILEPATH "CGAL header files")
48-
message(STATUS "Looking for CGAL include files in: ${CGAL_INCLUDE_DIR}")
49-
endif()
50-
51-
if(NOT "${CGAL_LIBRARY_DIR}" STREQUAL "")
52-
set(CGAL_LIBRARY_DIR ${CGAL_LIBRARY_DIR} CACHE FILEPATH "CGAL library files")
53-
message(STATUS "Looking for CGAL library files in: ${CGAL_LIBRARY_DIR}")
54-
endif()
55-
568
if(WASM_BUILD)
579
set(CMAKE_FIND_ROOT_PATH_BACKUP "${CMAKE_FIND_ROOT_PATH}")
5810
set(CMAKE_FIND_ROOT_PATH "")
5911
endif()
6012

61-
find_library(libCGAL NAMES CGAL PATHS ${CGAL_LIBRARY_DIR} NO_DEFAULT_PATH)
62-
63-
if(libCGAL)
64-
message(STATUS "CGAL library files found")
65-
foreach(lib ${CGAL_LIBRARY_NAMES})
66-
string(REPLACE libCGAL "${lib}" lib_path "${libCGAL}")
67-
list(APPEND CGAL_LIBRARIES "${lib_path}")
68-
endforeach()
69-
else()
70-
if(NOT "${CGAL_LIBRARY_DIR}" STREQUAL "")
71-
file(GLOB CGAL_LIBRARIES ${CGAL_LIBRARY_DIR}/CGAL*.lib)
72-
list(LENGTH CGAL_LIBRARY_NAMES num_cgal_library_names)
73-
list(LENGTH CGAL_LIBRARIES num_cgal_libraries)
74-
link_directories("${CGAL_LIBRARY_DIR}")
75-
if(NOT "${num_cgal_library_names}" STREQUAL "${num_cgal_libraries}")
76-
message(FATAL_ERROR "Unable to find CGAL library files, aborting")
77-
endif()
78-
message(STATUS "CGAL library files found")
79-
endif()
80-
endif()
81-
82-
find_library(libGMP NAMES gmp mpir PATHS ${GMP_LIBRARY_DIR} NO_DEFAULT_PATH)
83-
find_library(libMPFR NAMES mpfr PATHS ${MPFR_LIBRARY_DIR} NO_DEFAULT_PATH)
84-
if(NOT libGMP)
85-
message(FATAL_ERROR "Unable to find GMP library files, aborting")
86-
endif()
87-
if(NOT libMPFR)
88-
message(FATAL_ERROR "Unable to find MPFR library files, aborting")
89-
endif()
13+
find_package(Boost REQUIRED CONFIG)
14+
find_package(svgpp REQUIRED CONFIG)
15+
find_package(libxml2 REQUIRED CONFIG)
16+
find_package(CGAL REQUIRED CONFIG)
17+
find_package(gmp REQUIRED CONFIG)
18+
find_package(mpfr REQUIRED CONFIG)
9019

91-
list(APPEND CGAL_LIBRARIES "${libMPFR}")
92-
list(APPEND CGAL_LIBRARIES "${libGMP}")
9320

9421
if(WIN32 AND ("$ENV{CONDA_BUILD}" STREQUAL ""))
9522
set(Boost_USE_STATIC_LIBS ON)
@@ -112,31 +39,24 @@ if (MSVC)
11239
add_definitions(-bigobj)
11340
endif()
11441

115-
find_package(Boost)
116-
message(STATUS "Boost include files found in ${Boost_INCLUDE_DIRS}")
117-
11842
if(WASM_BUILD)
11943
set(CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH_BACKUP}")
12044
endif()
12145

12246

123-
124-
include_directories(${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR}
125-
${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/svgpp/include
126-
)
127-
12847
file(GLOB LIB_H_FILES src/*.h)
48+
message(STATUS "Found header files: ${LIB_H_FILES}")
12949
file(GLOB LIB_CPP_FILES src/svgfill.cpp src/arrange_polygons.cpp)
130-
set(LIB_SRC_FILES ${LIB_H_FILES} ${LIB_CPP_FILES})
131-
add_library(svgfill ${LIB_SRC_FILES})
132-
target_link_libraries(svgfill ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES} ${CGAL_LIBRARIES})
50+
51+
add_library(svgfill ${LIB_H_FILES} ${LIB_CPP_FILES})
52+
target_link_libraries(svgfill Boost::boost svgpp::svgpp LibXml2::LibXml2 CGAL::CGAL)
13353

13454
add_executable(svgfill_exe src/main.cpp)
13555
target_link_libraries(svgfill_exe svgfill)
13656
set_property(TARGET svgfill_exe PROPERTY OUTPUT_NAME svgfill)
13757
if(WIN32)
13858
# both the library and the executable now result in a file with basename svgfill,
139-
# on linux the the library is prefixed with lib as libsvgfill.a. Windows does not
59+
# on linux the library is prefixed with lib as libsvgfill.a. Windows does not
14060
# have this mechanism, so on windows the linker would be created an import library
14161
# for the executable, also named svgfill.lib. This naming conflict results in:
14262
# LINK : fatal error LNK1149: output filename matches input filename
@@ -145,6 +65,11 @@ if(WIN32)
14565
target_link_options(svgfill_exe PRIVATE "/NOIMPLIB")
14666
endif()
14767

148-
install(TARGETS svgfill_exe DESTINATION ${BINDIR})
149-
install(TARGETS svgfill DESTINATION ${LIBDIR})
150-
install(FILES ${LIB_H_FILES} DESTINATION ${INCLUDEDIR})
68+
set_target_properties(svgfill PROPERTIES PUBLIC_HEADER ${LIB_H_FILES})
69+
install(TARGETS svgfill)
70+
71+
install(TARGETS svgfill_exe DESTINATION "."
72+
RUNTIME DESTINATION bin
73+
ARCHIVE DESTINATION lib
74+
LIBRARY DESTINATION lib
75+
)

conanfile.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from conan import ConanFile
2+
from conan.tools.build import check_min_cppstd
3+
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
4+
from conan.tools.files import copy
5+
import os
6+
7+
required_conan_version = ">=2.0.9"
8+
9+
class SvgfillConan(ConanFile):
10+
name = "svgfill"
11+
version = "0.1.0"
12+
description = "An application to fill areas bounded by unconnected lines in SVG"
13+
license = "LGPL-2.1-or-later"
14+
url = "https://github.com/conan-io/conan-center-index"
15+
homepage = "https://github.com/IfcOpenShell/svgfill"
16+
topics = ("svg", "ifc")
17+
settings = "os", "arch", "compiler", "build_type"
18+
options = {
19+
"shared": [True, False],
20+
"fPIC": [True, False],
21+
}
22+
default_options = {
23+
"shared": False,
24+
"fPIC": True,
25+
}
26+
implements = ["auto_shared_fpic"]
27+
28+
exports_sources = "CMakeLists.txt", "src/**"
29+
30+
# no exports_sources attribute, but export_sources(self) method instead
31+
# def export_sources(self):
32+
# export_conandata_patches(self)
33+
34+
def layout(self):
35+
cmake_layout(self, src_folder="")
36+
37+
def requirements(self):
38+
self.requires("svgpp/1.3.1")
39+
self.requires("cgal/6.0.1")
40+
self.requires("boost/1.88.0", override=True)
41+
self.requires("libxml2/2.13.8")
42+
self.requires("nlohmann_json/3.12.0")
43+
self.requires("gmp/6.3.0")
44+
self.requires("mpfr/4.2.1")
45+
46+
def validate(self):
47+
check_min_cppstd(self, 17)
48+
49+
def build_requirements(self):
50+
self.tool_requires("cmake/[>=3.16 <4]")
51+
52+
# def source(self):
53+
# get(self, **self.conan_data["sources"][self.version], strip_root=True)
54+
# # Using patches is always the last resort to fix issues. If possible, try to fix the issue in the upstream project.
55+
# apply_conandata_patches(self)
56+
57+
def generate(self):
58+
tc = CMakeToolchain(self)
59+
tc.generate()
60+
61+
deps = CMakeDeps(self)
62+
deps.generate()
63+
64+
def build(self):
65+
cmake = CMake(self)
66+
cmake.configure()
67+
cmake.build()
68+
69+
def package(self):
70+
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
71+
cmake = CMake(self)
72+
cmake.install()

0 commit comments

Comments
 (0)