forked from CGAL/cgal-swig-bindings
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
163 lines (144 loc) · 7.01 KB
/
CMakeLists.txt
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
cmake_minimum_required(VERSION 2.8)
PROJECT(CGAL-bindings)
if(POLICY CMP0017)
# New policy in cmake-2.8.3
cmake_policy(SET CMP0017 NEW)
endif()
option ( LINK_PYTHON_LIBRARY "Link against python libraries" ON )
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/SWIG_CGAL_Macros.cmake)
find_package(CGAL QUIET COMPONENTS ImageIO)
find_package(SWIG REQUIRED)
option( BUILD_PYTHON "Build Python bindings" ON )
option( BUILD_JAVA "Build Java bindings" ON )
#set it to OFF by default while it is not fully tested and thus officially supported
option( BUILD_RUBY "Build Ruby bindings" OFF )
enable_testing ()
macro ( cgal_python_test TESTNAME_SRC )
get_filename_component(TESTNAME ${TESTNAME_SRC} NAME_WE)
add_test( ${TESTNAME} ${PYTHON_EXECUTABLE} ${TESTNAME_SRC} )
set_tests_properties ( ${TESTNAME} PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_OUTDIR_PREFIX};DATADIR=${CMAKE_CURRENT_SOURCE_DIR}/examples/data" )
endmacro ()
if ( CGAL_FOUND )
include( ${CGAL_USE_FILE} )
if ("${CGAL_MAJOR_VERSION}" STREQUAL "4" AND "${CGAL_MINOR_VERSION}" STREQUAL "0")
MESSAGE(STATUS "Using patches for CGAL-4.0")
include_directories(BEFORE patches_for_CGAL_4.0/include)
endif()
if ("${CGAL_MAJOR_VERSION}" STREQUAL "4" AND "${CGAL_MINOR_VERSION}" STRLESS "2")
MESSAGE(STATUS "Using patches from CGAL-4.2")
include_directories(BEFORE patches_in_CGAL_4.2/include)
endif()
if (${CMAKE_BUILD_TYPE} STREQUAL Release)
if(CMAKE_COMPILER_IS_GNUCXX)
message (STATUS "Release mode with g++: using -fno-strict-aliasing flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
endif()
endif()
if (SWIG_FOUND)
SET (UseSWIG ON)
INCLUDE(${SWIG_USE_FILE})
SET(CMAKE_SWIG_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if (${BUILD_RUBY})
FIND_PACKAGE(Ruby)
if (NOT RUBY_FOUND)
message(WARNING "Ruby has not been found, CGAL-bindings for Ruby will not be generated.")
SET(BUILD_RUBY OFF)
endif()
else()
message(STATUS "BUILD_RUBY is set to OFF: no CGAL-bindings for Ruby will be generated.")
endif()
if (${BUILD_PYTHON})
FIND_PACKAGE(PythonLibs)
find_package(PythonInterp)
if (NOT PYTHONLIBS_FOUND)
SET(BUILD_PYTHON OFF)
message(WARNING "Python has not been found, CGAL-bindings for Python will not be generated.")
endif()
else()
message(STATUS "BUILD_PYTHON is set to OFF: no CGAL-bindings for Python will be generated.")
endif()
if (${BUILD_JAVA})
FIND_PACKAGE(JNI)
if (NOT JAVA_INCLUDE_PATH)
message(WARNING "JNI has not been found, CGAL-bindings for Java will not be generated.")
SET(BUILD_JAVA OFF)
endif()
else()
message(STATUS "BUILD_JAVA is set to OFF: no CGAL-bindings for Java will be generated.")
endif()
SET (COMMON_LIBRARIES_PATH "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE PATH "Path where libraries common to all target languages are created.")
if (RUBY_FOUND)
SET (RUBY_OUTDIR_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/build-ruby" CACHE PATH "RUBY specific files output directory prefix: the CGAL directory will contain Ruby generated files and libraries.")
LINK_DIRECTORIES("${RUBY_OUTDIR_PREFIX}/CGAL")
MESSAGE(STATUS "Found Ruby libs.")
MESSAGE(STATUS "CGAL-SWIG Ruby files and libraries will be written in ${RUBY_OUTDIR_PREFIX}/CGAL.")
endif()
if (PYTHONLIBS_FOUND)
if ( PYTHON_EXECUTABLE )
file (GLOB python_files "${CMAKE_CURRENT_SOURCE_DIR}/examples/python/*.py" )
foreach(python_file ${python_files})
cgal_python_test(${python_file})
endforeach()
endif ()
SET (PYTHON_OUTDIR_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/build-python" CACHE PATH "PYTHON specific files output directory prefix: the CGAL directory will contain Python generated files and libraries.")
SET(PYTHON_INSTALL_PREFIX_DEBUG "${CMAKE_INSTALL_PREFIX}/cgal-bindings_d/CGAL")
SET(PYTHON_INSTALL_PREFIX_RELEASE "${CMAKE_INSTALL_PREFIX}/cgal-bindings/CGAL")
configure_file(SWIG_CGAL/files/__init__.py "${PYTHON_OUTDIR_PREFIX}/CGAL/__init__.py" @ONLY)
LINK_DIRECTORIES("${PYTHON_OUTDIR_PREFIX}/CGAL")
MESSAGE(STATUS "Found Python libs.")
MESSAGE(STATUS "CGAL-SWIG Python files and libraries will be written in ${PYTHON_OUTDIR_PREFIX}/CGAL.")
endif()
if (JAVA_INCLUDE_PATH)
SET (JAVA_OUTDIR_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/build-java/" CACHE PATH "Java specific files output directory prefix: Java files in CGAL directory, libraries in lib directory.")
SET (JAVALIBPATH "${JAVA_OUTDIR_PREFIX}/lib")
MESSAGE(STATUS "Found JNI: JNI include dirs ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}.")
MESSAGE(STATUS "CGAL-SWIG Java libraries and files will be respectively written in ${JAVALIBPATH} and ${JAVA_OUTDIR_PREFIX}/CGAL.")
endif()
MESSAGE(STATUS "Now adding packages")
add_subdirectory(SWIG_CGAL/Kernel)
add_subdirectory(SWIG_CGAL/Java)
add_subdirectory(SWIG_CGAL/Triangulation_3)
add_subdirectory(SWIG_CGAL/Triangulation_2)
add_subdirectory(SWIG_CGAL/Polyhedron_3)
add_subdirectory(SWIG_CGAL/Alpha_shape_2)
add_subdirectory(SWIG_CGAL/Spatial_searching)
add_subdirectory(SWIG_CGAL/AABB_tree)
if (CGAL_ImageIO_FOUND)
add_subdirectory(SWIG_CGAL/Surface_mesher)
else()
message(STATUS "NOTICE: CGAL imageIO has not be found, few bindings will not be compiled")
endif()
add_subdirectory(SWIG_CGAL/Mesh_3)
add_subdirectory(SWIG_CGAL/Mesh_2)
add_subdirectory(SWIG_CGAL/Interpolation)
add_subdirectory(SWIG_CGAL/Convex_hull_2)
#filter Voronoi diagram bindings
find_path(CGAL_VOR_BASIC_H "CGAL/Voronoi_diagram_2/basic.h" ${CGAL_INCLUDE_DIRS} NO_DEFAULT_PATH)
if ("${CGAL_VOR_BASIC_H}" STREQUAL "CGAL_VOR_BASIC_H-NOTFOUND")
MESSAGE(STATUS "Using CGAL-4.0, Voronoi_diagram_2 bindings won't be available.")
else()
add_subdirectory(SWIG_CGAL/Voronoi_diagram_2)
endif()
add_subdirectory(SWIG_CGAL/HalfedgeDS)
add_subdirectory(SWIG_CGAL/Point_set_processing_3)
add_subdirectory(SWIG_CGAL/Box_intersection_d)
if ("${CGAL_MAJOR_VERSION}" STRGREATER "3" AND "${CGAL_MINOR_VERSION}" STRGREATER "6")
find_package(Eigen3 3.2.0) #(requires 3.2.0 or greater)
if (EIGEN3_FOUND)
include( ${EIGEN3_USE_FILE} )
add_subdirectory(SWIG_CGAL/Polygon_mesh_processing)
else()
MESSAGE(STATUS "Eigen 3.2 or later was not found, Polygon_mesh_processing bindings will not be available")
endif(EIGEN3_FOUND)
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/SWIG_CGAL/User_packages/CMakeLists.txt")
MESSAGE(STATUS "Found SWIG_CGAL/User_packages/CMakeLists.txt, user packages will be built.")
add_subdirectory(SWIG_CGAL/User_packages)
endif()
else()
message(STATUS "NOTICE: CGAL-bindings requires the SWIG include files and binary program, and will not be compiled.")
endif()
else()
message(STATUS "NOTICE: CGAL-bindings requires the CGAL library, and will not be compiled.")
endif()