forked from openalea/plantgl
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
211 lines (153 loc) · 5.8 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# --- CMake Modules
cmake_minimum_required(VERSION 3.12)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include("Anaconda")
include("PglConfig")
include("PglWrapper")
include("detectPlantGL")
# --- PlantGL Project
project(plantgl CXX)
# --- Build setup
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
# --- CXX11 Compilation
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
# --- Config Header File
init_cpp_config("${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/plantgl/userconfig.h")
init_py_config("${CMAKE_CURRENT_SOURCE_DIR}/src/openalea/plantgl/config.py")
# --- (Win32) Multithreaded Compilation
if (MSVC)
string(REGEX REPLACE "/W3" "/W0" ${CMAKE_CXX_FLAGS} "${${CMAKE_CXX_FLAGS}}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MD")
# To fix compilation error with vc14 and boost
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DHAVE_SNPRINTF")
endif()
# --- PlantGL Configuration
detect_plantgl_version(${CMAKE_CURRENT_SOURCE_DIR}/src/cpp)
message(STATUS "PlantGL version : " ${PGL_VERSION_STR})
define_py_macro(PGL_VERSION ${PGL_VERSION})
define_py_macro(PGL_VERSION_STR "'${PGL_VERSION_STR}'")
define_py_macro(PGL_USE_DOUBLE "True")
define_cpp_macro(PGL_USE_DOUBLE 1)
## ###################################################################
## Dependencies
## ###################################################################
# --- Python
set(Python3_FIND_VIRTUALENV FIRST)
if (WIN32)
# needed when we run cmake in a conda environment
set(Python3_FIND_REGISTRY LAST)
endif()
find_package (Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
include_directories(${Python3_INCLUDE_DIRS})
message(STATUS "Python version : " ${Python3_VERSION})
message(STATUS "Python executable : " ${Python3_EXECUTABLE})
message(STATUS "Python lib : " ${Python3_LIBRARIES})
# --- Libraries
find_package(Threads REQUIRED)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Network OpenGL PrintSupport)
if(Qt6_FOUND)
find_package(Qt6 REQUIRED COMPONENTS Gui OpenGLWidgets Test)
endif()
find_library(METAL Metal)
define_cpp_macro(PGL_QT_VERSION ${QT_VERSION_MAJOR})
define_py_macro(PGL_WITHOUT_QT "False")
define_py_macro(PGL_QT_VERSION ${QT_VERSION_MAJOR})
set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS OFF)
set(BUILD_SHARED_LIBS ON)
set(boost_python python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
set(boost_numpy numpy${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
find_package(ZLIB REQUIRED)
find_package(OpenGL REQUIRED)
find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)
find_package(CGAL)
find_package(ANN)
find_package(BISON)
find_package(Eigen)
find_package(FLEX)
find_library(QHULL_LIBRARY NAMES "libqhullstatic.a" PATHS $ENV{CONDA_PREFIX}/lib)
find_package(Qhull)
#if (USE_CONDA_BUILD)
#if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
# find_library(LIBSELINUX_LIBRARY "selinux" PATHS $ENV{BUILD_PREFIX}/x86_64-conda-linux-gnu/sysroot/lib64 $ENV{BUILD_PREFIX}/x86_64-conda_cos6-linux-gnu/sysroot/lib64 REQUIRED)
# message(STATUS "Found libselinux: ${LIBSELINUX_LIBRARY}")
#endif()
#endif()
find_package(Boost 1.69 COMPONENTS thread system chrono ${boost_python} ${boost_numpy})
if (Boost_FOUND)
# Build with Boost
define_cpp_macro(PGL_WITH_BOOST 1)
if(DEFINED Boost_NUMPY_FOUND)
define_macro(PGL_WITH_BOOST_NUMPY 1)
set(USE_BOOST_NUMPY ON)
message(STATUS "Building with Boost.Numpy")
elseif(DEFINED Boost_NUMPY${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}_FOUND)
define_macro(PGL_WITH_BOOST_NUMPY 1)
set(USE_BOOST_NUMPY ON)
message(STATUS "Building with Boost.Numpy")
else()
define_macro(PGL_WITH_BOOST_NUMPY 0)
set(USE_BOOST_NUMPY OFF)
message(STATUS "Building without Boost.Numpy - Library not found.")
endif()
set(USE_BOOST ON)
include_directories(${Boost_INCLUDE_DIR})
else()
define_py_macro(PGL_WITH_BOOST 0)
set(USE_BOOST OFF)
set(USE_BOOST_NUMPY OFF)
message(STATUS "Building without Boost - Library not found.")
endif()
if (BISON_FOUND AND FLEX_FOUND)
# Build with Bison and Flex
define_cpp_macro(PGL_WITH_FLEX 1)
define_cpp_macro(PGL_WITH_BISON 1)
define_cpp_macro(PGL_BISON_HPP 1)
define_py_macro(PGL_WITH_BISONFLEX "True")
else()
message(STATUS "Build PlantGL without Bison/Flex - Not found.")
define_py_macro(PGL_WITH_BISONFLEX "False")
endif()
if (CGAL_FOUND)
# Build with CGAL
define_cpp_macro(PGL_WITH_CGAL 1)
define_py_macro(PGL_WITH_CGAL "True")
message(STATUS "Build PlantGL with CGAL")
if (DEFINED GMP_LIBRARIES)
define_macro(PGL_CGAL_USE_GMP 1)
message(STATUS "Build PlantGL with GMP")
else()
message(STATUS "Build PlantGL without GMP - Library not found. Use CGAL without it.")
endif()
else()
message(STATUS "Build PlantGL without CGAL - Library not found.")
define_py_macro(PGL_WITH_CGAL "False")
endif()
# --- Include Directories
include_directories("src/cpp")
include_directories(${PNG_INCLUDE_DIRS})
include_directories(${ZLIB_INCLUDE_DIRS})
include_directories(${OPENGL_INCLUDE_DIR})
# --- Library Directory
if (DEFINED CONDA_ENV)
link_directories("${CONDA_ENV}/lib")
endif()
# --- Source Directories
add_subdirectory("src/cpp")
if (Boost_FOUND)
add_subdirectory("src/wrapper")
endif()
install_share("share/plantgl" "plantgl")