/usr/lib/cmake/paraview/vtkWrapPython.cmake is in paraview-dev 5.0.1+dfsg1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | #
# CMake implementation of the Wrap Python command.
#
macro(VTK_WRAP_PYTHON2 TARGET SOURCE_LIST_NAME)
# convert to the WRAP3 signature
vtk_wrap_python3(${TARGET} ${SOURCE_LIST_NAME} "${ARGN}")
endmacro()
macro(VTK_WRAP_PYTHON3 TARGET SRC_LIST_NAME SOURCES)
if(NOT VTK_WRAP_PYTHON_INIT_EXE)
if(TARGET vtkWrapPythonInit)
set(VTK_WRAP_PYTHON_INIT_EXE vtkWrapPythonInit)
else()
message(SEND_ERROR
"VTK_WRAP_PYTHON_INIT_EXE not specified when calling vtk_wrap_python")
endif()
endif()
if(NOT VTK_WRAP_PYTHON_EXE)
if(TARGET vtkWrapPython)
set(VTK_WRAP_PYTHON_EXE vtkWrapPython)
else()
message(SEND_ERROR
"VTK_WRAP_PYTHON_EXE not specified when calling vtk_wrap_python")
endif()
endif()
# Initialize the custom target counter.
if(VTK_WRAP_PYTHON_NEED_CUSTOM_TARGETS)
set(VTK_WRAP_PYTHON_CUSTOM_COUNT "")
set(VTK_WRAP_PYTHON_CUSTOM_NAME ${TARGET})
set(VTK_WRAP_PYTHON_CUSTOM_LIST)
endif()
# start writing the input file for the init file
set(VTK_WRAPPER_INIT_DATA "${TARGET}")
# collect the common wrapper-tool arguments
set(_common_args)
if(VTK_WRAP_HINTS)
set(_common_args "${_common_args}--hints \"${VTK_WRAP_HINTS}\"\n")
endif()
if(KIT_HIERARCHY_FILE)
set(_common_args "${_common_args}--types \"${KIT_HIERARCHY_FILE}\"\n")
endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.1 AND NOT VTK_ENABLE_KITS)
# write wrapper-tool arguments to a file
set(_args_file ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.$<CONFIGURATION>.args)
file(GENERATE OUTPUT ${_args_file} CONTENT "${_common_args}
$<$<BOOL:$<TARGET_PROPERTY:${TARGET},COMPILE_DEFINITIONS>>:
-D\"$<JOIN:$<TARGET_PROPERTY:${TARGET},COMPILE_DEFINITIONS>,\"
-D\">\">
$<$<BOOL:$<TARGET_PROPERTY:${TARGET},INCLUDE_DIRECTORIES>>:
-I\"$<JOIN:$<TARGET_PROPERTY:${TARGET},INCLUDE_DIRECTORIES>,\"
-I\">\">
")
else()
# all the include directories
string(REGEX REPLACE "Python\$" "" module "${TARGET}")
if(${module}_INCLUDE_DIRS)
set(TMP_INCLUDE_DIRS ${${module}_INCLUDE_DIRS})
elseif(VTK_WRAP_INCLUDE_DIRS)
set(TMP_INCLUDE_DIRS ${VTK_WRAP_INCLUDE_DIRS})
else()
set(TMP_INCLUDE_DIRS ${VTK_INCLUDE_DIRS})
endif()
if(EXTRA_PYTHON_INCLUDE_DIRS)
list(APPEND TMP_INCLUDE_DIRS ${EXTRA_PYTHON_INCLUDE_DIRS})
endif()
foreach(INCLUDE_DIR ${TMP_INCLUDE_DIRS})
set(_common_args "${_common_args}-I\"${INCLUDE_DIR}\"\n")
endforeach()
get_directory_property(_def_list DEFINITION COMPILE_DEFINITIONS)
foreach(TMP_DEF ${_def_list})
set(_common_args "${_common_args}-D${TMP_DEF}\n")
endforeach()
# write wrapper-tool arguments to a file
string(STRIP "${_common_args}" CMAKE_CONFIGURABLE_FILE_CONTENT)
set(_args_file ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.args)
configure_file(${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in
${_args_file} @ONLY)
endif()
# for each class
foreach(FILE ${SOURCES})
# should we wrap the file?
get_source_file_property(TMP_EXCLUDE_PYTHON ${FILE} WRAP_EXCLUDE_PYTHON)
# if we should wrap it
if(NOT TMP_EXCLUDE_PYTHON)
# what is the filename without the extension
get_filename_component(TMP_FILENAME ${FILE} NAME_WE)
# the input file might be full path so handle that
get_filename_component(TMP_FILEPATH ${FILE} PATH)
# compute the input filename
if(TMP_FILEPATH)
set(TMP_INPUT ${TMP_FILEPATH}/${TMP_FILENAME}.h)
else()
set(TMP_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${TMP_FILENAME}.h)
endif()
# add the info to the init file
set(VTK_WRAPPER_INIT_DATA
"${VTK_WRAPPER_INIT_DATA}\n${TMP_FILENAME}")
# new source file is namePython.cxx, add to resulting list
list(APPEND ${SRC_LIST_NAME} ${TMP_FILENAME}Python.cxx)
# add custom command to output
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TMP_FILENAME}Python.cxx
DEPENDS ${VTK_WRAP_PYTHON_EXE}
${VTK_WRAP_HINTS}
${TMP_INPUT}
${_args_file}
${KIT_HIERARCHY_FILE}
COMMAND ${VTK_WRAP_PYTHON_EXE}
@${_args_file}
-o ${CMAKE_CURRENT_BINARY_DIR}/${TMP_FILENAME}Python.cxx
${TMP_INPUT}
COMMENT "Python Wrapping - generating ${TMP_FILENAME}Python.cxx"
VERBATIM
)
# Add this output to a custom target if needed.
if(VTK_WRAP_PYTHON_NEED_CUSTOM_TARGETS)
set(VTK_WRAP_PYTHON_CUSTOM_LIST ${VTK_WRAP_PYTHON_CUSTOM_LIST}
${CMAKE_CURRENT_BINARY_DIR}/${TMP_FILENAME}Python.cxx)
set(VTK_WRAP_PYTHON_CUSTOM_COUNT ${VTK_WRAP_PYTHON_CUSTOM_COUNT}x)
if(VTK_WRAP_PYTHON_CUSTOM_COUNT MATCHES "^${VTK_WRAP_PYTHON_CUSTOM_LIMIT}$")
set(VTK_WRAP_PYTHON_CUSTOM_NAME ${VTK_WRAP_PYTHON_CUSTOM_NAME}Hack)
add_custom_target(${VTK_WRAP_PYTHON_CUSTOM_NAME}
DEPENDS ${VTK_WRAP_PYTHON_CUSTOM_LIST})
set(KIT_PYTHON_DEPS ${VTK_WRAP_PYTHON_CUSTOM_NAME})
set(VTK_WRAP_PYTHON_CUSTOM_LIST)
set(VTK_WRAP_PYTHON_CUSTOM_COUNT)
endif()
endif()
else()
# message("${TMP_FILENAME} will not be wrapped.")
endif()
endforeach()
# finish the data file for the init file
configure_file(
${VTK_CMAKE_DIR}/vtkWrapperInit.data.in
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}Init.data
@ONLY
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}Init.cxx
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}InitImpl.cxx
DEPENDS ${VTK_WRAP_PYTHON_INIT_EXE}
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}Init.data
COMMAND ${VTK_WRAP_PYTHON_INIT_EXE}
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}Init.data
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}Init.cxx
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}InitImpl.cxx
COMMENT "Python Wrapping - generating ${TARGET}Init.cxx"
VERBATIM
)
# Create the Init File
set(${SRC_LIST_NAME} ${${SRC_LIST_NAME}} ${TARGET}InitImpl.cxx)
endmacro()
if(VTK_WRAP_PYTHON_FIND_LIBS)
get_filename_component(_CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
find_package(PythonLibs)
# Use separate debug/optimized libraries if they are different.
if(PYTHON_DEBUG_LIBRARY)
if("${PYTHON_DEBUG_LIBRARY}" STREQUAL "${PYTHON_LIBRARY}")
set(VTK_PYTHON_LIBRARIES ${PYTHON_LIBRARY})
else()
set(VTK_PYTHON_LIBRARIES
optimized ${PYTHON_LIBRARY}
debug ${PYTHON_DEBUG_LIBRARY})
endif()
set(VTK_WINDOWS_PYTHON_DEBUGGABLE 0)
if(WIN32)
if(PYTHON_DEBUG_LIBRARY MATCHES "_d")
set(VTK_WINDOWS_PYTHON_DEBUGGABLE 1)
endif()
endif()
else()
set(VTK_PYTHON_LIBRARIES ${PYTHON_LIBRARY})
endif()
# Some python installations on UNIX need to link to extra libraries
# such as zlib (-lz). It is hard to automatically detect the needed
# libraries so instead just give the user an easy way to specify
# the libraries. This should be needed only rarely. It should
# also be moved to the CMake FindPython.cmake module at some point.
if(UNIX)
if(NOT DEFINED PYTHON_EXTRA_LIBS)
set(PYTHON_EXTRA_LIBS "" CACHE STRING
"Extra libraries to link when linking to python (such as \"z\" for zlib). Separate multiple libraries with semicolons.")
mark_as_advanced(PYTHON_EXTRA_LIBS)
endif()
endif()
# Include any extra libraries for python.
set(VTK_PYTHON_LIBRARIES ${VTK_PYTHON_LIBRARIES} ${PYTHON_EXTRA_LIBS})
endif()
# Determine the location of the supplied header in the include_dirs supplied.
macro(vtk_find_header header include_dirs full_path)
unset(${full_path})
foreach(_dir ${include_dirs})
if(EXISTS "${_dir}/${header}")
set(${full_path} "${_dir}/${header}")
break()
endif()
endforeach()
endmacro()
# Macro that just takes the name of the module, figure the rest out from there.
macro(vtk_wrap_python TARGET SRC_LIST_NAME module)
# List of all headers to wrap.
set(headers_to_wrap)
# Decide what to do for each header.
foreach(header ${${module}_HEADERS})
# Everything in this block is for headers that will be wrapped.
if(NOT ${module}_HEADER_${header}_WRAP_EXCLUDE_PYTHON)
# Find the full path to the header file to be wrapped.
vtk_find_header(${header}.h "${${module}_INCLUDE_DIRS}" class_header_path)
if(NOT class_header_path)
message(FATAL_ERROR "Could not find ${header}.h for Python wrapping!")
endif()
# The new list of headers has the full path to each file.
list(APPEND headers_to_wrap ${class_header_path})
endif()
endforeach()
# Delegate to vtk_wrap_python3
vtk_wrap_python3(${TARGET} ${SRC_LIST_NAME} "${headers_to_wrap}")
endmacro()
|