2010-05-12 01:44:00 +08:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# CMake file for python support
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
project(opencv_python)
|
|
|
|
|
|
|
|
include_directories(${PYTHON_INCLUDE_PATH})
|
|
|
|
include_directories(
|
2011-05-04 00:00:31 +08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src2"
|
2011-06-14 18:19:56 +08:00
|
|
|
"${OpenCV_SOURCE_DIR}/modules/core/include"
|
2011-07-14 07:04:39 +08:00
|
|
|
"${OpenCV_SOURCE_DIR}/modules/flann/include"
|
2011-06-14 18:19:56 +08:00
|
|
|
"${OpenCV_SOURCE_DIR}/modules/imgproc/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/video/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/highgui/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/ml/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/features2d/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/flann/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/calib3d/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/objdetect/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/legacy/include"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/contrib/include"
|
2010-05-12 01:44:00 +08:00
|
|
|
)
|
2010-11-03 01:58:22 +08:00
|
|
|
|
2010-05-12 01:44:00 +08:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
2011-06-14 18:19:56 +08:00
|
|
|
set(opencv_hdrs "${OpenCV_SOURCE_DIR}/modules/core/include/opencv2/core/core.hpp"
|
2011-07-14 07:04:39 +08:00
|
|
|
"${OpenCV_SOURCE_DIR}/modules/flann/include/opencv2/flann/miniflann.hpp"
|
2011-06-14 18:19:56 +08:00
|
|
|
"${OpenCV_SOURCE_DIR}/modules/imgproc/include/opencv2/imgproc/imgproc.hpp"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/video/include/opencv2/video/background_segm.hpp"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/video/include/opencv2/video/tracking.hpp"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/highgui/include/opencv2/highgui/highgui.hpp"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/ml/include/opencv2/ml/ml.hpp"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/features2d/include/opencv2/features2d/features2d.hpp"
|
|
|
|
"${OpenCV_SOURCE_DIR}/modules/calib3d/include/opencv2/calib3d/calib3d.hpp"
|
2011-07-19 00:31:30 +08:00
|
|
|
"${OpenCV_SOURCE_DIR}/modules/objdetect/include/opencv2/objdetect/objdetect.hpp")
|
2010-11-03 01:58:22 +08:00
|
|
|
|
2010-05-12 01:44:00 +08:00
|
|
|
if(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
|
|
|
|
endif()
|
|
|
|
|
2011-05-04 00:00:31 +08:00
|
|
|
set(cv2_generated_hdrs
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_funcs.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_func_tab.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_types.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_type_reg.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_const_reg.h")
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2011-07-12 20:56:03 +08:00
|
|
|
|
2011-05-04 00:00:31 +08:00
|
|
|
add_custom_command(
|
2011-07-12 20:56:03 +08:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated0.i
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/src2/gen.py" "${CMAKE_CURRENT_SOURCE_DIR}/src2"
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/api
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/defs
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/gen.py
|
|
|
|
)
|
2011-05-04 00:00:31 +08:00
|
|
|
|
2011-07-12 20:56:03 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${cv2_generated_hdrs}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/src2/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} ${opencv_hdrs}
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/gen2.py
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/hdr_parser.py
|
|
|
|
DEPENDS ${opencv_hdrs})
|
|
|
|
|
|
|
|
set(cv2_target "opencv_python")
|
2011-07-19 00:31:30 +08:00
|
|
|
add_library(${cv2_target} SHARED src2/cv2.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated0.i ${cv2_generated_hdrs} src2/cv2.cv.hpp)
|
2011-07-14 07:04:39 +08:00
|
|
|
target_link_libraries(${cv2_target} ${PYTHON_LIBRARIES} opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_objdetect opencv_legacy opencv_contrib)
|
2011-07-12 20:56:03 +08:00
|
|
|
|
2011-05-04 00:00:31 +08:00
|
|
|
set_target_properties(${cv2_target} PROPERTIES PREFIX "")
|
|
|
|
set_target_properties(${cv2_target} PROPERTIES OUTPUT_NAME "cv2")
|
2011-07-12 20:56:03 +08:00
|
|
|
|
|
|
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('SO')"
|
|
|
|
RESULT_VARIABLE PYTHON_CVPY_PROCESS
|
|
|
|
OUTPUT_VARIABLE CVPY_SUFFIX
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
2011-05-04 00:00:31 +08:00
|
|
|
set_target_properties(${cv2_target} PROPERTIES SUFFIX ${CVPY_SUFFIX})
|
|
|
|
|
2011-05-30 22:08:43 +08:00
|
|
|
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(${cv2_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
|
|
endif()
|
|
|
|
|
2011-07-12 20:56:03 +08:00
|
|
|
set(cvpymodules ${cv2_target})
|
2010-05-12 01:44:00 +08:00
|
|
|
|
|
|
|
if(WIN32)
|
2011-08-13 02:03:01 +08:00
|
|
|
set(CVPY_PATH "Python${PYTHON_VERSION_MAJOR_MINOR}/Lib/site-packages")
|
2010-05-12 01:44:00 +08:00
|
|
|
else()
|
2011-08-13 02:03:01 +08:00
|
|
|
set(CVPY_PATH ${PYTHON_PACKAGES_PATH})
|
2010-05-12 01:44:00 +08:00
|
|
|
endif()
|
2011-08-13 02:03:01 +08:00
|
|
|
|
|
|
|
install(TARGETS ${cvpymodules}
|
|
|
|
RUNTIME DESTINATION ${CVPY_PATH} COMPONENT main
|
|
|
|
LIBRARY DESTINATION ${CVPY_PATH} COMPONENT main
|
|
|
|
ARCHIVE DESTINATION ${CVPY_PATH} COMPONENT main
|
|
|
|
)
|
|
|
|
install(FILES src2/cv.py DESTINATION ${CVPY_PATH} COMPONENT main)
|