1 OSG_SET_CACHE(OSG_PYTHON_MODULE_BASE_DIR "" PATH "")
3 MACRO(SETUP_PYTHON_BUILD)
5 # optional pass for test programs
6 IF(OSGBUILD_PYTHON_BINDINGS)
7 LIST(APPEND OSG_CMAKE_PASSES "OSGPYTHON")
8 SET(OSG_PASSDIR_OSGPYTHON "Python")
10 IF(EXISTS ${PYOSG_PYPLUSPLUS_DIR})
11 SET(OSG_HAS_PYOSG_PYPLUSPLUS_DIR "True")
13 SET(OSG_HAS_PYOSG_PYPLUSPLUS_DIR "False")
16 IF(EXISTS ${PYOSG_PYPLUSPLUS_GOODIES_DIR})
17 SET(OSG_HAS_PYOSG_PYPLUSPLUS_GOODIES_DIR "True")
19 SET(OSG_HAS_PYOSG_PYPLUSPLUS_GOODIES_DIR "False")
22 SET(OSG_CAN_REGEN_PYTHON_BINDINGS FALSE)
26 PYOSG_PYPLUSPLUS_DIR AND
27 PYOSG_PYPLUSPLUS_GOODIES_DIR)
29 IF(EXISTS ${GCCXML} AND
30 EXISTS ${PYOSG_DIR} AND
31 EXISTS ${PYOSG_PYPLUSPLUS_DIR} AND
32 EXISTS ${PYOSG_PYPLUSPLUS_GOODIES_DIR})
34 SET(OSG_CAN_REGEN_PYTHON_BINDINGS TRUE)
39 IF(${CMAKE_PROJECT_NAME} STREQUAL "OpenSG")
40 SET(OSG_PYTHON_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/Bindings/Python")
42 SET(OSG_PYTHON_SUPPORT_DIR "${OpenSG_DIR}/share/OpenSG/python")
46 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
47 "${OSG_PYTHON_SUPPORT_DIR}/genLibOrder.py"
48 "${CMAKE_BINARY_DIR}/Python/Helper/genLibOrder.py")
50 FILE(WRITE "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "# Lib order information\n\n\nlibInfo = {}\n\n")
51 FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "fullLibInfo = {}\n\n")
53 IF(EXISTS ${PYOSG_DIR})
56 MESSAGE(STATUS "preparing python")
59 FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Python/Helper")
61 #########################
63 #########################
65 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osggen.py")
66 SET(_OSG_FILE_OUT_PROC "${CMAKE_BINARY_DIR}/Python/Helper/processed/osggen.py.proc")
67 SET(_OSG_FILE_OUT "${CMAKE_BINARY_DIR}/Python/Helper/osggen.py")
68 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Bindings/Python/Patches/osggen.py.patch")
71 COMMAND "${CMAKE_COMMAND}" -E copy
73 "${_OSG_FILE_OUT_PROC}")
75 EXECUTE_PROCESS(COMMAND "patch"
76 INPUT_FILE "${_OSG_PATCH_FILE}"
77 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Python/Helper/processed")
80 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
81 "${_OSG_FILE_OUT_PROC}"
85 #########################
87 #########################
90 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
91 "${OSG_PYTHON_SUPPORT_DIR}/splitGenHelper.py"
92 "${CMAKE_BINARY_DIR}/Python/Helper/splitGenHelper.py")
94 #########################
96 #########################
98 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/settings.py")
99 SET(_OSG_FILE_OUT_PROC "${CMAKE_BINARY_DIR}/Python/Helper/processed/settings.py.proc")
100 SET(_OSG_FILE_OUT "${CMAKE_BINARY_DIR}/Python/Helper/settings.py")
101 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Bindings/Python/Patches/settings.py.patch")
104 COMMAND "${CMAKE_COMMAND}" -E copy
106 "${_OSG_FILE_OUT_PROC}")
108 EXECUTE_PROCESS(COMMAND "patch"
109 INPUT_FILE "${_OSG_PATCH_FILE}"
110 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Python/Helper/processed")
113 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
114 "${_OSG_FILE_OUT_PROC}"
118 IF(CMAKE_PROJECT_NAME STREQUAL "OpenSG")
120 #########################
122 #########################
124 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/PreBoostPython.h")
125 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/processed/PreBoostPython.h.proc")
126 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/PreBoostPython.h")
128 FILE(READ ${_OSG_FILE_IN} _OSG_FILE_IN_DATA)
130 STRING(REPLACE "<OpenSG/"
131 "<" _OSG_FILE_IN_DATA_P1 "${_OSG_FILE_IN_DATA}")
133 FILE(WRITE ${_OSG_FILE_OUT_PROC} "${_OSG_FILE_IN_DATA_P1}")
136 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
137 "${_OSG_FILE_OUT_PROC}"
141 #########################
143 #########################
145 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/OsgPtrHelpers.h")
146 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/processed/OsgPtrHelpers.h.proc")
147 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/OsgPtrHelpers.h")
149 FILE(READ ${_OSG_FILE_IN} _OSG_FILE_IN_DATA)
151 STRING(REPLACE "<OpenSG/"
152 "<" _OSG_FILE_IN_DATA_P1 "${_OSG_FILE_IN_DATA}")
154 FILE(WRITE ${_OSG_FILE_OUT_PROC} "${_OSG_FILE_IN_DATA_P1}")
157 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
158 "${_OSG_FILE_OUT_PROC}"
162 #########################
163 # pypp_OSGBase_aliases.h
164 #########################
166 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/aliases.h")
167 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/processed/pypp_aliases.h.proc")
168 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/pypp_aliases.h")
169 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Bindings/Python/Patches/pypp_aliases.h.patch")
172 COMMAND "${CMAKE_COMMAND}" -E copy
174 "${_OSG_FILE_OUT_PROC}")
176 EXECUTE_PROCESS(COMMAND "patch"
177 INPUT_FILE "${_OSG_PATCH_FILE}"
178 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/processed")
181 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
182 "${_OSG_FILE_OUT_PROC}"
186 #########################
188 #########################
190 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/ColorWrapper.h")
191 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/processed/ColorWrapper.h.proc")
192 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/ColorWrapper.h")
194 FILE(READ ${_OSG_FILE_IN} _OSG_FILE_IN_DATA)
196 STRING(REPLACE "<OpenSG/"
197 "<" _OSG_FILE_IN_DATA_P1 "${_OSG_FILE_IN_DATA}")
199 FILE(WRITE ${_OSG_FILE_OUT_PROC} "${_OSG_FILE_IN_DATA_P1}")
202 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
203 "${_OSG_FILE_OUT_PROC}"
207 #########################
208 # VecStorageWrappers.h
209 #########################
211 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/VecStorageWrappers.h")
212 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/processed/VecStorageWrappers.h.proc")
213 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/VecStorageWrappers.h")
215 FILE(READ ${_OSG_FILE_IN} _OSG_FILE_IN_DATA)
217 STRING(REPLACE "<OpenSG/"
218 "<" _OSG_FILE_IN_DATA_P1 "${_OSG_FILE_IN_DATA}")
220 FILE(WRITE ${_OSG_FILE_OUT_PROC} "${_OSG_FILE_IN_DATA_P1}")
223 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
224 "${_OSG_FILE_OUT_PROC}"
228 #########################
230 #########################
232 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/Wrappers.h")
233 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/processed/BaseWrappers.h.proc")
234 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/BaseWrappers.h")
235 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Patches/wrappers.h.patch")
238 COMMAND "${CMAKE_COMMAND}" -E copy
240 "${_OSG_FILE_OUT_PROC}")
242 EXECUTE_PROCESS(COMMAND "patch"
243 INPUT_FILE "${_OSG_PATCH_FILE}"
244 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/processed")
247 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
248 "${_OSG_FILE_OUT_PROC}"
252 #########################
254 #########################
256 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/Wrappers.cpp")
257 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/processed/BaseWrappers.cpp.proc")
258 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/BaseWrappers.cpp")
259 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Patches/wrappers.cpp.patch")
262 COMMAND "${CMAKE_COMMAND}" -E copy
264 "${_OSG_FILE_OUT_PROC}")
266 EXECUTE_PROCESS(COMMAND "patch"
267 INPUT_FILE "${_OSG_PATCH_FILE}"
268 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Source/Base/Bindings/Python/Wrapper/processed")
271 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
272 "${_OSG_FILE_OUT_PROC}"
277 #########################
279 #########################
281 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/Wrappers.h")
282 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Source/System/Bindings/Python/Wrapper/processed/SystemWrappers.h.proc")
283 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Source/System/Bindings/Python/Wrapper/SystemWrappers.h")
284 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Source/System/Bindings/Python/Patches/wrappers.h.patch")
287 COMMAND "${CMAKE_COMMAND}" -E copy
289 "${_OSG_FILE_OUT_PROC}")
291 EXECUTE_PROCESS(COMMAND "patch"
292 INPUT_FILE "${_OSG_PATCH_FILE}"
293 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Source/System/Bindings/Python/Wrapper/processed")
296 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
297 "${_OSG_FILE_OUT_PROC}"
301 #########################
303 #########################
305 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/Wrappers.cpp")
306 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Source/System/Bindings/Python/Wrapper/processed/SystemWrappers.cpp.proc")
307 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Source/System/Bindings/Python/Wrapper/SystemWrappers.cpp")
308 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Source/System/Bindings/Python/Patches/wrappers.cpp.patch")
311 COMMAND "${CMAKE_COMMAND}" -E copy
313 "${_OSG_FILE_OUT_PROC}")
315 EXECUTE_PROCESS(COMMAND "patch"
316 INPUT_FILE "${_OSG_PATCH_FILE}"
317 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Source/System/Bindings/Python/Wrapper/processed")
320 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
321 "${_OSG_FILE_OUT_PROC}"
325 #########################
327 #########################
329 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/lib/helpers.py")
330 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/processed/helpers.py.proc")
331 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/helpers.py")
332 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Bindings/Python/Patches/helpers.py.patch")
335 COMMAND "${CMAKE_COMMAND}" -E copy
337 "${_OSG_FILE_OUT_PROC}")
339 EXECUTE_PROCESS(COMMAND "patch"
340 INPUT_FILE "${_OSG_PATCH_FILE}"
341 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/processed")
344 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
345 "${_OSG_FILE_OUT_PROC}"
350 #########################
352 #########################
354 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/lib/cored_node.py")
355 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/processed/cored_node.py.proc")
356 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/cored_node.py")
357 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Bindings/Python/Patches/cored_node.py.patch")
360 COMMAND "${CMAKE_COMMAND}" -E copy
362 "${_OSG_FILE_OUT_PROC}")
364 EXECUTE_PROCESS(COMMAND "patch"
365 INPUT_FILE "${_OSG_PATCH_FILE}"
366 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/processed")
369 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
370 "${_OSG_FILE_OUT_PROC}"
374 #########################
376 #########################
378 SET(_OSG_FILE_IN "${PYOSG_DIR}/src/osg_module/lib/fcd_reflector.py")
379 SET(_OSG_FILE_OUT_PROC "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/processed/fcd_reflector.py.proc")
380 SET(_OSG_FILE_OUT "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/fcd_reflector.py")
381 SET(_OSG_PATCH_FILE "${CMAKE_SOURCE_DIR}/Bindings/Python/Patches/fcd_reflector.py.patch")
384 COMMAND "${CMAKE_COMMAND}" -E copy
386 "${_OSG_FILE_OUT_PROC}")
388 EXECUTE_PROCESS(COMMAND "patch"
389 INPUT_FILE "${_OSG_PATCH_FILE}"
390 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/processed")
393 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
394 "${_OSG_FILE_OUT_PROC}"
400 MESSAGE(STATUS "done python")
403 ENDIF(EXISTS ${PYOSG_DIR})
405 SET(_OSG_SRC_PYPATH_HELPERS ${OSG_PYTHON_SUPPORT_DIR}/helpers)
406 SET(_OSG_SRC_PYPATH_OSG ${CMAKE_BINARY_DIR}/Python/lib/osg2/helpers)
408 SET(_OSG_DST_PYPATH_HELPERS ${CMAKE_BINARY_DIR}/Python/lib/osg2/helpers)
409 SET(_OSG_DST_PYPATH_OSG ${CMAKE_BINARY_DIR}/Python/lib/osg2/osg)
411 FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Python/lib/osg2)
412 FILE(MAKE_DIRECTORY ${_OSG_DST_PYPATH_HELPERS})
413 FILE(MAKE_DIRECTORY ${_OSG_DST_PYPATH_OSG})
415 OSG_SYMLINK_CHECKED(${OSG_PYTHON_SUPPORT_DIR}/osg2/__init__.py
416 ${CMAKE_BINARY_DIR}/Python/lib/osg2/__init__.py)
418 OSG_SYMLINK_CHECKED(${_OSG_SRC_PYPATH_HELPERS}/cored_node.py
419 ${_OSG_DST_PYPATH_HELPERS}/cored_node.py)
420 OSG_SYMLINK_CHECKED(${_OSG_SRC_PYPATH_HELPERS}/fcd_reflector.py
421 ${_OSG_DST_PYPATH_HELPERS}/fcd_reflector.py)
422 OSG_SYMLINK_CHECKED(${_OSG_SRC_PYPATH_HELPERS}/helpers.py
423 ${_OSG_DST_PYPATH_HELPERS}/helpers.py)
424 OSG_SYMLINK_CHECKED(${_OSG_SRC_PYPATH_HELPERS}/__init__.py
425 ${_OSG_DST_PYPATH_HELPERS}/__init__.py)
427 IF(${CMAKE_PROJECT_NAME} STREQUAL "OpenSG")
428 SET(OSG_PYTHON_COMMON_INCDIR "${CMAKE_SOURCE_DIR}/Bindings/Python/Common" CACHE PATH "" FORCE)
430 SET(OSG_PYTHON_COMMON_INCDIR "${OpenSG_DIR}/include/OpenSG/Bindings/Python/Common" CACHE PATH "" FORCE)
433 ADD_CUSTOM_TARGET(OSGPy)
435 IF(OSG_CAN_REGEN_PYTHON_BINDINGS)
436 ADD_CUSTOM_TARGET(OSGPyGen)
438 # ADD_CUSTOM_TARGET(OSGPyBuild)
440 ENDIF(OSGBUILD_PYTHON_BINDINGS)
444 MACRO(INSTALL_PYTHON_ELEMENTS)
446 # Neverthless install bindings common headers
447 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/PreBoostPython.h"
448 "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/OsgPtrHelpers.h"
449 "${CMAKE_SOURCE_DIR}/Bindings/Python/Common/pypp_aliases.h"
450 DESTINATION include/OpenSG/Bindings/Python/Common)
452 INSTALL(FILES "${CMAKE_SOURCE_DIR}/CMake/OSGSetupPython.cmake"
453 DESTINATION share/OpenSG/cmake)
455 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/genLibOrder.py"
456 DESTINATION share/OpenSG/python/)
458 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/splitGenHelper.py"
459 DESTINATION share/OpenSG/python/)
461 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/osgGenBindings.py.in"
462 DESTINATION share/OpenSG/python/)
464 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/__init__.py.in"
465 DESTINATION share/OpenSG/python/)
467 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/osg2/__init__.py"
468 DESTINATION share/OpenSG/python/osg2)
470 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/cored_node.py"
471 DESTINATION share/OpenSG/python/helpers)
473 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/fcd_reflector.py"
474 DESTINATION share/OpenSG/python/helpers)
476 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/helpers.py"
477 DESTINATION share/OpenSG/python/helpers)
479 INSTALL(FILES "${CMAKE_SOURCE_DIR}/Bindings/Python/helpers/__init__.py"
480 DESTINATION share/OpenSG/python/helpers)