-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibCGAL.mk
139 lines (110 loc) · 5.41 KB
/
libCGAL.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# A minimal makefile that mimics the cmake process in CGAL
MAJOR_VERSION := 13
MINOR_VERSION := 0.1
VERSION := $(MAJOR_VERSION).$(MINOR_VERSION)
COMPAT_VERSION := $(MAJOR_VERSION).0.0
PHOENIX_DIR ?= $(shell pwd | sed "s/\(phoenix\).*/\1/g")
CGAL_DIR := $(PHOENIX_DIR)/contrib/cgal
# ----------------------------------------------------------------------
# Build miniconda info
MINICONDA_LOC := $(shell conda info --root)
MINICONDA_LIBS := $(MINICONDA_LOC)/lib
MINICONDA_INCLUDE := $(MINICONDA_LOC)/include
# ----------------------------------------------------------------------
# Build boost lib locations
BOOST_ROOT ?= $(MINICONDA_LOC)
BOOST_INCLUDE := $(BOOST_ROOT)/include
BOOST_LIB := $(BOOST_ROOT)/lib
# ----------------------------------------------------------------------
# Library names
CGAL_DYLIB := $(CGAL_DIR)/libCGAL-$(METHOD).la
CGAL_CORE_DYLIB := $(CGAL_DIR)/libCGAL_Core-$(METHOD).la
# ----------------------------------------------------------------------
# Find CGAL source files
CGAL_SRC_FILES := $(shell find $(CGAL_DIR)/Installation/src/CGAL -name "*.cpp")
CGAL_SRC_FILES += $(shell find $(CGAL_DIR)/Intersections_2/src/CGAL -name "*.cpp")
CGAL_SRC_FILES += $(shell find $(CGAL_DIR)/Kernel_23/src/CGAL -name "*.cpp")
CGAL_SRC_FILES += $(shell find $(CGAL_DIR)/Kinetic_data_structures/src/CGAL -name "*.cpp")
CGAL_SRC_FILES += $(shell find $(CGAL_DIR)/Number_types/src/CGAL -name "*.cpp")
CGAL_SRC_FILES += $(shell find $(CGAL_DIR)/Profiling_tools/src/CGAL -name "*.cpp")
CGAL_SRC_FILES += $(shell find $(CGAL_DIR)/Random_numbers/src/CGAL -name "*.cpp")
CGAL_SRC_FILES += $(shell find $(CGAL_DIR)/STL_Extension/src/CGAL -name "*.cpp")
CGAL_SRC_FILES += $(shell find $(CGAL_DIR)/Stream_support/src/CGAL -name "*.cpp")
CGAL_OBJ_FILES := $(patsubst %.cpp, %.$(obj-suffix), $(CGAL_SRC_FILES))
CGAL_deps := $(patsubst %.$(obj-suffix), %.$(obj-suffix).d, $(CGAL_OBJ_FILES))
# ----------------------------------------------------------------------
# Find CGAL_Core source files
CGAL_CORE_SRC_FILES := $(shell find $(CGAL_DIR)/CGAL_Core/src/CGAL_Core -name "*.cpp")
CGAL_CORE_OBJ_FILES := $(patsubst %.cpp, %.$(obj-suffix), $(CGAL_CORE_SRC_FILES))
CGAL_CORE_deps := $(patsubst %.$(obj-suffix), %.$(obj-suffix).d, $(CGAL_CORE_OBJ_FILES))
# Additional includes needed
app_INCLUDES += -I$(MINICONDA_INCLUDE)
app_INCLUDES += -I$(BOOST_INCLUDE)
app_INCLUDES += -I$(CGAL_DIR)/include
app_INCLUDES += -I$(CGAL_DIR)/Algebraic_foundations/include
app_INCLUDES += -I$(CGAL_DIR)/Arithmetic_kernel/include
app_INCLUDES += -I$(CGAL_DIR)/Cartesian_kernel/include
app_INCLUDES += -I$(CGAL_DIR)/CGAL_Core/include
app_INCLUDES += -I$(CGAL_DIR)/Distance_2/include
app_INCLUDES += -I$(CGAL_DIR)/Distance_3/include
app_INCLUDES += -I$(CGAL_DIR)/Installation/include
app_INCLUDES += -I$(CGAL_DIR)/Intersections_2/include
app_INCLUDES += -I$(CGAL_DIR)/Intersections_3/include
app_INCLUDES += -I$(CGAL_DIR)/Interval_support/include
app_INCLUDES += -I$(CGAL_DIR)/Kernel_23/include
app_INCLUDES += -I$(CGAL_DIR)/Kinetic_data_structures/include
app_INCLUDES += -I$(CGAL_DIR)/Modular_arithmetic/include
app_INCLUDES += -I$(CGAL_DIR)/Number_types/include
app_INCLUDES += -I$(CGAL_DIR)/Profiling_tools/include
app_INCLUDES += -I$(CGAL_DIR)/Random_numbers/include
app_INCLUDES += -I$(CGAL_DIR)/STL_Extension/include
app_INCLUDES += -I$(CGAL_DIR)/Stream_support/include
# ----------------------------------------------------------------------
# Build compiler flags for both object files that are used in the cgal
# code
CGAL_LICENSE_FLAG = -DCGAL_LICENSE_WARNING
# CGAL_LICENSE_FLAG = -DCGAL_LICENSE_ERROR
CGAL_DEFINES := CGAL_EXPORTS
CGAL_DEFINES += CGAL_USE_GMP
CGAL_DEFINES += CGAL_USE_MPFR
CXX_DEFINES := $(addprefix -D, $(CGAL_DEFINES))
# ----------------------------------------------------------------------
# Build rules
.PHONY: cleanCGAL
# build CGAL dylib
$(CGAL_DYLIB) : $(CGAL_OBJ_FILES)
@echo "Linking Library "$@"..."
@$(libmesh_LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link --quiet \
$(libmesh_CC) $(libmesh_CFLAGS) -o $@ $(CGAL_OBJ_FILES) $(libmesh_LDFLAGS) $(EXTERNAL_FLAGS) -rpath $(CGAL_DIR)
@$(libmesh_LIBTOOL) --mode=install --quiet install -c $(CGAL_DYLIB) $(CGAL_DIR)
# build CGAL_Core dylib
$(CGAL_CORE_DYLIB) : $(CGAL_DYLIB) $(CGAL_CORE_OBJ_FILES)
@echo "Linking Library "$@"..."
@$(libmesh_LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link --quiet \
$(libmesh_CC) $(libmesh_CFLAGS) -o $@ $(CGAL_CORE_OBJ_FILES) $(libmesh_LDFLAGS) $(EXTERNAL_FLAGS) $(CGAL_DYLIB) -rpath $(CGAL_DIR)
@$(libmesh_LIBTOOL) --mode=install --quiet install -c $(CGAL_CORE_DYLIB) $(CGAL_DIR)
app_LIBS += $(CGAL_CORE_DYLIB)
app_LIBS += $(CGAL_DYLIB)
ADDITIONAL_CPPFLAGS += $(CGAL_LICENSE_FLAG)
ADDITIONAL_CPPFLAGS += $(CXX_DEFINES)
ADDITIONAL_CPPFLAGS += -Wno-parentheses-equality
ADDITIONAL_LIBS += $(CGAL_CORE_DYLIB)
ADDITIONAL_LIBS += $(CGAL_DYLIB)
# gmp, mpfr
ADDITIONAL_LIBS += -Wl,-rpath,$(MINICONDA_LIBS) -L$(MINICONDA_LIBS) -lgmp -lmpfr
# boost
ADDITIONAL_LIBS += -Wl,-rpath,$(BOOST_LIB) -L$(BOOST_LIB) -lboost_thread -lboost_system -lboost_chrono -lboost_date_time -lboost_atomic
$(app_EXEC): $(CGAL_CORE_DYLIB) $(CGAL_DYLIB)
-include $(CGAL_CORE_deps)
-include $(CGAL_deps)
cleanCGAL:
@echo "Cleaning CGAL"
@rm -f $(CGAL_OBJ_FILES)
@rm -f $(CGAL_deps)
@rm -f $(CGAL_DYLIB)
@rm -f $(CGAL_CORE_OBJ_FILES)
@rm -f $(CGAL_deps)
@rm -f $(CGAL_CORE_DYLIB)
@rm -f $(CGAL_DIR)/libCGAL*-$(METHOD)*.dylib
@rm -f $(CGAL_DIR)/libCGAL*-$(METHOD)*.so*
@rm -f $(CGAL_DIR)/libCGAL*-$(METHOD)*.a